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 2c9807670 feat: add reporul to gitlab (#4876)
2c9807670 is described below

commit 2c980767075b3160b4954784bdb600e09fa708d9
Author: mappjzc <[email protected]>
AuthorDate: Mon Apr 10 09:19:00 2023 +0800

    feat: add reporul to gitlab (#4876)
    
    Add repo_url to gitlab.
    
    Nddtfjiang <[email protected]>
---
 backend/plugins/gitlab/e2e/pipelines_test.go       |  4 ++-
 .../e2e/snapshot_tables/cicd_pipeline_commits.csv  | 40 +++++++++++-----------
 .../gitlab/tasks/pipeline_commit_convertor.go      |  7 ++++
 3 files changed, 30 insertions(+), 21 deletions(-)

diff --git a/backend/plugins/gitlab/e2e/pipelines_test.go 
b/backend/plugins/gitlab/e2e/pipelines_test.go
index e574ed8d8..d313ed3b2 100644
--- a/backend/plugins/gitlab/e2e/pipelines_test.go
+++ b/backend/plugins/gitlab/e2e/pipelines_test.go
@@ -18,13 +18,14 @@ limitations under the License.
 package e2e
 
 import (
+       "testing"
+
        "github.com/apache/incubator-devlake/core/models/common"
        "github.com/apache/incubator-devlake/core/models/domainlayer/devops"
        "github.com/apache/incubator-devlake/helpers/e2ehelper"
        "github.com/apache/incubator-devlake/plugins/gitlab/impl"
        "github.com/apache/incubator-devlake/plugins/gitlab/models"
        "github.com/apache/incubator-devlake/plugins/gitlab/tasks"
-       "testing"
 )
 
 func TestGitlabPipelineDataFlow(t *testing.T) {
@@ -41,6 +42,7 @@ func TestGitlabPipelineDataFlow(t *testing.T) {
        }
        // import raw data table
        
dataflowTester.ImportCsvIntoRawTable("./raw_tables/_raw_gitlab_api_pipeline.csv",
 "_raw_gitlab_api_pipeline")
+       
dataflowTester.ImportCsvIntoTabler("./raw_tables/_tool_gitlab_projects.csv", 
&models.GitlabProject{})
 
        // verify extraction
        dataflowTester.FlushTabler(&models.GitlabPipeline{})
diff --git 
a/backend/plugins/gitlab/e2e/snapshot_tables/cicd_pipeline_commits.csv 
b/backend/plugins/gitlab/e2e/snapshot_tables/cicd_pipeline_commits.csv
index d34b65eb3..89c570eaf 100644
--- a/backend/plugins/gitlab/e2e/snapshot_tables/cicd_pipeline_commits.csv
+++ b/backend/plugins/gitlab/e2e/snapshot_tables/cicd_pipeline_commits.csv
@@ -1,21 +1,21 @@
 pipeline_id,commit_sha,branch,repo_id,repo_url
-gitlab:GitlabPipeline:1:457474837,b1b82852d48b516a18e56c5bab0ebf54b8f4ccfd,renovate/pin-dependencies,gitlab:GitlabProject:1:12345678,
-gitlab:GitlabPipeline:1:457474996,739ab912e6e1ed27cecd8a2d00bfd6fa52afd90a,renovate/jest-monorepo,gitlab:GitlabProject:1:12345678,
-gitlab:GitlabPipeline:1:457475160,44d127e0ab7dbc4bc259b55929c9d00b62fc3bf4,renovate/lodash-monorepo,gitlab:GitlabProject:1:12345678,
-gitlab:GitlabPipeline:1:457475337,10a6464b6bd2cf4b59b8ac37ce1466e013f5a20d,renovate/shx-0.x,gitlab:GitlabProject:1:12345678,
-gitlab:GitlabPipeline:1:485811050,c791ea6949d6b4aadf79b15ba666cb690c6527ac,EE-7121,gitlab:GitlabProject:1:12345678,
-gitlab:GitlabPipeline:1:485811059,c791ea6949d6b4aadf79b15ba666cb690c6527ac,refs/merge-requests/74/head,gitlab:GitlabProject:1:12345678,
-gitlab:GitlabPipeline:1:485813816,ecc7c0b2874c812ed882c9effbbda26e0abc7110,EE-7121,gitlab:GitlabProject:1:12345678,
-gitlab:GitlabPipeline:1:485813830,ecc7c0b2874c812ed882c9effbbda26e0abc7110,refs/merge-requests/74/head,gitlab:GitlabProject:1:12345678,
-gitlab:GitlabPipeline:1:485814501,6a3346f8434cc65fbe3f7a80a0edec5b4014a733,EE-7121,gitlab:GitlabProject:1:12345678,
-gitlab:GitlabPipeline:1:485814516,6a3346f8434cc65fbe3f7a80a0edec5b4014a733,refs/merge-requests/74/head,gitlab:GitlabProject:1:12345678,
-gitlab:GitlabPipeline:1:485814871,f731732471961fed061a01fa99631f69e861c4a2,refs/merge-requests/74/head,gitlab:GitlabProject:1:12345678,
-gitlab:GitlabPipeline:1:485817670,5b95c5aebce1eae6a1b95ecf6fbc870851455375,refs/merge-requests/74/head,gitlab:GitlabProject:1:12345678,
-gitlab:GitlabPipeline:1:485837602,a79e2aaeee9916338a11b665cb4201f24627f3f1,refs/merge-requests/74/head,gitlab:GitlabProject:1:12345678,
-gitlab:GitlabPipeline:1:485842553,9e0934cedcd83abab8d34c5bb0f597c7837a55f0,refs/merge-requests/74/head,gitlab:GitlabProject:1:12345678,
-gitlab:GitlabPipeline:1:485845850,b3b581940f6d4d3226db31e48eab2b3b73f4c6db,refs/merge-requests/74/head,gitlab:GitlabProject:1:12345678,
-gitlab:GitlabPipeline:1:485852752,82df93eeb72c71271dad5a85359f39661de899fe,refs/merge-requests/74/head,gitlab:GitlabProject:1:12345678,
-gitlab:GitlabPipeline:1:485865876,db45efd231dbaca1337bd29bc1f65f404754e6bd,refs/merge-requests/74/head,gitlab:GitlabProject:1:12345678,
-gitlab:GitlabPipeline:1:485877118,09f81b1b2d083411c0bfecd32d7728479b594503,refs/merge-requests/74/head,gitlab:GitlabProject:1:12345678,
-gitlab:GitlabPipeline:1:485905167,cce432655861efafcd05edc8de09e305c772d2b8,refs/merge-requests/74/head,gitlab:GitlabProject:1:12345678,
-gitlab:GitlabPipeline:1:485932863,12fc3a42080bb98ca520817bd4fe0ca33c0bb279,refs/merge-requests/74/head,gitlab:GitlabProject:1:12345678,
+gitlab:GitlabPipeline:1:457474837,b1b82852d48b516a18e56c5bab0ebf54b8f4ccfd,renovate/pin-dependencies,gitlab:GitlabProject:1:12345678,https://gitlab.com/gitlab-data/snowflake_spend
+gitlab:GitlabPipeline:1:457474996,739ab912e6e1ed27cecd8a2d00bfd6fa52afd90a,renovate/jest-monorepo,gitlab:GitlabProject:1:12345678,https://gitlab.com/gitlab-data/snowflake_spend
+gitlab:GitlabPipeline:1:457475160,44d127e0ab7dbc4bc259b55929c9d00b62fc3bf4,renovate/lodash-monorepo,gitlab:GitlabProject:1:12345678,https://gitlab.com/gitlab-data/snowflake_spend
+gitlab:GitlabPipeline:1:457475337,10a6464b6bd2cf4b59b8ac37ce1466e013f5a20d,renovate/shx-0.x,gitlab:GitlabProject:1:12345678,https://gitlab.com/gitlab-data/snowflake_spend
+gitlab:GitlabPipeline:1:485811050,c791ea6949d6b4aadf79b15ba666cb690c6527ac,EE-7121,gitlab:GitlabProject:1:12345678,https://gitlab.com/gitlab-data/snowflake_spend
+gitlab:GitlabPipeline:1:485811059,c791ea6949d6b4aadf79b15ba666cb690c6527ac,refs/merge-requests/74/head,gitlab:GitlabProject:1:12345678,https://gitlab.com/gitlab-data/snowflake_spend
+gitlab:GitlabPipeline:1:485813816,ecc7c0b2874c812ed882c9effbbda26e0abc7110,EE-7121,gitlab:GitlabProject:1:12345678,https://gitlab.com/gitlab-data/snowflake_spend
+gitlab:GitlabPipeline:1:485813830,ecc7c0b2874c812ed882c9effbbda26e0abc7110,refs/merge-requests/74/head,gitlab:GitlabProject:1:12345678,https://gitlab.com/gitlab-data/snowflake_spend
+gitlab:GitlabPipeline:1:485814501,6a3346f8434cc65fbe3f7a80a0edec5b4014a733,EE-7121,gitlab:GitlabProject:1:12345678,https://gitlab.com/gitlab-data/snowflake_spend
+gitlab:GitlabPipeline:1:485814516,6a3346f8434cc65fbe3f7a80a0edec5b4014a733,refs/merge-requests/74/head,gitlab:GitlabProject:1:12345678,https://gitlab.com/gitlab-data/snowflake_spend
+gitlab:GitlabPipeline:1:485814871,f731732471961fed061a01fa99631f69e861c4a2,refs/merge-requests/74/head,gitlab:GitlabProject:1:12345678,https://gitlab.com/gitlab-data/snowflake_spend
+gitlab:GitlabPipeline:1:485817670,5b95c5aebce1eae6a1b95ecf6fbc870851455375,refs/merge-requests/74/head,gitlab:GitlabProject:1:12345678,https://gitlab.com/gitlab-data/snowflake_spend
+gitlab:GitlabPipeline:1:485837602,a79e2aaeee9916338a11b665cb4201f24627f3f1,refs/merge-requests/74/head,gitlab:GitlabProject:1:12345678,https://gitlab.com/gitlab-data/snowflake_spend
+gitlab:GitlabPipeline:1:485842553,9e0934cedcd83abab8d34c5bb0f597c7837a55f0,refs/merge-requests/74/head,gitlab:GitlabProject:1:12345678,https://gitlab.com/gitlab-data/snowflake_spend
+gitlab:GitlabPipeline:1:485845850,b3b581940f6d4d3226db31e48eab2b3b73f4c6db,refs/merge-requests/74/head,gitlab:GitlabProject:1:12345678,https://gitlab.com/gitlab-data/snowflake_spend
+gitlab:GitlabPipeline:1:485852752,82df93eeb72c71271dad5a85359f39661de899fe,refs/merge-requests/74/head,gitlab:GitlabProject:1:12345678,https://gitlab.com/gitlab-data/snowflake_spend
+gitlab:GitlabPipeline:1:485865876,db45efd231dbaca1337bd29bc1f65f404754e6bd,refs/merge-requests/74/head,gitlab:GitlabProject:1:12345678,https://gitlab.com/gitlab-data/snowflake_spend
+gitlab:GitlabPipeline:1:485877118,09f81b1b2d083411c0bfecd32d7728479b594503,refs/merge-requests/74/head,gitlab:GitlabProject:1:12345678,https://gitlab.com/gitlab-data/snowflake_spend
+gitlab:GitlabPipeline:1:485905167,cce432655861efafcd05edc8de09e305c772d2b8,refs/merge-requests/74/head,gitlab:GitlabProject:1:12345678,https://gitlab.com/gitlab-data/snowflake_spend
+gitlab:GitlabPipeline:1:485932863,12fc3a42080bb98ca520817bd4fe0ca33c0bb279,refs/merge-requests/74/head,gitlab:GitlabProject:1:12345678,https://gitlab.com/gitlab-data/snowflake_spend
diff --git a/backend/plugins/gitlab/tasks/pipeline_commit_convertor.go 
b/backend/plugins/gitlab/tasks/pipeline_commit_convertor.go
index f7a6a4840..f400de05d 100644
--- a/backend/plugins/gitlab/tasks/pipeline_commit_convertor.go
+++ b/backend/plugins/gitlab/tasks/pipeline_commit_convertor.go
@@ -41,6 +41,12 @@ func ConvertPipelineCommits(taskCtx plugin.SubTaskContext) 
errors.Error {
        db := taskCtx.GetDal()
        data := taskCtx.GetData().(*GitlabTaskData)
 
+       repo := &gitlabModels.GitlabProject{}
+       err := db.First(repo, dal.Where("gitlab_id = ? and connection_id = ?", 
data.Options.ProjectId, data.Options.ConnectionId))
+       if err != nil {
+               return err
+       }
+
        cursor, err := db.Cursor(dal.From(gitlabModels.GitlabPipelineProject{}),
                dal.Where("project_id = ? and connection_id = ?", 
data.Options.ProjectId, data.Options.ConnectionId))
        if err != nil {
@@ -70,6 +76,7 @@ func ConvertPipelineCommits(taskCtx plugin.SubTaskContext) 
errors.Error {
                                Branch:     gitlabPipelineCommit.Ref,
                                RepoId: 
didgen.NewDomainIdGenerator(&gitlabModels.GitlabProject{}).
                                        
Generate(gitlabPipelineCommit.ConnectionId, gitlabPipelineCommit.ProjectId),
+                               RepoUrl: repo.WebUrl,
                        }
 
                        return []interface{}{

Reply via email to