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 840c72890 feat(linker): link when branch names contain issue keys
(#8777)
840c72890 is described below
commit 840c728902b248bc656f7dd013b3fc732c9d4b35
Author: Reece Ward <[email protected]>
AuthorDate: Thu Mar 19 13:05:00 2026 +0000
feat(linker): link when branch names contain issue keys (#8777)
* feat(linker): branch names containing issue keys
* chore: add testing data
---
backend/plugins/linker/e2e/snapshot_tables/board_issues.csv | 1 +
backend/plugins/linker/e2e/snapshot_tables/pull_request_issues.csv | 1 +
backend/plugins/linker/e2e/snapshot_tables/pull_requests.csv | 3 ++-
backend/plugins/linker/tasks/link_pr_and_issue.go | 5 +++--
4 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/backend/plugins/linker/e2e/snapshot_tables/board_issues.csv
b/backend/plugins/linker/e2e/snapshot_tables/board_issues.csv
index 8c288bf48..0955b9ccd 100644
--- a/backend/plugins/linker/e2e/snapshot_tables/board_issues.csv
+++ b/backend/plugins/linker/e2e/snapshot_tables/board_issues.csv
@@ -1,3 +1,4 @@
"board_id","issue_id","created_at","updated_at","_raw_data_params","_raw_data_table","_raw_data_id","_raw_data_remark"
"github:GithubRepo:1:384111310","github:GithubIssue:1:1237324696","2024-05-14
10:42:37.541","2024-05-28
00:25:41.436","{""ConnectionId"":1,""Name"":""apache/incubator-devlake""}","_raw_github_graphql_issues",69,""
"github:GithubRepo:1:384111310","github:GithubIssue:1:1237324697","2024-05-14
10:42:37.541","2024-05-28
00:25:41.436","{""ConnectionId"":1,""Name"":""apache/incubator-devlake""}","_raw_github_graphql_issues",69,""
+"github:GithubRepo:1:384111310","github:GithubIssue:1:1237324698","2024-05-14
10:42:37.541","2024-05-28
00:25:41.436","{""ConnectionId"":1,""Name"":""apache/incubator-devlake""}","_raw_github_graphql_issues",69,""
diff --git a/backend/plugins/linker/e2e/snapshot_tables/pull_request_issues.csv
b/backend/plugins/linker/e2e/snapshot_tables/pull_request_issues.csv
index 6b7d30fb8..d602f600d 100644
--- a/backend/plugins/linker/e2e/snapshot_tables/pull_request_issues.csv
+++ b/backend/plugins/linker/e2e/snapshot_tables/pull_request_issues.csv
@@ -1,3 +1,4 @@
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:1819250573,github:GithubIssue:1:1237324696,7317,1884,,,0,"pull_requests,"
github:GithubPullRequest:1:1819250573,github:GithubIssue:1:1237324697,7317,1885,,,0,"pull_requests,"
+github:GithubPullRequest:1:1819250574,github:GithubIssue:1:1237324698,7318,1886,,,0,"pull_requests,"
diff --git a/backend/plugins/linker/e2e/snapshot_tables/pull_requests.csv
b/backend/plugins/linker/e2e/snapshot_tables/pull_requests.csv
index 22635f9b0..3084711b0 100644
--- a/backend/plugins/linker/e2e/snapshot_tables/pull_requests.csv
+++ b/backend/plugins/linker/e2e/snapshot_tables/pull_requests.csv
@@ -1,2 +1,3 @@
"id","created_at","updated_at","_raw_data_params","_raw_data_table","_raw_data_id","_raw_data_remark","base_repo_id","base_ref","base_commit_sha","head_repo_id","head_ref","head_commit_sha","merge_commit_sha","status","original_status","type","component","title","description","url","author_name","author_id","parent_pr_id","pull_request_key","created_date","merged_date","closed_date"
-"github:GithubPullRequest:1:1819250573","2024-05-15 12:07:36.778","2024-05-15
12:07:36.778","{""ConnectionId"":1,""Name"":""apache/incubator-devlake""}","_raw_github_api_pull_requests",191,"","github:GithubRepo:1:384111310","main","64c52748f3529784cb6c8a372691aa0f638fa73d","github:GithubRepo:1:384111310","fix#7275","14fb6488f2208e6a65374a86efce12dd460987e0","91dbce48759da14a4a030124c3ef751f1c5d8389","CLOSED","closed","","","fix:
can't GET projects which have / in their name #1884 #1885", [...]
\ No newline at end of file
+"github:GithubPullRequest:1:1819250573","2024-05-15 12:07:36.778","2024-05-15
12:07:36.778","{""ConnectionId"":1,""Name"":""apache/incubator-devlake""}","_raw_github_api_pull_requests",191,"","github:GithubRepo:1:384111310","main","64c52748f3529784cb6c8a372691aa0f638fa73d","github:GithubRepo:1:384111310","fix#7275","14fb6488f2208e6a65374a86efce12dd460987e0","91dbce48759da14a4a030124c3ef751f1c5d8389","CLOSED","closed","","","fix:
can't GET projects which have / in their name #1884 #1885", [...]
+"github:GithubPullRequest:1:1819250574","2024-05-15 12:07:36.778","2024-05-15
12:07:36.778","{""ConnectionId"":1,""Name"":""apache/incubator-devlake""}","_raw_github_api_pull_requests",192,"","github:GithubRepo:1:384111310","main","64c52748f3529784cb6c8a372691aa0f638fa73d","github:GithubRepo:1:384111310","fix#1886","14fb6488f2208e6a65374a86efce12dd460987e0","","MERGED","merged","","","Fix
deployment policy recreation","no issue key
here","https://github.com/apache/incubator-devlake/pull/ [...]
diff --git a/backend/plugins/linker/tasks/link_pr_and_issue.go
b/backend/plugins/linker/tasks/link_pr_and_issue.go
index 7fcd3baa5..52fb7aa86 100644
--- a/backend/plugins/linker/tasks/link_pr_and_issue.go
+++ b/backend/plugins/linker/tasks/link_pr_and_issue.go
@@ -18,10 +18,11 @@ limitations under the License.
package tasks
import (
+ "strings"
+
"github.com/apache/incubator-devlake/core/models/domainlayer/code"
"github.com/apache/incubator-devlake/core/models/domainlayer/crossdomain"
"github.com/apache/incubator-devlake/core/models/domainlayer/ticket"
- "strings"
"github.com/apache/incubator-devlake/core/dal"
"github.com/apache/incubator-devlake/core/errors"
@@ -97,7 +98,7 @@ func LinkPrToIssue(taskCtx plugin.SubTaskContext)
errors.Error {
Enrich: func(pullRequest *code.PullRequest) ([]interface{},
errors.Error) {
var issueKeys []string
- for _, text := range []string{pullRequest.Title,
pullRequest.Description} {
+ for _, text := range []string{pullRequest.Title,
pullRequest.Description, pullRequest.HeadRef} {
foundIssueKeys :=
data.PrToIssueRegexp.FindAllString(text, -1)
if len(foundIssueKeys) > 0 {
for _, issueKey := range foundIssueKeys
{