This is an automated email from the ASF dual-hosted git repository.
zhangliang2022 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 754135dee fix: gitlab/bitbucket generate the complete repo name path
when creat… (#5463)
754135dee is described below
commit 754135dee02b6b9992da91e17a9de748e00415ba
Author: abeizn <[email protected]>
AuthorDate: Tue Jun 13 17:20:52 2023 +0800
fix: gitlab/bitbucket generate the complete repo name path when creat…
(#5463)
* fix: gitlab/bitbucket generate the complete repo name path when creating
blueprint
* fix: unit test
* fix: unit test
---
.../plugins/bitbucket/api/blueprint_V200_test.go | 4 ++--
backend/plugins/bitbucket/api/blueprint_v200.go | 6 +++---
backend/plugins/gitlab/api/blueprint_V200_test.go | 21 +++++++++++----------
backend/plugins/gitlab/api/blueprint_v200.go | 8 +++-----
4 files changed, 19 insertions(+), 20 deletions(-)
diff --git a/backend/plugins/bitbucket/api/blueprint_V200_test.go
b/backend/plugins/bitbucket/api/blueprint_V200_test.go
index f1473da4d..d2d546e98 100644
--- a/backend/plugins/bitbucket/api/blueprint_V200_test.go
+++ b/backend/plugins/bitbucket/api/blueprint_V200_test.go
@@ -111,14 +111,14 @@ func TestMakeDataSourcePipelinePlanV200(t *testing.T) {
DomainEntity: domainlayer.DomainEntity{
Id: "bitbucket:BitbucketRepo:1:likyh/likyhphp",
},
- Name: "test/testRepo",
+ Name: "likyh/likyhphp",
}
scopeTicket := &ticket.Board{
DomainEntity: domainlayer.DomainEntity{
Id: "bitbucket:BitbucketRepo:1:likyh/likyhphp",
},
- Name: "test/testRepo",
+ Name: "likyh/likyhphp",
Description: "",
Url: "",
CreatedDate: nil,
diff --git a/backend/plugins/bitbucket/api/blueprint_v200.go
b/backend/plugins/bitbucket/api/blueprint_v200.go
index add31560c..d9e6ca54d 100644
--- a/backend/plugins/bitbucket/api/blueprint_v200.go
+++ b/backend/plugins/bitbucket/api/blueprint_v200.go
@@ -154,7 +154,7 @@ func makeScopesV200(bpScopes []*plugin.BlueprintScopeV200,
connection *models.Bi
DomainEntity: domainlayer.DomainEntity{
Id:
didgen.NewDomainIdGenerator(&models.BitbucketRepo{}).Generate(connection.ID,
repo.BitbucketId),
},
- Name: repo.Name,
+ Name: repo.BitbucketId,
}
scopes = append(scopes, scopeRepo)
}
@@ -164,7 +164,7 @@ func makeScopesV200(bpScopes []*plugin.BlueprintScopeV200,
connection *models.Bi
DomainEntity: domainlayer.DomainEntity{
Id:
didgen.NewDomainIdGenerator(&models.BitbucketRepo{}).Generate(connection.ID,
repo.BitbucketId),
},
- Name: repo.Name,
+ Name: repo.BitbucketId,
}
scopes = append(scopes, scopeCICD)
}
@@ -174,7 +174,7 @@ func makeScopesV200(bpScopes []*plugin.BlueprintScopeV200,
connection *models.Bi
DomainEntity: domainlayer.DomainEntity{
Id:
didgen.NewDomainIdGenerator(&models.BitbucketRepo{}).Generate(connection.ID,
repo.BitbucketId),
},
- Name: repo.Name,
+ Name: repo.BitbucketId,
}
scopes = append(scopes, scopeTicket)
}
diff --git a/backend/plugins/gitlab/api/blueprint_V200_test.go
b/backend/plugins/gitlab/api/blueprint_V200_test.go
index 7e3b13d1e..7a026f6a6 100644
--- a/backend/plugins/gitlab/api/blueprint_V200_test.go
+++ b/backend/plugins/gitlab/api/blueprint_V200_test.go
@@ -47,6 +47,7 @@ func TestMakeDataSourcePipelinePlanV200(t *testing.T) {
const testHttpUrlToRepo string = "https://this_is_cloneUrl"
const testToken string = "nddtf"
const testName string = "gitlab-test"
+ const pathWithNamespace string = "nddtf/gitlab-test"
const testScopeConfigName string = "gitlab scope config"
const testProxy string = ""
@@ -59,13 +60,13 @@ func TestMakeDataSourcePipelinePlanV200(t *testing.T) {
}
var testGitlabProject = &models.GitlabProject{
- ConnectionId: testConnectionID,
- GitlabId: testID,
- Name: testName,
-
- ScopeConfigId: testScopeConfigId,
- CreatedDate: &time.Time{},
- HttpUrlToRepo: testHttpUrlToRepo,
+ ConnectionId: testConnectionID,
+ GitlabId: testID,
+ Name: testName,
+ PathWithNamespace: pathWithNamespace,
+ ScopeConfigId: testScopeConfigId,
+ CreatedDate: &time.Time{},
+ HttpUrlToRepo: testHttpUrlToRepo,
}
var testScopeConfig = &models.GitlabScopeConfig{
@@ -160,14 +161,14 @@ func TestMakeDataSourcePipelinePlanV200(t *testing.T) {
},
}
- expectRepo := code.NewRepo(expectRepoId, testName)
+ expectRepo := code.NewRepo(expectRepoId, pathWithNamespace)
expectRepo.ForkedFrom = testGitlabProject.ForkedFromProjectWebUrl
- expectCicdScope := devops.NewCicdScope(expectRepoId, testName)
+ expectCicdScope := devops.NewCicdScope(expectRepoId, pathWithNamespace)
expectCicdScope.Description = ""
expectCicdScope.Url = ""
- expectBoard := ticket.NewBoard(expectRepoId, testName)
+ expectBoard := ticket.NewBoard(expectRepoId, pathWithNamespace)
expectBoard.Description = ""
expectBoard.Url = ""
expectBoard.Type = ""
diff --git a/backend/plugins/gitlab/api/blueprint_v200.go
b/backend/plugins/gitlab/api/blueprint_v200.go
index c5f96934f..c7339689a 100644
--- a/backend/plugins/gitlab/api/blueprint_v200.go
+++ b/backend/plugins/gitlab/api/blueprint_v200.go
@@ -86,7 +86,7 @@ func makeScopeV200(connectionId uint64, scopes
[]*plugin.BlueprintScopeV200) ([]
if utils.StringsContains(scopeConfig.Entities,
plugin.DOMAIN_TYPE_CODE_REVIEW) ||
utils.StringsContains(scopeConfig.Entities,
plugin.DOMAIN_TYPE_CODE) {
// if we don't need to collect gitex, we need to add
repo to scopes here
- scopeRepo := code.NewRepo(id, gitlabProject.Name)
+ scopeRepo := code.NewRepo(id,
gitlabProject.PathWithNamespace)
if gitlabProject.ForkedFromProjectWebUrl != "" {
scopeRepo.ForkedFrom =
gitlabProject.ForkedFromProjectWebUrl
@@ -96,15 +96,13 @@ func makeScopeV200(connectionId uint64, scopes
[]*plugin.BlueprintScopeV200) ([]
// add cicd_scope to scopes
if utils.StringsContains(scopeConfig.Entities,
plugin.DOMAIN_TYPE_CICD) {
- scopeCICD := devops.NewCicdScope(id, gitlabProject.Name)
-
+ scopeCICD := devops.NewCicdScope(id,
gitlabProject.PathWithNamespace)
sc = append(sc, scopeCICD)
}
// add board to scopes
if utils.StringsContains(scopeConfig.Entities,
plugin.DOMAIN_TYPE_TICKET) {
- scopeTicket := ticket.NewBoard(id, gitlabProject.Name)
-
+ scopeTicket := ticket.NewBoard(id,
gitlabProject.PathWithNamespace)
sc = append(sc, scopeTicket)
}
}