This is an automated email from the ASF dual-hosted git repository. abeizn pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit 5ccbc1e3826b6f159b64326182e3104c2abfdc58 Author: xgdyp <[email protected]> AuthorDate: Fri Jul 15 14:24:30 2022 +0800 fix: change table name filecomponent->component; commitfilecomponent->filecomponent --- models/domainlayer/code/commit.go | 12 ++++++------ models/migrationscripts/updateSchemas20220711.go | 16 ++++++++-------- plugins/gitextractor/models/interface.go | 2 +- plugins/gitextractor/parser/repo.go | 10 +++++----- plugins/gitextractor/store/csv.go | 2 +- plugins/gitextractor/store/database.go | 2 +- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/models/domainlayer/code/commit.go b/models/domainlayer/code/commit.go index b48ef489..77065b1e 100644 --- a/models/domainlayer/code/commit.go +++ b/models/domainlayer/code/commit.go @@ -57,23 +57,23 @@ func (CommitFile) TableName() string { return "commit_files" } -type FileComponent struct { +type Component struct { RepoId string `gorm:"primaryKey;type:varchar(255)"` Component string `gorm:"primaryKey;type:varchar(255)"` PathRegex string `gorm:"type:varchar(255)"` } -func (FileComponent) TableName() string { - return "file_component" +func (Component) TableName() string { + return "component" } -type CommitfileComponent struct { +type FileComponent struct { common.NoPKModel CommitFileID string `gorm:"primaryKey;type:varchar(255)"` RepoId string `gorm:"primaryKey;type:varchar(255)"` Component string `gorm:"type:varchar(255)"` } -func (CommitfileComponent) TableName() string { - return "commitfile_component" +func (FileComponent) TableName() string { + return "file_component" } diff --git a/models/migrationscripts/updateSchemas20220711.go b/models/migrationscripts/updateSchemas20220711.go index ffbbe3d5..4aa8c64b 100644 --- a/models/migrationscripts/updateSchemas20220711.go +++ b/models/migrationscripts/updateSchemas20220711.go @@ -32,14 +32,14 @@ import ( // return "code_component_20220711" //} -type FileComponent struct { +type Component struct { RepoId string `gorm:"primaryKey;type:varchar(255)"` Component string `gorm:"primaryKey;type:varchar(255)"` PathRegex string `gorm:"type:varchar(255)"` } -func (FileComponent) TableName() string { - return "file_component" +func (Component) TableName() string { + return "component" } type CommitFile struct { @@ -56,22 +56,22 @@ func (CommitFile) TableName() string { return "commit_files" } -type CommitfileComponent struct { +type FileComponent struct { common.NoPKModel CommitFileID string `gorm:"primaryKey;type:varchar(255)"` RepoId string `gorm:"primaryKey;type:varchar(255)"` Component string `gorm:"type:varchar(255)"` } -func (CommitfileComponent) TableName() string { - return "commitfile_component" +func (FileComponent) TableName() string { + return "file_component" } type updateSchemas20220711 struct{} func (*updateSchemas20220711) Up(ctx context.Context, db *gorm.DB) error { - err := db.Migrator().AutoMigrate(FileComponent{}, CommitFile{}, CommitfileComponent{}) + err := db.Migrator().AutoMigrate(Component{}, CommitFile{}, FileComponent{}) if err != nil { return err } @@ -80,7 +80,7 @@ func (*updateSchemas20220711) Up(ctx context.Context, db *gorm.DB) error { } func (*updateSchemas20220711) Version() uint64 { - return 202207151400 + return 202207151420 } func (*updateSchemas20220711) Name() string { diff --git a/plugins/gitextractor/models/interface.go b/plugins/gitextractor/models/interface.go index 86d73bab..a5ae3a86 100644 --- a/plugins/gitextractor/models/interface.go +++ b/plugins/gitextractor/models/interface.go @@ -27,6 +27,6 @@ type Store interface { Refs(ref *code.Ref) error CommitFiles(file *code.CommitFile) error CommitParents(pp []*code.CommitParent) error - CommitfileComponent(component *code.CommitfileComponent) error + FileComponent(component *code.FileComponent) error Close() error } diff --git a/plugins/gitextractor/parser/repo.go b/plugins/gitextractor/parser/repo.go index 8656a5e1..a796ca23 100644 --- a/plugins/gitextractor/parser/repo.go +++ b/plugins/gitextractor/parser/repo.go @@ -191,7 +191,7 @@ func (r *GitRepo) CollectCommits(subtaskCtx core.SubTaskContext) error { return err } db := subtaskCtx.GetDal() - components := make([]code.FileComponent, 0) + components := make([]code.Component, 0) err = db.All(&components, dal.From(components), dal.Where("repo_id= ?", r.id)) if err != nil { return err @@ -312,7 +312,7 @@ func (r *GitRepo) getDiffComparedToParent(commitSha string, commit *git.Commit, func (r *GitRepo) storeCommitFilesFromDiff(commitSha string, diff *git.Diff, componentMap map[string]*regexp.Regexp) error { var commitFile *code.CommitFile - var commitfileComponent *code.CommitfileComponent + var commitfileComponent *code.FileComponent var err error err = diff.ForEach(func(file git.DiffDelta, progress float64) ( git.DiffForEachHunkCallback, error) { @@ -328,7 +328,7 @@ func (r *GitRepo) storeCommitFilesFromDiff(commitSha string, diff *git.Diff, com commitFile.CommitSha = commitSha commitFile.FilePath = file.NewFile.Path commitFile.CommitFileID = commitSha + ":" + file.NewFile.Path - commitfileComponent = new(code.CommitfileComponent) + commitfileComponent = new(code.FileComponent) for component, reg := range componentMap { if reg.MatchString(commitFile.FilePath) { commitfileComponent.Component = component @@ -355,9 +355,9 @@ func (r *GitRepo) storeCommitFilesFromDiff(commitSha string, diff *git.Diff, com }, nil }, git.DiffDetailLines) if commitfileComponent != nil { - err = r.store.CommitfileComponent(commitfileComponent) + err = r.store.FileComponent(commitfileComponent) if err != nil { - r.logger.Error("CommitfileComponent error:", err) + r.logger.Error("FileComponent error:", err) } } if commitFile != nil { diff --git a/plugins/gitextractor/store/csv.go b/plugins/gitextractor/store/csv.go index 8a389116..bdf4205c 100644 --- a/plugins/gitextractor/store/csv.go +++ b/plugins/gitextractor/store/csv.go @@ -132,7 +132,7 @@ func (c *CsvStore) Refs(ref *code.Ref) error { func (c *CsvStore) CommitFiles(file *code.CommitFile) error { return c.commitFileWriter.Write(file) } -func (c *CsvStore) CommitfileComponent(component *code.CommitfileComponent) error { +func (c *CsvStore) FileComponent(component *code.FileComponent) error { return c.commitFileWriter.Write(component) } diff --git a/plugins/gitextractor/store/database.go b/plugins/gitextractor/store/database.go index 2821b0f5..564433d5 100644 --- a/plugins/gitextractor/store/database.go +++ b/plugins/gitextractor/store/database.go @@ -91,7 +91,7 @@ func (d *Database) CommitFiles(file *code.CommitFile) error { return batch.Add(file) } -func (d *Database) CommitfileComponent(commitfile *code.CommitfileComponent) error { +func (d *Database) FileComponent(commitfile *code.FileComponent) error { batch, err := d.driver.ForType(reflect.TypeOf(commitfile)) if err != nil { return err
