You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by zh...@apache.org on 2023/02/06 06:29:32 UTC

[incubator-devlake] branch release-v0.15 updated: fix: fix jira issue url (#4328) (#4330)

This is an automated email from the ASF dual-hosted git repository.

zhangliang2022 pushed a commit to branch release-v0.15
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/release-v0.15 by this push:
     new c4ab5c36b fix: fix jira issue url (#4328) (#4330)
c4ab5c36b is described below

commit c4ab5c36b9c030e857193f33fbaf2ddf5c425333
Author: mindlesscloud <li...@merico.dev>
AuthorDate: Mon Feb 6 14:29:28 2023 +0800

    fix: fix jira issue url (#4328) (#4330)
---
 plugins/jira/tasks/issue_convertor.go      |  9 +++++----
 plugins/jira/tasks/issue_convertor_test.go | 10 ++++++++++
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/plugins/jira/tasks/issue_convertor.go b/plugins/jira/tasks/issue_convertor.go
index 21590c488..dad747a88 100644
--- a/plugins/jira/tasks/issue_convertor.go
+++ b/plugins/jira/tasks/issue_convertor.go
@@ -18,17 +18,17 @@ limitations under the License.
 package tasks
 
 import (
-	"github.com/apache/incubator-devlake/errors"
 	"net/url"
 	"path/filepath"
 	"reflect"
+	"strings"
 
-	"github.com/apache/incubator-devlake/plugins/core/dal"
-
+	"github.com/apache/incubator-devlake/errors"
 	"github.com/apache/incubator-devlake/models/domainlayer"
 	"github.com/apache/incubator-devlake/models/domainlayer/didgen"
 	"github.com/apache/incubator-devlake/models/domainlayer/ticket"
 	"github.com/apache/incubator-devlake/plugins/core"
+	"github.com/apache/incubator-devlake/plugins/core/dal"
 	"github.com/apache/incubator-devlake/plugins/helper"
 	jiraModels "github.com/apache/incubator-devlake/plugins/jira/models"
 )
@@ -143,6 +143,7 @@ func convertURL(api, issueKey string) string {
 	if err != nil {
 		return api
 	}
-	u.Path = filepath.Join("/browse", issueKey)
+	before, _, _ := strings.Cut(u.Path, "/rest/agile/1.0/issue")
+	u.Path = filepath.Join(before, "browse", issueKey)
 	return u.String()
 }
diff --git a/plugins/jira/tasks/issue_convertor_test.go b/plugins/jira/tasks/issue_convertor_test.go
index 88f4b531d..674a7591a 100644
--- a/plugins/jira/tasks/issue_convertor_test.go
+++ b/plugins/jira/tasks/issue_convertor_test.go
@@ -39,6 +39,16 @@ func Test_convertURL(t *testing.T) {
 			args{"http://8.142.68.162:8080/rest/agile/1.0/issue/10003", "TEST-4"},
 			"http://8.142.68.162:8080/browse/TEST-4",
 		},
+		{
+			"",
+			args{"http://8.142.68.162:8080/prefix/rest/agile/1.0/issue/10003", "TEST-4"},
+			"http://8.142.68.162:8080/prefix/browse/TEST-4",
+		},
+		{
+			"",
+			args{"http://8.142.68.162:8080/prefix1/prefix2/rest/agile/1.0/issue/10003", "TEST-4"},
+			"http://8.142.68.162:8080/prefix1/prefix2/browse/TEST-4",
+		},
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {