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/devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new a582f3140 fix(linker): match issue keys case-insensitively in 
LinkPrToIssue (#9336)
a582f3140 is described below

commit a582f3140c5cf5a94f26c10f67d641138ac2a995
Author: Victor Colomb <[email protected]>
AuthorDate: Sun Nov 8 15:25:21 2026 +0100

    fix(linker): match issue keys case-insensitively in LinkPrToIssue (#9336)
---
 .../plugins/linker/e2e/link_pr_and_issue_test.go   | 40 ++++++++++++++++++++++
 .../e2e/snapshot_tables/case_board_issues.csv      |  3 ++
 .../linker/e2e/snapshot_tables/case_issues.csv     |  3 ++
 .../e2e/snapshot_tables/case_project_mapping.csv   |  3 ++
 .../snapshot_tables/case_pull_request_issues.csv   |  3 ++
 .../e2e/snapshot_tables/case_pull_requests.csv     |  4 +++
 backend/plugins/linker/tasks/link_pr_and_issue.go  |  4 +--
 7 files changed, 58 insertions(+), 2 deletions(-)

diff --git a/backend/plugins/linker/e2e/link_pr_and_issue_test.go 
b/backend/plugins/linker/e2e/link_pr_and_issue_test.go
index 97e70f8a9..2950c2d49 100644
--- a/backend/plugins/linker/e2e/link_pr_and_issue_test.go
+++ b/backend/plugins/linker/e2e/link_pr_and_issue_test.go
@@ -71,6 +71,46 @@ func TestLinkPrToIssueWithSharedRepo(t *testing.T) {
        )
 }
 
+func TestLinkPrToIssueCaseInsensitive(t *testing.T) {
+       var plugin impl.Linker
+       dataflowTester := e2ehelper.NewDataFlowTester(t, "linker", plugin)
+
+       regexpStr := `(?i)\b(PROJ)-\d+\b`
+       taskData := &tasks.LinkerTaskData{
+               Options: &tasks.LinkerOptions{
+                       PrToIssueRegexp: regexpStr,
+                       ProjectName:     "GitHub1",
+               },
+               PrToIssueRegexp: regexp.MustCompile(regexpStr),
+       }
+
+       dataflowTester.FlushTabler(&ticket.Issue{})
+       dataflowTester.FlushTabler(&code.PullRequest{})
+       dataflowTester.FlushTabler(&crossdomain.ProjectMapping{})
+       dataflowTester.FlushTabler(&ticket.BoardIssue{})
+       dataflowTester.ImportCsvIntoTabler("./snapshot_tables/case_issues.csv", 
&ticket.Issue{})
+       
dataflowTester.ImportCsvIntoTabler("./snapshot_tables/case_pull_requests.csv", 
&code.PullRequest{})
+       
dataflowTester.ImportCsvIntoTabler("./snapshot_tables/case_project_mapping.csv",
 &crossdomain.ProjectMapping{})
+       
dataflowTester.ImportCsvIntoTabler("./snapshot_tables/case_board_issues.csv", 
&ticket.BoardIssue{})
+
+       dataflowTester.FlushTabler(&crossdomain.PullRequestIssue{})
+       dataflowTester.Subtask(tasks.LinkPrToIssueMeta, taskData)
+       dataflowTester.VerifyTable(
+               crossdomain.PullRequestIssue{},
+               "./snapshot_tables/case_pull_request_issues.csv",
+               []string{
+                       "pull_request_id",
+                       "pull_request_key",
+                       "issue_id",
+                       "issue_key",
+                       "_raw_data_params",
+                       "_raw_data_table",
+                       "_raw_data_id",
+                       "_raw_data_remark",
+               },
+       )
+}
+
 func TestLinkPrToIssue(t *testing.T) {
        var plugin impl.Linker
        dataflowTester := e2ehelper.NewDataFlowTester(t, "linker", plugin)
diff --git a/backend/plugins/linker/e2e/snapshot_tables/case_board_issues.csv 
b/backend/plugins/linker/e2e/snapshot_tables/case_board_issues.csv
new file mode 100644
index 000000000..6477b4ec2
--- /dev/null
+++ b/backend/plugins/linker/e2e/snapshot_tables/case_board_issues.csv
@@ -0,0 +1,3 @@
+"board_id","issue_id","created_at","updated_at","_raw_data_params","_raw_data_table","_raw_data_id","_raw_data_remark"
+"jira:JiraBoard:1:1","jira:JiraIssue:1:123","2024-05-14 
10:42:37.541","2024-05-28 00:25:41.436","","",0,""
+"jira:JiraBoard:1:1","jira:JiraIssue:1:456","2024-05-14 
10:42:37.541","2024-05-28 00:25:41.436","","",0,""
diff --git a/backend/plugins/linker/e2e/snapshot_tables/case_issues.csv 
b/backend/plugins/linker/e2e/snapshot_tables/case_issues.csv
new file mode 100644
index 000000000..b6197c071
--- /dev/null
+++ b/backend/plugins/linker/e2e/snapshot_tables/case_issues.csv
@@ -0,0 +1,3 @@
+"id","created_at","updated_at","_raw_data_params","_raw_data_table","_raw_data_id","_raw_data_remark","issue_key","title"
+"jira:JiraIssue:1:123","2024-05-14 10:42:37.529","2024-05-15 
12:07:36.450","","",0,"","PROJ-123","Upper key"
+"jira:JiraIssue:1:456","2024-05-14 10:42:37.529","2024-05-15 
12:07:36.450","","",0,"","proj-456","Lower key"
diff --git 
a/backend/plugins/linker/e2e/snapshot_tables/case_project_mapping.csv 
b/backend/plugins/linker/e2e/snapshot_tables/case_project_mapping.csv
new file mode 100644
index 000000000..b970fb55c
--- /dev/null
+++ b/backend/plugins/linker/e2e/snapshot_tables/case_project_mapping.csv
@@ -0,0 +1,3 @@
+"project_name","table","row_id","created_at","updated_at","_raw_data_params","_raw_data_table","_raw_data_id","_raw_data_remark"
+"GitHub1","repos","github:GithubRepo:1:1","2024-05-15 
12:02:13.590","2024-05-15 12:02:13.590","GitHub1","",0,""
+"GitHub1","boards","jira:JiraBoard:1:1","2024-05-15 12:02:13.590","2024-05-15 
12:02:13.590","GitHub1","",0,""
diff --git 
a/backend/plugins/linker/e2e/snapshot_tables/case_pull_request_issues.csv 
b/backend/plugins/linker/e2e/snapshot_tables/case_pull_request_issues.csv
new file mode 100644
index 000000000..34c2b4365
--- /dev/null
+++ b/backend/plugins/linker/e2e/snapshot_tables/case_pull_request_issues.csv
@@ -0,0 +1,3 @@
+pull_request_id,issue_id,pull_request_key,issue_key,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark
+github:GithubPullRequest:1:1,jira:JiraIssue:1:123,1,PROJ-123,,,0,"pull_requests,"
+github:GithubPullRequest:1:2,jira:JiraIssue:1:456,2,proj-456,,,0,"pull_requests,"
diff --git a/backend/plugins/linker/e2e/snapshot_tables/case_pull_requests.csv 
b/backend/plugins/linker/e2e/snapshot_tables/case_pull_requests.csv
new file mode 100644
index 000000000..ea2720d42
--- /dev/null
+++ b/backend/plugins/linker/e2e/snapshot_tables/case_pull_requests.csv
@@ -0,0 +1,4 @@
+"id","created_at","updated_at","_raw_data_params","_raw_data_table","_raw_data_id","_raw_data_remark","base_repo_id","head_ref","title","description","pull_request_key"
+"github:GithubPullRequest:1:1","2024-05-15 12:07:36.778","2024-05-15 
12:07:36.778","","",0,"","github:GithubRepo:1:1","user/proj-123-short-title","","",1
+"github:GithubPullRequest:1:2","2024-05-15 12:07:36.778","2024-05-15 
12:07:36.778","","",0,"","github:GithubRepo:1:1","feature","Fix Proj-456","",2
+"github:GithubPullRequest:1:3","2024-05-15 12:07:36.778","2024-05-15 
12:07:36.778","","",0,"","github:GithubRepo:1:1","other","No key here","",3
diff --git a/backend/plugins/linker/tasks/link_pr_and_issue.go 
b/backend/plugins/linker/tasks/link_pr_and_issue.go
index 76ad312ec..d8af45204 100644
--- a/backend/plugins/linker/tasks/link_pr_and_issue.go
+++ b/backend/plugins/linker/tasks/link_pr_and_issue.go
@@ -43,7 +43,7 @@ var LinkPrToIssueMeta = plugin.SubTaskMeta{
 func normalizeIssueKey(issueKey string) string {
        issueKey = strings.ReplaceAll(issueKey, "#", "")
        issueKey = strings.TrimSpace(issueKey)
-       return issueKey
+       return strings.ToUpper(issueKey)
 }
 
 func clearHistoryData(db dal.Dal, data *LinkerTaskData) errors.Error {
@@ -122,7 +122,7 @@ func LinkPrToIssue(taskCtx plugin.SubTaskContext) 
errors.Error {
 
                        var clauses = []dal.Clause{
                                dal.From(&ticket.Issue{}),
-                               dal.Where("issues.id in ? AND issues.issue_key 
in ?", projectIssueIds, issueKeys),
+                               dal.Where("issues.id in ? AND 
UPPER(issues.issue_key) in ?", projectIssueIds, issueKeys),
                        }
 
                        if err := db.All(&issues, clauses...); err != nil {

Reply via email to