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


The following commit(s) were added to refs/heads/main by this push:
     new 348ba7a09 feat(gitee): add author info to pr commits (#4983)
348ba7a09 is described below

commit 348ba7a09c9b99cc61984c9f7c2589d6fde1c0bf
Author: Warren Chen <[email protected]>
AuthorDate: Thu Apr 20 16:24:04 2023 +0800

    feat(gitee): add author info to pr commits (#4983)
---
 ...0230419_add_commit_authored_date_in_pr_commits.go |  2 +-
 ...date.go => 20230420_add_pr_commit_author_info.go} | 12 ++++++------
 .../bitbucket/models/migrationscripts/register.go    |  2 +-
 ...20230420_add_commit_author_info_in_pr_commits.go} | 20 ++++++++++----------
 .../gitee/models/migrationscripts/register.go        |  1 +
 backend/plugins/gitee/models/pull_request_commit.go  | 10 +++++++---
 backend/plugins/gitee/tasks/pr_commit_convertor.go   |  7 +++++--
 backend/plugins/gitee/tasks/pr_commit_extractor.go   |  9 ++++++---
 ...20230419_add_commit_author_info_in_pr_commits.go} | 18 +++++++++---------
 .../github/models/migrationscripts/register.go       |  2 +-
 backend/plugins/github/models/pr_commit.go           |  4 ++--
 ...date.go => 20230420_add_mr_commit_author_info.go} | 12 ++++++------
 .../gitlab/models/migrationscripts/register.go       |  2 +-
 13 files changed, 56 insertions(+), 45 deletions(-)

diff --git 
a/backend/core/models/migrationscripts/20230419_add_commit_authored_date_in_pr_commits.go
 
b/backend/core/models/migrationscripts/20230419_add_commit_authored_date_in_pr_commits.go
index 7c4ac014b..d455de9ef 100644
--- 
a/backend/core/models/migrationscripts/20230419_add_commit_authored_date_in_pr_commits.go
+++ 
b/backend/core/models/migrationscripts/20230419_add_commit_authored_date_in_pr_commits.go
@@ -53,5 +53,5 @@ func (*addCommitAuthoredDate) Version() uint64 {
 }
 
 func (*addCommitAuthoredDate) Name() string {
-       return "add commit_authored_date to pull_request_commits table"
+       return "add commit author info to pull_request_commits table"
 }
diff --git 
a/backend/plugins/bitbucket/models/migrationscripts/20230420_add_pr_commit_author_date.go
 
b/backend/plugins/bitbucket/models/migrationscripts/20230420_add_pr_commit_author_info.go
similarity index 78%
rename from 
backend/plugins/bitbucket/models/migrationscripts/20230420_add_pr_commit_author_date.go
rename to 
backend/plugins/bitbucket/models/migrationscripts/20230420_add_pr_commit_author_info.go
index 155a2b254..de01ddb00 100644
--- 
a/backend/plugins/bitbucket/models/migrationscripts/20230420_add_pr_commit_author_date.go
+++ 
b/backend/plugins/bitbucket/models/migrationscripts/20230420_add_pr_commit_author_info.go
@@ -26,7 +26,7 @@ import (
        "github.com/apache/incubator-devlake/helpers/migrationhelper"
 )
 
-var _ plugin.MigrationScript = (*addBitbucketCommitAuthoredDate)(nil)
+var _ plugin.MigrationScript = (*addBitbucketCommitAuthorInfo)(nil)
 
 type BitbucketPrCommit20230420 struct {
        CommitAuthorName   string `gorm:"type:varchar(255)"`
@@ -38,9 +38,9 @@ func (BitbucketPrCommit20230420) TableName() string {
        return "_tool_bitbucket_pull_request_commits"
 }
 
-type addBitbucketCommitAuthoredDate struct{}
+type addBitbucketCommitAuthorInfo struct{}
 
-func (script *addBitbucketCommitAuthoredDate) Up(basicRes context.BasicRes) 
errors.Error {
+func (script *addBitbucketCommitAuthorInfo) Up(basicRes context.BasicRes) 
errors.Error {
 
        return migrationhelper.AutoMigrateTables(
                basicRes,
@@ -48,10 +48,10 @@ func (script *addBitbucketCommitAuthoredDate) Up(basicRes 
context.BasicRes) erro
        )
 }
 
-func (*addBitbucketCommitAuthoredDate) Version() uint64 {
+func (*addBitbucketCommitAuthorInfo) Version() uint64 {
        return 20230420135129
 }
 
-func (*addBitbucketCommitAuthoredDate) Name() string {
-       return "add commit_authored_date to 
_tool_bitbucket_pull_request_commits table"
+func (*addBitbucketCommitAuthorInfo) Name() string {
+       return "add commit author info to _tool_bitbucket_pull_request_commits 
table"
 }
diff --git a/backend/plugins/bitbucket/models/migrationscripts/register.go 
b/backend/plugins/bitbucket/models/migrationscripts/register.go
index 8cec7a7f0..e4485ab91 100644
--- a/backend/plugins/bitbucket/models/migrationscripts/register.go
+++ b/backend/plugins/bitbucket/models/migrationscripts/register.go
@@ -35,6 +35,6 @@ func All() []plugin.MigrationScript {
                new(addTypeEnvToPipelineAndStep),
                new(addRepoIdField20230411),
                new(addRepoIdToPr),
-               new(addBitbucketCommitAuthoredDate),
+               new(addBitbucketCommitAuthorInfo),
        }
 }
diff --git 
a/backend/plugins/gitlab/models/migrationscripts/20230420_add_mr_commit_author_date.go
 
b/backend/plugins/gitee/models/migrationscripts/20230420_add_commit_author_info_in_pr_commits.go
similarity index 71%
copy from 
backend/plugins/gitlab/models/migrationscripts/20230420_add_mr_commit_author_date.go
copy to 
backend/plugins/gitee/models/migrationscripts/20230420_add_commit_author_info_in_pr_commits.go
index 6287c2765..42fa84e72 100644
--- 
a/backend/plugins/gitlab/models/migrationscripts/20230420_add_mr_commit_author_date.go
+++ 
b/backend/plugins/gitee/models/migrationscripts/20230420_add_commit_author_info_in_pr_commits.go
@@ -26,32 +26,32 @@ import (
        "github.com/apache/incubator-devlake/helpers/migrationhelper"
 )
 
-var _ plugin.MigrationScript = (*addGitlabCommitAuthoredDate)(nil)
+var _ plugin.MigrationScript = (*addGiteeCommitAuthorInfo)(nil)
 
-type GitlabMrCommit20230420 struct {
+type GiteePrCommit20230419 struct {
        CommitAuthorName   string `gorm:"type:varchar(255)"` // Author name
        CommitAuthorEmail  string `gorm:"type:varchar(255)"` // Author email
        CommitAuthoredDate time.Time
 }
 
-func (GitlabMrCommit20230420) TableName() string {
-       return "_tool_gitlab_mr_commits"
+func (GiteePrCommit20230419) TableName() string {
+       return "_tool_gitee_pull_request_commits"
 }
 
-type addGitlabCommitAuthoredDate struct{}
+type addGiteeCommitAuthorInfo struct{}
 
-func (script *addGitlabCommitAuthoredDate) Up(basicRes context.BasicRes) 
errors.Error {
+func (script *addGiteeCommitAuthorInfo) Up(basicRes context.BasicRes) 
errors.Error {
 
        return migrationhelper.AutoMigrateTables(
                basicRes,
-               &GitlabMrCommit20230420{},
+               &GiteePrCommit20230419{},
        )
 }
 
-func (*addGitlabCommitAuthoredDate) Version() uint64 {
+func (*addGiteeCommitAuthorInfo) Version() uint64 {
        return 20230420135129
 }
 
-func (*addGitlabCommitAuthoredDate) Name() string {
-       return "add commit_authored_date to _tool_gitlab_mr_commits table"
+func (*addGiteeCommitAuthorInfo) Name() string {
+       return "add commit author info to _tool_gitee_pull_request_commits 
table"
 }
diff --git a/backend/plugins/gitee/models/migrationscripts/register.go 
b/backend/plugins/gitee/models/migrationscripts/register.go
index ec054748c..cbb21d711 100644
--- a/backend/plugins/gitee/models/migrationscripts/register.go
+++ b/backend/plugins/gitee/models/migrationscripts/register.go
@@ -25,5 +25,6 @@ import (
 func All() []plugin.MigrationScript {
        return []plugin.MigrationScript{
                new(addInitTables),
+               new(addGiteeCommitAuthorInfo),
        }
 }
diff --git a/backend/plugins/gitee/models/pull_request_commit.go 
b/backend/plugins/gitee/models/pull_request_commit.go
index 4001b7536..2ea46e49a 100644
--- a/backend/plugins/gitee/models/pull_request_commit.go
+++ b/backend/plugins/gitee/models/pull_request_commit.go
@@ -19,12 +19,16 @@ package models
 
 import (
        "github.com/apache/incubator-devlake/core/models/common"
+       "time"
 )
 
 type GiteePullRequestCommit struct {
-       ConnectionId  uint64 `gorm:"primaryKey"`
-       CommitSha     string `gorm:"primaryKey;type:varchar(40)"`
-       PullRequestId int    `gorm:"primaryKey;autoIncrement:false"`
+       ConnectionId       uint64 `gorm:"primaryKey"`
+       CommitSha          string `gorm:"primaryKey;type:varchar(40)"`
+       PullRequestId      int    `gorm:"primaryKey;autoIncrement:false"`
+       CommitAuthorName   string `gorm:"type:varchar(255)"` // Author name
+       CommitAuthorEmail  string `gorm:"type:varchar(255)"` // Author email
+       CommitAuthoredDate time.Time
        common.NoPKModel
 }
 
diff --git a/backend/plugins/gitee/tasks/pr_commit_convertor.go 
b/backend/plugins/gitee/tasks/pr_commit_convertor.go
index 0deecf87e..50e973001 100644
--- a/backend/plugins/gitee/tasks/pr_commit_convertor.go
+++ b/backend/plugins/gitee/tasks/pr_commit_convertor.go
@@ -62,8 +62,11 @@ func ConvertPullRequestCommits(taskCtx 
plugin.SubTaskContext) (err errors.Error)
                Convert: func(inputRow interface{}) ([]interface{}, 
errors.Error) {
                        giteePullRequestCommit := 
inputRow.(*models.GiteePullRequestCommit)
                        domainPrCommit := &code.PullRequestCommit{
-                               CommitSha:     giteePullRequestCommit.CommitSha,
-                               PullRequestId: 
pullIdGen.Generate(data.Options.ConnectionId, 
giteePullRequestCommit.PullRequestId),
+                               CommitSha:          
giteePullRequestCommit.CommitSha,
+                               PullRequestId:      
pullIdGen.Generate(data.Options.ConnectionId, 
giteePullRequestCommit.PullRequestId),
+                               CommitAuthorName:   
giteePullRequestCommit.CommitAuthorName,
+                               CommitAuthorEmail:  
giteePullRequestCommit.CommitAuthorEmail,
+                               CommitAuthoredDate: 
giteePullRequestCommit.CommitAuthoredDate,
                        }
                        return []interface{}{
                                domainPrCommit,
diff --git a/backend/plugins/gitee/tasks/pr_commit_extractor.go 
b/backend/plugins/gitee/tasks/pr_commit_extractor.go
index a6f9ebf2f..02ac5e88b 100644
--- a/backend/plugins/gitee/tasks/pr_commit_extractor.go
+++ b/backend/plugins/gitee/tasks/pr_commit_extractor.go
@@ -93,9 +93,12 @@ func ExtractApiPullRequestCommits(taskCtx 
plugin.SubTaskContext) errors.Error {
                        results = append(results, giteeCommit)
 
                        giteePullRequestCommit := 
&models.GiteePullRequestCommit{
-                               ConnectionId:  data.Options.ConnectionId,
-                               CommitSha:     apiPullRequestCommit.Sha,
-                               PullRequestId: pull.GiteeId,
+                               ConnectionId:       data.Options.ConnectionId,
+                               CommitSha:          apiPullRequestCommit.Sha,
+                               PullRequestId:      pull.GiteeId,
+                               CommitAuthorEmail:  
apiPullRequestCommit.Commit.Author.Email,
+                               CommitAuthorName:   
apiPullRequestCommit.Commit.Author.Name,
+                               CommitAuthoredDate: 
apiPullRequestCommit.Commit.Author.Date.ToTime(),
                        }
                        if err != nil {
                                return nil, err
diff --git 
a/backend/plugins/github/models/migrationscripts/20230419_add_commit_authored_date_in_pr_commits.go
 
b/backend/plugins/github/models/migrationscripts/20230419_add_commit_author_info_in_pr_commits.go
similarity index 70%
rename from 
backend/plugins/github/models/migrationscripts/20230419_add_commit_authored_date_in_pr_commits.go
rename to 
backend/plugins/github/models/migrationscripts/20230419_add_commit_author_info_in_pr_commits.go
index 79ef18bd6..551611870 100644
--- 
a/backend/plugins/github/models/migrationscripts/20230419_add_commit_authored_date_in_pr_commits.go
+++ 
b/backend/plugins/github/models/migrationscripts/20230419_add_commit_author_info_in_pr_commits.go
@@ -26,11 +26,11 @@ import (
        "github.com/apache/incubator-devlake/helpers/migrationhelper"
 )
 
-var _ plugin.MigrationScript = (*addGithubCommitAuthoredDate)(nil)
+var _ plugin.MigrationScript = (*addGithubCommitAuthorInfo)(nil)
 
 type GithubPrCommit20230419 struct {
-       CommitAuthorName   string
-       CommitAuthorEmail  string
+       CommitAuthorName   string `gorm:"type:varchar(255)"` // Author name
+       CommitAuthorEmail  string `gorm:"type:varchar(255)"` // Author email
        CommitAuthoredDate time.Time
 }
 
@@ -38,9 +38,9 @@ func (GithubPrCommit20230419) TableName() string {
        return "_tool_github_pull_request_commits"
 }
 
-type addGithubCommitAuthoredDate struct{}
+type addGithubCommitAuthorInfo struct{}
 
-func (script *addGithubCommitAuthoredDate) Up(basicRes context.BasicRes) 
errors.Error {
+func (script *addGithubCommitAuthorInfo) Up(basicRes context.BasicRes) 
errors.Error {
 
        return migrationhelper.AutoMigrateTables(
                basicRes,
@@ -48,10 +48,10 @@ func (script *addGithubCommitAuthoredDate) Up(basicRes 
context.BasicRes) errors.
        )
 }
 
-func (*addGithubCommitAuthoredDate) Version() uint64 {
-       return 20230419135127
+func (*addGithubCommitAuthorInfo) Version() uint64 {
+       return 20230419135129
 }
 
-func (*addGithubCommitAuthoredDate) Name() string {
-       return "add commit_authored_date to _tool_github_pull_request_commits 
table"
+func (*addGithubCommitAuthorInfo) Name() string {
+       return "add commit author info to _tool_github_pull_request_commits 
table"
 }
diff --git a/backend/plugins/github/models/migrationscripts/register.go 
b/backend/plugins/github/models/migrationscripts/register.go
index 8410643e2..0ea45195b 100644
--- a/backend/plugins/github/models/migrationscripts/register.go
+++ b/backend/plugins/github/models/migrationscripts/register.go
@@ -36,6 +36,6 @@ func All() []plugin.MigrationScript {
                new(addStdTypeToIssue221230),
                new(addConnectionIdToTransformationRule),
                new(addEnvToRunAndJob),
-               new(addGithubCommitAuthoredDate),
+               new(addGithubCommitAuthorInfo),
        }
 }
diff --git a/backend/plugins/github/models/pr_commit.go 
b/backend/plugins/github/models/pr_commit.go
index 6e8890094..f7b9e2665 100644
--- a/backend/plugins/github/models/pr_commit.go
+++ b/backend/plugins/github/models/pr_commit.go
@@ -27,8 +27,8 @@ type GithubPrCommit struct {
        ConnectionId       uint64 `gorm:"primaryKey"`
        CommitSha          string `gorm:"primaryKey;type:varchar(40)"`
        PullRequestId      int    `gorm:"primaryKey;autoIncrement:false"`
-       CommitAuthorName   string
-       CommitAuthorEmail  string
+       CommitAuthorName   string `gorm:"type:varchar(255)"` // Author name
+       CommitAuthorEmail  string `gorm:"type:varchar(255)"` // Author email
        CommitAuthoredDate time.Time
        common.NoPKModel
 }
diff --git 
a/backend/plugins/gitlab/models/migrationscripts/20230420_add_mr_commit_author_date.go
 
b/backend/plugins/gitlab/models/migrationscripts/20230420_add_mr_commit_author_info.go
similarity index 79%
rename from 
backend/plugins/gitlab/models/migrationscripts/20230420_add_mr_commit_author_date.go
rename to 
backend/plugins/gitlab/models/migrationscripts/20230420_add_mr_commit_author_info.go
index 6287c2765..9f28b9571 100644
--- 
a/backend/plugins/gitlab/models/migrationscripts/20230420_add_mr_commit_author_date.go
+++ 
b/backend/plugins/gitlab/models/migrationscripts/20230420_add_mr_commit_author_info.go
@@ -26,7 +26,7 @@ import (
        "github.com/apache/incubator-devlake/helpers/migrationhelper"
 )
 
-var _ plugin.MigrationScript = (*addGitlabCommitAuthoredDate)(nil)
+var _ plugin.MigrationScript = (*addGitlabCommitAuthorInfo)(nil)
 
 type GitlabMrCommit20230420 struct {
        CommitAuthorName   string `gorm:"type:varchar(255)"` // Author name
@@ -38,9 +38,9 @@ func (GitlabMrCommit20230420) TableName() string {
        return "_tool_gitlab_mr_commits"
 }
 
-type addGitlabCommitAuthoredDate struct{}
+type addGitlabCommitAuthorInfo struct{}
 
-func (script *addGitlabCommitAuthoredDate) Up(basicRes context.BasicRes) 
errors.Error {
+func (script *addGitlabCommitAuthorInfo) Up(basicRes context.BasicRes) 
errors.Error {
 
        return migrationhelper.AutoMigrateTables(
                basicRes,
@@ -48,10 +48,10 @@ func (script *addGitlabCommitAuthoredDate) Up(basicRes 
context.BasicRes) errors.
        )
 }
 
-func (*addGitlabCommitAuthoredDate) Version() uint64 {
+func (*addGitlabCommitAuthorInfo) Version() uint64 {
        return 20230420135129
 }
 
-func (*addGitlabCommitAuthoredDate) Name() string {
-       return "add commit_authored_date to _tool_gitlab_mr_commits table"
+func (*addGitlabCommitAuthorInfo) Name() string {
+       return "add commit author info to _tool_gitlab_mr_commits table"
 }
diff --git a/backend/plugins/gitlab/models/migrationscripts/register.go 
b/backend/plugins/gitlab/models/migrationscripts/register.go
index 4f65f5ea3..6be1f60fe 100644
--- a/backend/plugins/gitlab/models/migrationscripts/register.go
+++ b/backend/plugins/gitlab/models/migrationscripts/register.go
@@ -33,7 +33,7 @@ func All() []plugin.MigrationScript {
                new(addStdTypeToIssue221230),
                new(addIsDetailRequired20230210),
                new(addConnectionIdToTransformationRule),
-               new(addGitlabCommitAuthoredDate),
+               new(addGitlabCommitAuthorInfo),
                new(addTypeEnvToPipeline),
        }
 }

Reply via email to