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 9fc9b5b42 fix(azuredevops): default empty entities and add CROSS to
repo scope in makeScopeV200 (#8751)
9fc9b5b42 is described below
commit 9fc9b5b423c4b1aaa0c9dda6bc1edc62cdf7ff64
Author: Spiff Azeta <[email protected]>
AuthorDate: Thu Mar 5 15:21:24 2026 +0100
fix(azuredevops): default empty entities and add CROSS to repo scope in
makeScopeV200 (#8751)
When scopeConfig.Entities is empty (common when no entities are
explicitly selected in the UI), makeScopeV200 produced zero scopes,
leaving project_mapping with no rows. Additionally, the repo scope
condition did not check for DOMAIN_TYPE_CROSS, so selecting only
CROSS would not create a repo scope, breaking DORA metrics.
This adds the same fixes applied to GitLab in #8743.
Closes #8749
---
.../plugins/azuredevops_go/api/blueprint_v200.go | 8 ++-
.../azuredevops_go/api/blueprint_v200_test.go | 58 ++++++++++++++++++++++
2 files changed, 65 insertions(+), 1 deletion(-)
diff --git a/backend/plugins/azuredevops_go/api/blueprint_v200.go
b/backend/plugins/azuredevops_go/api/blueprint_v200.go
index 59a587b78..018d9d1d7 100644
--- a/backend/plugins/azuredevops_go/api/blueprint_v200.go
+++ b/backend/plugins/azuredevops_go/api/blueprint_v200.go
@@ -77,8 +77,14 @@ func makeScopeV200(
}
id :=
didgen.NewDomainIdGenerator(&models.AzuredevopsRepo{}).Generate(connectionId,
azuredevopsRepo.Id)
+ // if no entities specified, use all entities enabled by default
+ if len(scopeConfig.Entities) == 0 {
+ scopeConfig.Entities = plugin.DOMAIN_TYPES
+ }
+
if utils.StringsContains(scopeConfig.Entities,
plugin.DOMAIN_TYPE_CODE_REVIEW) ||
- utils.StringsContains(scopeConfig.Entities,
plugin.DOMAIN_TYPE_CODE) {
+ utils.StringsContains(scopeConfig.Entities,
plugin.DOMAIN_TYPE_CODE) ||
+ utils.StringsContains(scopeConfig.Entities,
plugin.DOMAIN_TYPE_CROSS) {
// if we don't need to collect gitex, we need to add
repo to scopes here
scopeRepo := code.NewRepo(id, azuredevopsRepo.Name)
sc = append(sc, scopeRepo)
diff --git a/backend/plugins/azuredevops_go/api/blueprint_v200_test.go
b/backend/plugins/azuredevops_go/api/blueprint_v200_test.go
index ceddcda68..fd40353f7 100644
--- a/backend/plugins/azuredevops_go/api/blueprint_v200_test.go
+++ b/backend/plugins/azuredevops_go/api/blueprint_v200_test.go
@@ -78,6 +78,64 @@ func TestMakeScopes(t *testing.T) {
assert.Equal(t, actualScopes[2].ScopeId(), expectDomainScopeId)
}
+func TestMakeScopesWithEmptyEntities(t *testing.T) {
+ mockAzuredevopsPlugin(t)
+
+ actualScopes, err := makeScopeV200(
+ connectionID,
+ []*srvhelper.ScopeDetail[models.AzuredevopsRepo,
models.AzuredevopsScopeConfig]{
+ {
+ Scope: models.AzuredevopsRepo{
+ Scope: common.Scope{
+ ConnectionId: connectionID,
+ },
+ Id: azuredevopsRepoId,
+ Type: models.RepositoryTypeADO,
+ },
+ ScopeConfig: &models.AzuredevopsScopeConfig{
+ ScopeConfig: common.ScopeConfig{
+ Entities: []string{},
+ },
+ },
+ },
+ },
+ )
+ assert.Nil(t, err)
+ // empty entities should default to all domain types, producing repo +
cicd + board scopes
+ assert.Equal(t, 3, len(actualScopes))
+ assert.Equal(t, actualScopes[0].ScopeId(), expectDomainScopeId)
+}
+
+func TestMakeScopesWithCrossEntity(t *testing.T) {
+ mockAzuredevopsPlugin(t)
+
+ actualScopes, err := makeScopeV200(
+ connectionID,
+ []*srvhelper.ScopeDetail[models.AzuredevopsRepo,
models.AzuredevopsScopeConfig]{
+ {
+ Scope: models.AzuredevopsRepo{
+ Scope: common.Scope{
+ ConnectionId: connectionID,
+ },
+ Id: azuredevopsRepoId,
+ Type: models.RepositoryTypeADO,
+ },
+ ScopeConfig: &models.AzuredevopsScopeConfig{
+ ScopeConfig: common.ScopeConfig{
+ Entities:
[]string{plugin.DOMAIN_TYPE_CROSS, plugin.DOMAIN_TYPE_TICKET},
+ },
+ },
+ },
+ },
+ )
+ assert.Nil(t, err)
+ // CROSS entity should trigger repo scope creation, plus ticket = board
scope
+ assert.Equal(t, 2, len(actualScopes))
+ assert.Equal(t, actualScopes[0].ScopeId(), expectDomainScopeId)
+ assert.Equal(t, "repos", actualScopes[0].TableName())
+ assert.Equal(t, "boards", actualScopes[1].TableName())
+}
+
func TestMakeDataSourcePipelinePlanV200(t *testing.T) {
mockAzuredevopsPlugin(t)