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 0cd881f1e fix(bamboo): keep plan name same in both 
/search-remote-scopes and /remote-scopes (#6284)
0cd881f1e is described below

commit 0cd881f1e0e0ccc5d4f66cf661654d75b543e06f
Author: Lynwee <[email protected]>
AuthorDate: Thu Oct 19 15:25:03 2023 +0800

    fix(bamboo): keep plan name same in both /search-remote-scopes and 
/remote-scopes (#6284)
---
 backend/plugins/bamboo/api/remote.go  | 5 ++---
 backend/plugins/bamboo/models/plan.go | 7 +++++++
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/backend/plugins/bamboo/api/remote.go 
b/backend/plugins/bamboo/api/remote.go
index c3ab38dd6..e9782ae66 100644
--- a/backend/plugins/bamboo/api/remote.go
+++ b/backend/plugins/bamboo/api/remote.go
@@ -20,13 +20,12 @@ package api
 import (
        gocontext "context"
        "fmt"
-       "net/url"
-
        "github.com/apache/incubator-devlake/core/context"
        "github.com/apache/incubator-devlake/core/errors"
        "github.com/apache/incubator-devlake/core/plugin"
        "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
        "github.com/apache/incubator-devlake/plugins/bamboo/models"
+       "net/url"
 )
 
 // RemoteScopes list all available scope for users
@@ -87,7 +86,7 @@ func SearchRemoteScopes(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutp
                        for _, apiResult := range resBody.SearchResults {
                                bambooPlan := models.ApiBambooPlan{
                                        Key:  apiResult.SearchEntity.Key,
-                                       Name: apiResult.SearchEntity.PlanName,
+                                       Name: apiResult.SearchEntity.Name(),
                                }
                                apiBambooPlans = append(apiBambooPlans, 
bambooPlan)
                        }
diff --git a/backend/plugins/bamboo/models/plan.go 
b/backend/plugins/bamboo/models/plan.go
index a3653279f..26d0d3c1e 100644
--- a/backend/plugins/bamboo/models/plan.go
+++ b/backend/plugins/bamboo/models/plan.go
@@ -20,6 +20,7 @@ package models
 import (
        "github.com/apache/incubator-devlake/core/models/common"
        "github.com/apache/incubator-devlake/core/plugin"
+       "strings"
 )
 
 var _ plugin.ToolLayerScope = (*BambooPlan)(nil)
@@ -108,6 +109,12 @@ type SearchEntity struct {
        Type        string `json:"type"`
 }
 
+// Name trys to keep plan's name field the same with name in /remote-scopes.
+// In /remote-scopes, plan's name is "{projectName - planName}".
+func (entity SearchEntity) Name() string {
+       return strings.Join([]string{entity.ProjectName, entity.PlanName}, " - 
")
+}
+
 type ApiSearchResult struct {
        Id           string       `json:"id"`
        Type         string       `json:"type"`

Reply via email to