This is an automated email from the ASF dual-hosted git repository.
klesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/main by this push:
new 4389c64f fix: add NoPKModel to commit_parents (#2654)
4389c64f is described below
commit 4389c64fdbbb86b4c2a0a6645977312ed7d8adbc
Author: mindlesscloud <[email protected]>
AuthorDate: Mon Aug 1 21:45:03 2022 +0800
fix: add NoPKModel to commit_parents (#2654)
---
models/domainlayer/code/commit_parent.go | 3 ++
.../20220801_add_NoPKModel_to_CommitParent.go} | 32 ++++++++++++++++++++--
models/migrationscripts/register.go | 1 +
plugins/gitextractor/parser/repo.go | 3 +-
4 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/models/domainlayer/code/commit_parent.go
b/models/domainlayer/code/commit_parent.go
index 610e2854..ddae059a 100644
--- a/models/domainlayer/code/commit_parent.go
+++ b/models/domainlayer/code/commit_parent.go
@@ -17,7 +17,10 @@ limitations under the License.
package code
+import "github.com/apache/incubator-devlake/models/common"
+
type CommitParent struct {
+ common.NoPKModel
CommitSha string `json:"commitSha"
gorm:"primaryKey;type:varchar(40);comment:commit hash"`
ParentCommitSha string `json:"parentCommitSha"
gorm:"primaryKey;type:varchar(40);comment:parent commit hash"`
}
diff --git a/models/domainlayer/code/commit_parent.go
b/models/migrationscripts/20220801_add_NoPKModel_to_CommitParent.go
similarity index 62%
copy from models/domainlayer/code/commit_parent.go
copy to models/migrationscripts/20220801_add_NoPKModel_to_CommitParent.go
index 610e2854..b65e3e08 100644
--- a/models/domainlayer/code/commit_parent.go
+++ b/models/migrationscripts/20220801_add_NoPKModel_to_CommitParent.go
@@ -15,13 +15,39 @@ See the License for the specific language governing
permissions and
limitations under the License.
*/
-package code
+package migrationscripts
-type CommitParent struct {
+import (
+ "context"
+ "github.com/apache/incubator-devlake/models/common"
+ "gorm.io/gorm"
+)
+
+type commitParent struct {
+ common.NoPKModel
CommitSha string `json:"commitSha"
gorm:"primaryKey;type:varchar(40);comment:commit hash"`
ParentCommitSha string `json:"parentCommitSha"
gorm:"primaryKey;type:varchar(40);comment:parent commit hash"`
}
-func (CommitParent) TableName() string {
+func (commitParent) TableName() string {
return "commit_parents"
}
+
+type addNoPKModelToCommitParent struct{}
+
+func (*addNoPKModelToCommitParent) Up(ctx context.Context, db *gorm.DB) error {
+ err := db.Migrator().AutoMigrate(&commitParent{})
+ if err != nil {
+ return err
+ }
+
+ return nil
+}
+
+func (*addNoPKModelToCommitParent) Version() uint64 {
+ return 20220801162735
+}
+
+func (*addNoPKModelToCommitParent) Name() string {
+ return "add NoPKModel to commit_parents"
+}
diff --git a/models/migrationscripts/register.go
b/models/migrationscripts/register.go
index 1ddc29de..c49fab8e 100644
--- a/models/migrationscripts/register.go
+++ b/models/migrationscripts/register.go
@@ -32,5 +32,6 @@ func All() []migration.Script {
new(commitfileComponent),
new(removeNotes),
new(addProjectMapping),
+ new(addNoPKModelToCommitParent),
}
}
diff --git a/plugins/gitextractor/parser/repo.go
b/plugins/gitextractor/parser/repo.go
index cf1d5655..d298d947 100644
--- a/plugins/gitextractor/parser/repo.go
+++ b/plugins/gitextractor/parser/repo.go
@@ -235,7 +235,8 @@ func (r *GitRepo) CollectCommits(subtaskCtx
core.SubTaskContext) error {
c.CommitterId = committer.Email
c.CommittedDate = committer.When
}
- if err != r.storeParentCommits(commitSha, commit) {
+ err = r.storeParentCommits(commitSha, commit)
+ if err != nil {
return err
}
if commit.ParentCount() > 0 {