You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by kl...@apache.org on 2023/09/06 06:06:03 UTC
[incubator-devlake] branch release-v0.18 updated: Fix gitlab cicd data issue (#5994) (#6022)
This is an automated email from the ASF dual-hosted git repository.
klesh pushed a commit to branch release-v0.18
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/release-v0.18 by this push:
new 903f6fb6a Fix gitlab cicd data issue (#5994) (#6022)
903f6fb6a is described below
commit 903f6fb6a70436a2c419a4b971fc1d49a2423c32
Author: Leric Zhang <li...@merico.dev>
AuthorDate: Wed Sep 6 14:05:59 2023 +0800
Fix gitlab cicd data issue (#5994) (#6022)
* fix(gitlab): all cicd_pipeline record have same name (#5986)
* fix(gitlab): fix cicd_pipeline created_date and duration_sec (#5988)
* fix: tapd handling of repo url, namespace could contain slash (#5991)
* fix(tapd): tapd repo_name in issue_repo_commit_* should use repo name in url (#5991)
---
.../pluginhelper/api/api_collector_with_state.go | 1 +
.../gitlab/e2e/snapshot_tables/cicd_pipelines.csv | 40 +++++++++++-----------
backend/plugins/gitlab/tasks/pipeline_convertor.go | 15 ++++----
.../e2e/snapshot_tables/issue_repo_commits_bug.csv | 12 +++----
.../snapshot_tables/issue_repo_commits_story.csv | 12 +++----
.../snapshot_tables/issue_repo_commits_task.csv | 12 +++----
backend/plugins/tapd/tasks/bug_commit_converter.go | 11 +++---
backend/plugins/tapd/tasks/shared.go | 22 ++++++++++++
.../plugins/tapd/tasks/story_commit_converter.go | 11 +++---
.../plugins/tapd/tasks/task_commit_converter.go | 11 +++---
10 files changed, 87 insertions(+), 60 deletions(-)
diff --git a/backend/helpers/pluginhelper/api/api_collector_with_state.go b/backend/helpers/pluginhelper/api/api_collector_with_state.go
index 65d4e2176..2216497fe 100644
--- a/backend/helpers/pluginhelper/api/api_collector_with_state.go
+++ b/backend/helpers/pluginhelper/api/api_collector_with_state.go
@@ -78,6 +78,7 @@ func (m *ApiCollectorStateManager) IsIncremental() bool {
if prevSyncTime == nil {
return false
}
+ // if we cleared the timeAfter, or moved timeAfter back in time, we should do a full sync
if currTimeAfter != nil {
return prevTimeAfter == nil || !currTimeAfter.Before(*prevTimeAfter)
}
diff --git a/backend/plugins/gitlab/e2e/snapshot_tables/cicd_pipelines.csv b/backend/plugins/gitlab/e2e/snapshot_tables/cicd_pipelines.csv
index b09f525ea..beaf52710 100644
--- a/backend/plugins/gitlab/e2e/snapshot_tables/cicd_pipelines.csv
+++ b/backend/plugins/gitlab/e2e/snapshot_tables/cicd_pipelines.csv
@@ -1,21 +1,21 @@
id,name,result,status,type,duration_sec,environment,created_date,finished_date,cicd_scope_id
-gitlab:GitlabPipeline:1:457474837,gitlab:GitlabProject:1:12345678,,IN_PROGRESS,,0,,2022-01-27T10:07:09.429+00:00,,gitlab:GitlabProject:1:12345678
-gitlab:GitlabPipeline:1:457474996,gitlab:GitlabProject:1:12345678,FAILURE,DONE,,0,,2022-01-27T10:07:18.884+00:00,2022-01-27T10:07:19.043+00:00,gitlab:GitlabProject:1:12345678
-gitlab:GitlabPipeline:1:457475160,gitlab:GitlabProject:1:12345678,FAILURE,DONE,,0,,2022-01-27T10:07:26.435+00:00,2022-01-27T10:07:26.638+00:00,gitlab:GitlabProject:1:12345678
-gitlab:GitlabPipeline:1:457475337,gitlab:GitlabProject:1:12345678,,IN_PROGRESS,,0,,2022-01-27T10:07:36.502+00:00,,gitlab:GitlabProject:1:12345678
-gitlab:GitlabPipeline:1:485811050,gitlab:GitlabProject:1:12345678,FAILURE,DONE,DEPLOYMENT,0,PRODUCTION,2022-03-07T06:26:42.109+00:00,2022-03-07T06:26:42.109+00:00,gitlab:GitlabProject:1:12345678
-gitlab:GitlabPipeline:1:485811059,gitlab:GitlabProject:1:12345678,FAILURE,DONE,,0,,2022-03-07T06:26:43.784+00:00,2022-03-07T06:26:43.784+00:00,gitlab:GitlabProject:1:12345678
-gitlab:GitlabPipeline:1:485813816,gitlab:GitlabProject:1:12345678,FAILURE,DONE,DEPLOYMENT,0,PRODUCTION,2022-03-07T06:33:56.824+00:00,2022-03-07T06:33:56.824+00:00,gitlab:GitlabProject:1:12345678
-gitlab:GitlabPipeline:1:485813830,gitlab:GitlabProject:1:12345678,FAILURE,DONE,,0,,2022-03-07T06:33:58.889+00:00,2022-03-07T06:33:58.889+00:00,gitlab:GitlabProject:1:12345678
-gitlab:GitlabPipeline:1:485814501,gitlab:GitlabProject:1:12345678,FAILURE,DONE,DEPLOYMENT,0,PRODUCTION,2022-03-07T06:35:28.111+00:00,2022-03-07T06:35:28.111+00:00,gitlab:GitlabProject:1:12345678
-gitlab:GitlabPipeline:1:485814516,gitlab:GitlabProject:1:12345678,FAILURE,DONE,,0,,2022-03-07T06:35:31.255+00:00,2022-03-07T06:35:31.255+00:00,gitlab:GitlabProject:1:12345678
-gitlab:GitlabPipeline:1:485814871,gitlab:GitlabProject:1:12345678,FAILURE,DONE,,42,,2022-03-07T06:36:50.020+00:00,2022-03-07T06:37:32.103+00:00,gitlab:GitlabProject:1:12345678
-gitlab:GitlabPipeline:1:485817670,gitlab:GitlabProject:1:12345678,FAILURE,DONE,,1956,,2022-03-07T06:45:09.471+00:00,2022-03-07T07:17:46.305+00:00,gitlab:GitlabProject:1:12345678
-gitlab:GitlabPipeline:1:485837602,gitlab:GitlabProject:1:12345678,FAILURE,DONE,,434,,2022-03-07T07:20:45.859+00:00,2022-03-07T07:28:00.277+00:00,gitlab:GitlabProject:1:12345678
-gitlab:GitlabPipeline:1:485842553,gitlab:GitlabProject:1:12345678,FAILURE,DONE,,287,,2022-03-07T07:30:47.018+00:00,2022-03-07T07:35:34.998+00:00,gitlab:GitlabProject:1:12345678
-gitlab:GitlabPipeline:1:485845850,gitlab:GitlabProject:1:12345678,FAILURE,DONE,,419,,2022-03-07T07:38:58.611+00:00,2022-03-07T07:45:58.412+00:00,gitlab:GitlabProject:1:12345678
-gitlab:GitlabPipeline:1:485852752,gitlab:GitlabProject:1:12345678,FAILURE,DONE,,319,,2022-03-07T07:46:09.385+00:00,2022-03-07T07:51:28.709+00:00,gitlab:GitlabProject:1:12345678
-gitlab:GitlabPipeline:1:485865876,gitlab:GitlabProject:1:12345678,FAILURE,DONE,,480,,2022-03-07T08:04:56.406+00:00,2022-03-07T08:12:56.453+00:00,gitlab:GitlabProject:1:12345678
-gitlab:GitlabPipeline:1:485877118,gitlab:GitlabProject:1:12345678,FAILURE,DONE,,289,,2022-03-07T08:22:48.943+00:00,2022-03-07T08:27:38.364+00:00,gitlab:GitlabProject:1:12345678
-gitlab:GitlabPipeline:1:485905167,gitlab:GitlabProject:1:12345678,FAILURE,DONE,,687,,2022-03-07T09:02:09.994+00:00,2022-03-07T09:13:37.013+00:00,gitlab:GitlabProject:1:12345678
-gitlab:GitlabPipeline:1:485932863,gitlab:GitlabProject:1:12345678,SUCCESS,DONE,,398,,2022-03-07T09:34:57.476+00:00,2022-03-07T09:41:36.267+00:00,gitlab:GitlabProject:1:12345678
+gitlab:GitlabPipeline:1:457474837,gitlab:GitlabPipeline:1:457474837,,IN_PROGRESS,,0,,2022-01-27T10:07:09.429+00:00,,gitlab:GitlabProject:1:12345678
+gitlab:GitlabPipeline:1:457474996,gitlab:GitlabPipeline:1:457474996,FAILURE,DONE,,0,,2022-01-27T10:07:18.884+00:00,2022-01-27T10:07:19.043+00:00,gitlab:GitlabProject:1:12345678
+gitlab:GitlabPipeline:1:457475160,gitlab:GitlabPipeline:1:457475160,FAILURE,DONE,,0,,2022-01-27T10:07:26.435+00:00,2022-01-27T10:07:26.638+00:00,gitlab:GitlabProject:1:12345678
+gitlab:GitlabPipeline:1:457475337,gitlab:GitlabPipeline:1:457475337,,IN_PROGRESS,,0,,2022-01-27T10:07:36.502+00:00,,gitlab:GitlabProject:1:12345678
+gitlab:GitlabPipeline:1:485811050,gitlab:GitlabPipeline:1:485811050,FAILURE,DONE,DEPLOYMENT,0,PRODUCTION,2022-03-07T06:26:42.109+00:00,2022-03-07T06:26:42.109+00:00,gitlab:GitlabProject:1:12345678
+gitlab:GitlabPipeline:1:485811059,gitlab:GitlabPipeline:1:485811059,FAILURE,DONE,,0,,2022-03-07T06:26:43.784+00:00,2022-03-07T06:26:43.784+00:00,gitlab:GitlabProject:1:12345678
+gitlab:GitlabPipeline:1:485813816,gitlab:GitlabPipeline:1:485813816,FAILURE,DONE,DEPLOYMENT,0,PRODUCTION,2022-03-07T06:33:56.824+00:00,2022-03-07T06:33:56.824+00:00,gitlab:GitlabProject:1:12345678
+gitlab:GitlabPipeline:1:485813830,gitlab:GitlabPipeline:1:485813830,FAILURE,DONE,,0,,2022-03-07T06:33:58.889+00:00,2022-03-07T06:33:58.889+00:00,gitlab:GitlabProject:1:12345678
+gitlab:GitlabPipeline:1:485814501,gitlab:GitlabPipeline:1:485814501,FAILURE,DONE,DEPLOYMENT,0,PRODUCTION,2022-03-07T06:35:28.111+00:00,2022-03-07T06:35:28.111+00:00,gitlab:GitlabProject:1:12345678
+gitlab:GitlabPipeline:1:485814516,gitlab:GitlabPipeline:1:485814516,FAILURE,DONE,,0,,2022-03-07T06:35:31.255+00:00,2022-03-07T06:35:31.255+00:00,gitlab:GitlabProject:1:12345678
+gitlab:GitlabPipeline:1:485814871,gitlab:GitlabPipeline:1:485814871,FAILURE,DONE,,42,,2022-03-07T06:36:50.020+00:00,2022-03-07T06:37:32.103+00:00,gitlab:GitlabProject:1:12345678
+gitlab:GitlabPipeline:1:485817670,gitlab:GitlabPipeline:1:485817670,FAILURE,DONE,,1956,,2022-03-07T06:45:09.471+00:00,2022-03-07T07:17:46.305+00:00,gitlab:GitlabProject:1:12345678
+gitlab:GitlabPipeline:1:485837602,gitlab:GitlabPipeline:1:485837602,FAILURE,DONE,,434,,2022-03-07T07:20:45.859+00:00,2022-03-07T07:28:00.277+00:00,gitlab:GitlabProject:1:12345678
+gitlab:GitlabPipeline:1:485842553,gitlab:GitlabPipeline:1:485842553,FAILURE,DONE,,287,,2022-03-07T07:30:47.018+00:00,2022-03-07T07:35:34.998+00:00,gitlab:GitlabProject:1:12345678
+gitlab:GitlabPipeline:1:485845850,gitlab:GitlabPipeline:1:485845850,FAILURE,DONE,,419,,2022-03-07T07:38:58.611+00:00,2022-03-07T07:45:58.412+00:00,gitlab:GitlabProject:1:12345678
+gitlab:GitlabPipeline:1:485852752,gitlab:GitlabPipeline:1:485852752,FAILURE,DONE,,319,,2022-03-07T07:46:09.385+00:00,2022-03-07T07:51:28.709+00:00,gitlab:GitlabProject:1:12345678
+gitlab:GitlabPipeline:1:485865876,gitlab:GitlabPipeline:1:485865876,FAILURE,DONE,,480,,2022-03-07T08:04:56.406+00:00,2022-03-07T08:12:56.453+00:00,gitlab:GitlabProject:1:12345678
+gitlab:GitlabPipeline:1:485877118,gitlab:GitlabPipeline:1:485877118,FAILURE,DONE,,289,,2022-03-07T08:22:48.943+00:00,2022-03-07T08:27:38.364+00:00,gitlab:GitlabProject:1:12345678
+gitlab:GitlabPipeline:1:485905167,gitlab:GitlabPipeline:1:485905167,FAILURE,DONE,,687,,2022-03-07T09:02:09.994+00:00,2022-03-07T09:13:37.013+00:00,gitlab:GitlabProject:1:12345678
+gitlab:GitlabPipeline:1:485932863,gitlab:GitlabPipeline:1:485932863,SUCCESS,DONE,,398,,2022-03-07T09:34:57.476+00:00,2022-03-07T09:41:36.267+00:00,gitlab:GitlabProject:1:12345678
diff --git a/backend/plugins/gitlab/tasks/pipeline_convertor.go b/backend/plugins/gitlab/tasks/pipeline_convertor.go
index a2bfddc2b..5c065b1d1 100644
--- a/backend/plugins/gitlab/tasks/pipeline_convertor.go
+++ b/backend/plugins/gitlab/tasks/pipeline_convertor.go
@@ -73,17 +73,18 @@ func ConvertPipelines(taskCtx plugin.SubTaskContext) errors.Error {
Convert: func(inputRow interface{}) ([]interface{}, errors.Error) {
gitlabPipeline := inputRow.(*models.GitlabPipeline)
- createdAt := time.Now()
- if gitlabPipeline.GitlabCreatedAt != nil {
- createdAt = *gitlabPipeline.GitlabCreatedAt
+ startedAt := time.Now()
+ if gitlabPipeline.StartedAt != nil {
+ startedAt = *gitlabPipeline.StartedAt
+ } else if gitlabPipeline.GitlabCreatedAt != nil {
+ startedAt = *gitlabPipeline.GitlabCreatedAt
}
domainPipeline := &devops.CICDPipeline{
DomainEntity: domainlayer.DomainEntity{
Id: pipelineIdGen.Generate(data.Options.ConnectionId, gitlabPipeline.GitlabId),
},
- Name: projectIdGen.
- Generate(data.Options.ConnectionId, data.Options.ProjectId),
+ Name: pipelineIdGen.Generate(data.Options.ConnectionId, gitlabPipeline.GitlabId),
Result: devops.GetResult(&devops.ResultRule{
Failed: []string{"failed"},
Abort: []string{"canceled"},
@@ -95,7 +96,7 @@ func ConvertPipelines(taskCtx plugin.SubTaskContext) errors.Error {
InProgress: []string{"created", "waiting_for_resource", "preparing", "pending", "running", "manual", "scheduled"},
Default: devops.STATUS_DONE,
}, gitlabPipeline.Status),
- CreatedDate: createdAt,
+ CreatedDate: startedAt,
FinishedDate: gitlabPipeline.GitlabUpdatedAt,
CicdScopeId: projectIdGen.Generate(data.Options.ConnectionId, gitlabPipeline.ProjectId),
Environment: gitlabPipeline.Environment,
@@ -107,7 +108,7 @@ func ConvertPipelines(taskCtx plugin.SubTaskContext) errors.Error {
domainPipeline.FinishedDate = nil
domainPipeline.DurationSec = 0
} else if domainPipeline.FinishedDate != nil {
- durationTime := domainPipeline.FinishedDate.Sub(createdAt)
+ durationTime := domainPipeline.FinishedDate.Sub(startedAt)
domainPipeline.DurationSec = uint64(durationTime.Seconds())
}
diff --git a/backend/plugins/tapd/e2e/snapshot_tables/issue_repo_commits_bug.csv b/backend/plugins/tapd/e2e/snapshot_tables/issue_repo_commits_bug.csv
index 6f7ff8c4d..f55e9f76d 100644
--- a/backend/plugins/tapd/e2e/snapshot_tables/issue_repo_commits_bug.csv
+++ b/backend/plugins/tapd/e2e/snapshot_tables/issue_repo_commits_bug.csv
@@ -1,7 +1,7 @@
issue_id,repo_url,commit_sha,host,namespace,repo_name
-tapd:TapdBug:1:1137469667001000002,https://gitlab.com/merico-dev/ee/tapd-test.git,ca5cd69aa0af3fb457d1975e58db2f430eca6d7e,gitlab.com,merico-dev,Tapd Test
-tapd:TapdBug:1:1137469667001000006,https://gitlab.com/merico-dev/ee/tapd-test.git,0d55ae5b75b08ef8f657f95cd15d48ee8fcedc10,gitlab.com,merico-dev,Tapd Test
-tapd:TapdBug:1:1137469667001000006,https://gitlab.com/merico-dev/ee/tapd-test.git,461bc8c6a334c9d443fe6f147897cea1d777cb71,gitlab.com,merico-dev,Tapd Test
-tapd:TapdBug:1:1137469667001000006,https://gitlab.com/merico-dev/ee/tapd-test.git,5c908856f64c9286ec974f9088ea7825d87b8553,gitlab.com,merico-dev,Tapd Test
-tapd:TapdBug:1:1137469667001000006,https://gitlab.com/merico-dev/ee/tapd-test.git,d81557aef2025ec5a43c8d39bb2d9f18b48c9af1,gitlab.com,merico-dev,Tapd Test
-tapd:TapdBug:1:1137469667001009015,https://gitlab.com/merico-dev/ee/tapd-test.git,7649df9ea8c066b61955a47d66aa1983c8834033,gitlab.com,merico-dev,Tapd Test
+tapd:TapdBug:1:1137469667001000002,https://gitlab.com/merico-dev/ee/tapd-test.git,ca5cd69aa0af3fb457d1975e58db2f430eca6d7e,gitlab.com,merico-dev/ee,tapd-test
+tapd:TapdBug:1:1137469667001000006,https://gitlab.com/merico-dev/ee/tapd-test.git,0d55ae5b75b08ef8f657f95cd15d48ee8fcedc10,gitlab.com,merico-dev/ee,tapd-test
+tapd:TapdBug:1:1137469667001000006,https://gitlab.com/merico-dev/ee/tapd-test.git,461bc8c6a334c9d443fe6f147897cea1d777cb71,gitlab.com,merico-dev/ee,tapd-test
+tapd:TapdBug:1:1137469667001000006,https://gitlab.com/merico-dev/ee/tapd-test.git,5c908856f64c9286ec974f9088ea7825d87b8553,gitlab.com,merico-dev/ee,tapd-test
+tapd:TapdBug:1:1137469667001000006,https://gitlab.com/merico-dev/ee/tapd-test.git,d81557aef2025ec5a43c8d39bb2d9f18b48c9af1,gitlab.com,merico-dev/ee,tapd-test
+tapd:TapdBug:1:1137469667001009015,https://gitlab.com/merico-dev/ee/tapd-test.git,7649df9ea8c066b61955a47d66aa1983c8834033,gitlab.com,merico-dev/ee,tapd-test
diff --git a/backend/plugins/tapd/e2e/snapshot_tables/issue_repo_commits_story.csv b/backend/plugins/tapd/e2e/snapshot_tables/issue_repo_commits_story.csv
index 8133fcf65..59d6a0e23 100644
--- a/backend/plugins/tapd/e2e/snapshot_tables/issue_repo_commits_story.csv
+++ b/backend/plugins/tapd/e2e/snapshot_tables/issue_repo_commits_story.csv
@@ -1,7 +1,7 @@
issue_id,repo_url,commit_sha,host,namespace,repo_name
-tapd:TapdStory:1:1137469667001000002,https://gitlab.com/merico-dev/ee/tapd-test.git,ca5cd69aa0af3fb457d1975e58db2f430eca6d7e,gitlab.com,merico-dev,Tapd Test
-tapd:TapdStory:1:1137469667001000006,https://gitlab.com/merico-dev/ee/tapd-test.git,0d55ae5b75b08ef8f657f95cd15d48ee8fcedc10,gitlab.com,merico-dev,Tapd Test
-tapd:TapdStory:1:1137469667001000006,https://gitlab.com/merico-dev/ee/tapd-test.git,461bc8c6a334c9d443fe6f147897cea1d777cb71,gitlab.com,merico-dev,Tapd Test
-tapd:TapdStory:1:1137469667001000006,https://gitlab.com/merico-dev/ee/tapd-test.git,5c908856f64c9286ec974f9088ea7825d87b8553,gitlab.com,merico-dev,Tapd Test
-tapd:TapdStory:1:1137469667001000006,https://gitlab.com/merico-dev/ee/tapd-test.git,d81557aef2025ec5a43c8d39bb2d9f18b48c9af1,gitlab.com,merico-dev,Tapd Test
-tapd:TapdStory:1:1137469667001009015,https://gitlab.com/merico-dev/ee/tapd-test.git,7649df9ea8c066b61955a47d66aa1983c8834033,gitlab.com,merico-dev,Tapd Test
+tapd:TapdStory:1:1137469667001000002,https://gitlab.com/merico-dev/ee/tapd-test.git,ca5cd69aa0af3fb457d1975e58db2f430eca6d7e,gitlab.com,merico-dev/ee,tapd-test
+tapd:TapdStory:1:1137469667001000006,https://gitlab.com/merico-dev/ee/tapd-test.git,0d55ae5b75b08ef8f657f95cd15d48ee8fcedc10,gitlab.com,merico-dev/ee,tapd-test
+tapd:TapdStory:1:1137469667001000006,https://gitlab.com/merico-dev/ee/tapd-test.git,461bc8c6a334c9d443fe6f147897cea1d777cb71,gitlab.com,merico-dev/ee,tapd-test
+tapd:TapdStory:1:1137469667001000006,https://gitlab.com/merico-dev/ee/tapd-test.git,5c908856f64c9286ec974f9088ea7825d87b8553,gitlab.com,merico-dev/ee,tapd-test
+tapd:TapdStory:1:1137469667001000006,https://gitlab.com/merico-dev/ee/tapd-test.git,d81557aef2025ec5a43c8d39bb2d9f18b48c9af1,gitlab.com,merico-dev/ee,tapd-test
+tapd:TapdStory:1:1137469667001009015,https://gitlab.com/merico-dev/ee/tapd-test.git,7649df9ea8c066b61955a47d66aa1983c8834033,gitlab.com,merico-dev/ee,tapd-test
diff --git a/backend/plugins/tapd/e2e/snapshot_tables/issue_repo_commits_task.csv b/backend/plugins/tapd/e2e/snapshot_tables/issue_repo_commits_task.csv
index 17f297b2d..70e376232 100644
--- a/backend/plugins/tapd/e2e/snapshot_tables/issue_repo_commits_task.csv
+++ b/backend/plugins/tapd/e2e/snapshot_tables/issue_repo_commits_task.csv
@@ -1,7 +1,7 @@
issue_id,repo_url,commit_sha,host,namespace,repo_name
-tapd:TapdTask:1:1137469667001000002,https://gitlab.com/merico-dev/ee/tapd-test.git,ca5cd69aa0af3fb457d1975e58db2f430eca6d7e,gitlab.com,merico-dev,Tapd Test
-tapd:TapdTask:1:1137469667001000006,https://gitlab.com/merico-dev/ee/tapd-test.git,0d55ae5b75b08ef8f657f95cd15d48ee8fcedc10,gitlab.com,merico-dev,Tapd Test
-tapd:TapdTask:1:1137469667001000006,https://gitlab.com/merico-dev/ee/tapd-test.git,461bc8c6a334c9d443fe6f147897cea1d777cb71,gitlab.com,merico-dev,Tapd Test
-tapd:TapdTask:1:1137469667001000006,https://gitlab.com/merico-dev/ee/tapd-test.git,5c908856f64c9286ec974f9088ea7825d87b8553,gitlab.com,merico-dev,Tapd Test
-tapd:TapdTask:1:1137469667001000006,https://gitlab.com/merico-dev/ee/tapd-test.git,d81557aef2025ec5a43c8d39bb2d9f18b48c9af1,gitlab.com,merico-dev,Tapd Test
-tapd:TapdTask:1:1137469667001009015,https://gitlab.com/merico-dev/ee/tapd-test.git,7649df9ea8c066b61955a47d66aa1983c8834033,gitlab.com,merico-dev,Tapd Test
+tapd:TapdTask:1:1137469667001000002,https://gitlab.com/merico-dev/ee/tapd-test.git,ca5cd69aa0af3fb457d1975e58db2f430eca6d7e,gitlab.com,merico-dev/ee,tapd-test
+tapd:TapdTask:1:1137469667001000006,https://gitlab.com/merico-dev/ee/tapd-test.git,0d55ae5b75b08ef8f657f95cd15d48ee8fcedc10,gitlab.com,merico-dev/ee,tapd-test
+tapd:TapdTask:1:1137469667001000006,https://gitlab.com/merico-dev/ee/tapd-test.git,461bc8c6a334c9d443fe6f147897cea1d777cb71,gitlab.com,merico-dev/ee,tapd-test
+tapd:TapdTask:1:1137469667001000006,https://gitlab.com/merico-dev/ee/tapd-test.git,5c908856f64c9286ec974f9088ea7825d87b8553,gitlab.com,merico-dev/ee,tapd-test
+tapd:TapdTask:1:1137469667001000006,https://gitlab.com/merico-dev/ee/tapd-test.git,d81557aef2025ec5a43c8d39bb2d9f18b48c9af1,gitlab.com,merico-dev/ee,tapd-test
+tapd:TapdTask:1:1137469667001009015,https://gitlab.com/merico-dev/ee/tapd-test.git,7649df9ea8c066b61955a47d66aa1983c8834033,gitlab.com,merico-dev/ee,tapd-test
diff --git a/backend/plugins/tapd/tasks/bug_commit_converter.go b/backend/plugins/tapd/tasks/bug_commit_converter.go
index 2586bb400..f90c6818f 100644
--- a/backend/plugins/tapd/tasks/bug_commit_converter.go
+++ b/backend/plugins/tapd/tasks/bug_commit_converter.go
@@ -18,6 +18,10 @@ limitations under the License.
package tasks
import (
+ "net/url"
+ "reflect"
+ "strings"
+
"github.com/apache/incubator-devlake/core/dal"
"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/models/domainlayer/crossdomain"
@@ -25,9 +29,6 @@ import (
"github.com/apache/incubator-devlake/core/plugin"
helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
"github.com/apache/incubator-devlake/plugins/tapd/models"
- "net/url"
- "reflect"
- "strings"
)
func ConvertBugCommit(taskCtx plugin.SubTaskContext) errors.Error {
@@ -71,8 +72,8 @@ func ConvertBugCommit(taskCtx plugin.SubTaskContext) errors.Error {
RepoUrl: repoUrl,
CommitSha: toolL.CommitId,
Host: u.Host,
- Namespace: strings.Split(u.Path, `/`)[1],
- RepoName: toolL.HookProjectName,
+ Namespace: getRepoNamespaceFromUrlPath(u.Path),
+ RepoName: getRepoNameFromUrlPath(u.Path),
}
results = append(results, issueRepoCommit)
}
diff --git a/backend/plugins/tapd/tasks/shared.go b/backend/plugins/tapd/tasks/shared.go
index fe05d32a6..25487b9bc 100644
--- a/backend/plugins/tapd/tasks/shared.go
+++ b/backend/plugins/tapd/tasks/shared.go
@@ -356,3 +356,25 @@ func extractStatus(blob []byte) (map[string]string, errors.Error) {
}
return results, nil
}
+
+// getRepoNamespaceFromUrlPath
+// returns the namespace of a repository from the given URL path,
+// which is the url path without the last segment, and without leading and trailing slashes.
+func getRepoNamespaceFromUrlPath(path string) string {
+ // Remove leading and trailing slashes
+ path = strings.Trim(path, "/")
+ // Remove last segment
+ path = path[:strings.LastIndex(path, "/")]
+ return path
+}
+
+// getRepoNameFromUrlPath
+// returns the last segment of url path as repo name, without .git suffix.
+func getRepoNameFromUrlPath(path string) string {
+ // Remove leading and trailing slashes
+ path = strings.Trim(path, "/")
+ // Remove .git suffix
+ path = strings.TrimSuffix(path, ".git")
+ // Get last segment
+ return path[strings.LastIndex(path, "/")+1:]
+}
diff --git a/backend/plugins/tapd/tasks/story_commit_converter.go b/backend/plugins/tapd/tasks/story_commit_converter.go
index c06a201fc..071db0334 100644
--- a/backend/plugins/tapd/tasks/story_commit_converter.go
+++ b/backend/plugins/tapd/tasks/story_commit_converter.go
@@ -18,6 +18,10 @@ limitations under the License.
package tasks
import (
+ "net/url"
+ "reflect"
+ "strings"
+
"github.com/apache/incubator-devlake/core/dal"
"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/models/domainlayer/crossdomain"
@@ -25,9 +29,6 @@ import (
"github.com/apache/incubator-devlake/core/plugin"
helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
"github.com/apache/incubator-devlake/plugins/tapd/models"
- "net/url"
- "reflect"
- "strings"
)
func ConvertStoryCommit(taskCtx plugin.SubTaskContext) errors.Error {
@@ -69,8 +70,8 @@ func ConvertStoryCommit(taskCtx plugin.SubTaskContext) errors.Error {
RepoUrl: repoUrl,
CommitSha: toolL.CommitId,
Host: u.Host,
- Namespace: strings.Split(u.Path, `/`)[1],
- RepoName: toolL.HookProjectName,
+ Namespace: getRepoNamespaceFromUrlPath(u.Path),
+ RepoName: getRepoNameFromUrlPath(u.Path),
}
results = append(results, issueRepoCommit)
}
diff --git a/backend/plugins/tapd/tasks/task_commit_converter.go b/backend/plugins/tapd/tasks/task_commit_converter.go
index bdf93cf42..c4c48e84f 100644
--- a/backend/plugins/tapd/tasks/task_commit_converter.go
+++ b/backend/plugins/tapd/tasks/task_commit_converter.go
@@ -18,6 +18,10 @@ limitations under the License.
package tasks
import (
+ "net/url"
+ "reflect"
+ "strings"
+
"github.com/apache/incubator-devlake/core/dal"
"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/models/domainlayer/crossdomain"
@@ -25,9 +29,6 @@ import (
"github.com/apache/incubator-devlake/core/plugin"
helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
"github.com/apache/incubator-devlake/plugins/tapd/models"
- "net/url"
- "reflect"
- "strings"
)
func ConvertTaskCommit(taskCtx plugin.SubTaskContext) errors.Error {
@@ -72,8 +73,8 @@ func ConvertTaskCommit(taskCtx plugin.SubTaskContext) errors.Error {
RepoUrl: repoUrl,
CommitSha: toolL.CommitId,
Host: u.Host,
- Namespace: strings.Split(u.Path, `/`)[1],
- RepoName: toolL.HookProjectName,
+ Namespace: getRepoNamespaceFromUrlPath(u.Path),
+ RepoName: getRepoNameFromUrlPath(u.Path),
}
results = append(results, issueRepoCommit)
}