This is an automated email from the ASF dual-hosted git repository.

zhangliang2022 pushed a commit to branch release-v0.12
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit 383a124aaba5144f6abe5af35b868b8739a7e398
Author: mindlesscloud <[email protected]>
AuthorDate: Mon Aug 1 21:45:03 2022 +0800

    fix: resolve conflit
---
 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 332a8d01..a03a485b 100644
--- a/models/migrationscripts/register.go
+++ b/models/migrationscripts/register.go
@@ -31,5 +31,6 @@ func All() []migration.Script {
                new(addTypeField),
                new(commitfileComponent),
                new(removeNotes),
+               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 {

Reply via email to