This is an automated email from the ASF dual-hosted git repository.
abeizn pushed a commit to branch release-v0.20
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/release-v0.20 by this push:
new 8eec57808 fix: type trans rules (#6679) (#6683)
8eec57808 is described below
commit 8eec5780855736575ba978328718e56e5b3a4475
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Dec 21 15:10:31 2023 +0800
fix: type trans rules (#6679) (#6683)
* fix: type trans rules
* fix: github issue e2e
Co-authored-by: abeizn <[email protected]>
---
backend/plugins/gitee/tasks/issue_extractor.go | 45 +++++------------
backend/plugins/gitee/tasks/pr_extractor.go | 15 ++----
.../e2e/snapshot_tables/_tool_github_issues.csv | 18 +++----
backend/plugins/github/tasks/issue_extractor.go | 25 ++++------
backend/plugins/github/tasks/pr_extractor.go | 15 ++----
.../github_graphql/tasks/issue_extractor.go | 25 ++++------
.../plugins/github_graphql/tasks/pr_extractor.go | 18 +++----
backend/plugins/gitlab/tasks/issue_extractor.go | 58 ++++++++--------------
.../plugins/gitlab/tasks/mr_detail_extractor.go | 15 ++----
backend/plugins/gitlab/tasks/mr_extractor.go | 15 ++----
10 files changed, 83 insertions(+), 166 deletions(-)
diff --git a/backend/plugins/gitee/tasks/issue_extractor.go
b/backend/plugins/gitee/tasks/issue_extractor.go
index 175fd7a5a..5f20ec8fa 100644
--- a/backend/plugins/gitee/tasks/issue_extractor.go
+++ b/backend/plugins/gitee/tasks/issue_extractor.go
@@ -177,43 +177,22 @@ func ExtractApiIssues(taskCtx plugin.SubTaskContext)
errors.Error {
IssueId: giteeIssue.GiteeId,
LabelName: label.Name,
})
- if issueSeverityRegex != nil {
- groups :=
issueSeverityRegex.FindStringSubmatch(label.Name)
- if len(groups) > 0 {
- giteeIssue.Severity = groups[0]
- }
+ if issueSeverityRegex != nil &&
issueSeverityRegex.MatchString(label.Name) {
+ giteeIssue.Severity = label.Name
}
-
- if issueComponentRegex != nil {
- groups :=
issueComponentRegex.FindStringSubmatch(label.Name)
- if len(groups) > 0 {
- giteeIssue.Component = groups[0]
- }
- }
-
- if issuePriorityRegex != nil {
- groups :=
issuePriorityRegex.FindStringSubmatch(label.Name)
- if len(groups) > 0 {
- giteeIssue.Priority = groups[0]
- }
+ if issueComponentRegex != nil &&
issueComponentRegex.MatchString(label.Name) {
+ giteeIssue.Component = label.Name
}
-
- if issueTypeBugRegex != nil {
- if ok :=
issueTypeBugRegex.MatchString(label.Name); ok {
- giteeIssue.Type = ticket.BUG
- }
- }
-
- if issueTypeRequirementRegex != nil {
- if ok :=
issueTypeRequirementRegex.MatchString(label.Name); ok {
- giteeIssue.Type =
ticket.REQUIREMENT
- }
+ if issuePriorityRegex != nil &&
issuePriorityRegex.MatchString(label.Name) {
+ giteeIssue.Priority = label.Name
}
- if issueTypeIncidentRegex != nil {
- if ok :=
issueTypeIncidentRegex.MatchString(label.Name); ok {
- giteeIssue.Type =
ticket.INCIDENT
- }
+ if issueTypeRequirementRegex != nil &&
issueTypeRequirementRegex.MatchString(label.Name) {
+ giteeIssue.Type = ticket.REQUIREMENT
+ } else if issueTypeBugRegex != nil &&
issueTypeBugRegex.MatchString(label.Name) {
+ giteeIssue.Type = ticket.BUG
+ } else if issueTypeIncidentRegex != nil &&
issueTypeIncidentRegex.MatchString(label.Name) {
+ giteeIssue.Type = ticket.INCIDENT
}
}
results = append(results, giteeIssue)
diff --git a/backend/plugins/gitee/tasks/pr_extractor.go
b/backend/plugins/gitee/tasks/pr_extractor.go
index 462fe2e5d..94b84c271 100644
--- a/backend/plugins/gitee/tasks/pr_extractor.go
+++ b/backend/plugins/gitee/tasks/pr_extractor.go
@@ -124,19 +124,12 @@ func ExtractApiPullRequests(taskCtx
plugin.SubTaskContext) errors.Error {
LabelName: label.Name,
})
// if pr.Type has not been set and prType is
set in .env, process the below
- if labelTypeRegex != nil {
- groups :=
labelTypeRegex.FindStringSubmatch(label.Name)
- if len(groups) > 0 {
- giteePr.Type = groups[0]
- }
+ if labelTypeRegex != nil &&
labelTypeRegex.MatchString(label.Name) {
+ giteePr.Type = label.Name
}
-
// if pr.Component has not been set and
prComponent is set in .env, process
- if labelComponentRegex != nil {
- groups :=
labelComponentRegex.FindStringSubmatch(label.Name)
- if len(groups) > 0 {
- giteePr.Component = groups[0]
- }
+ if labelComponentRegex != nil &&
labelComponentRegex.MatchString(label.Name) {
+ giteePr.Component = label.Name
}
}
results = append(results, giteePr)
diff --git a/backend/plugins/github/e2e/snapshot_tables/_tool_github_issues.csv
b/backend/plugins/github/e2e/snapshot_tables/_tool_github_issues.csv
index 933af4374..556adb7ea 100644
--- a/backend/plugins/github/e2e/snapshot_tables/_tool_github_issues.csv
+++ b/backend/plugins/github/e2e/snapshot_tables/_tool_github_issues.csv
@@ -1,23 +1,23 @@
connection_id,github_id,repo_id,number,state,title,body,priority,type,author_id,author_name,assignee_id,assignee_name,milestone_id,lead_time_minutes,url,closed_at,github_created_at,github_updated_at,severity,component,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark
-1,346842831,134018330,5,closed," chinese <-p.freeSignal chinese ","""Hi,\r\n
chinese , chinese `<-p.freeSignal` chinese 。 chinese ,freeSignal
chinese , chinese `putWorker` chinese `p.freeSignal <- sig{}`\r\n\r\n
chinese \r\n```\r\nfunc (p *Pool) getWorker() *Worker {\r\n\tvar w
*Worker\r\n\twaiting := false\r\n\r\n\tp.lock.Lock()\r\n\tidleWorkers :=
p.workers\r\n\tn := len(idleWorkers) - 1\r\n\tif n < 0 { // chinese pool
chinese worker chinese \r\n\t\twaiting = p.Running() [...]
+1,346842831,134018330,5,closed," chinese <-p.freeSignal chinese ","""Hi,\r\n
chinese , chinese `<-p.freeSignal` chinese 。 chinese ,freeSignal
chinese , chinese `putWorker` chinese `p.freeSignal <- sig{}`\r\n\r\n
chinese \r\n```\r\nfunc (p *Pool) getWorker() *Worker {\r\n\tvar w
*Worker\r\n\twaiting := false\r\n\r\n\tp.lock.Lock()\r\n\tidleWorkers :=
p.workers\r\n\tn := len(idleWorkers) - 1\r\n\tif n < 0 { // chinese pool
chinese worker chinese \r\n\t\twaiting = p.Running() [...]
1,347255859,134018330,6,closed," chinese bug","""func (p *Pool) getWorker()
*Worker chinese 199 chinese \r\n chinese , chinese
\r\n\r\n\tp.lock.Unlock()\r\n\t\t<-p.freeSignal\r\n\t\tp.lock.Lock()""",,bug,13118848,lovelly,0,,7856149,1786,https://github.com/panjf2000/ants/issues/6,2018-08-04T10:18:41.000+00:00,2018-08-03T04:32:28.000+00:00,2018-08-04T10:18:41.000+00:00,,,"{""ConnectionId"":1,""Name"":""panjf2000/ants""}",_raw_github_api_issues,12,
1,348630179,134018330,7,closed," chinese ",""" chinese , chinese 。 chinese
ants chinese , chinese 。 chinese
\r\n\r\n
chinese periodicallyPurge chinese
\r\n\r\n\r\n###
chinese \r\n\r\n chinese n==0 chinese \r\n```\r\nif n > 0
{\r\n\tn++\r\n\tp.workers = idleWorkers[n:]\r\n} [...]
-1,356703393,134018330,10,closed," chinese worker chinese ",""" chinese cpu
chinese
?""",,question,11763614,Moonlight-Zhao,0,,7856149,36198,https://github.com/panjf2000/ants/issues/10,2018-09-29T11:45:00.000+00:00,2018-09-04T08:26:55.000+00:00,2018-09-29T11:45:00.000+00:00,,,"{""ConnectionId"":1,""Name"":""panjf2000/ants""}",_raw_github_api_issues,16,
+1,356703393,134018330,10,closed," chinese worker chinese ",""" chinese cpu
chinese
?""",,,11763614,Moonlight-Zhao,0,,7856149,36198,https://github.com/panjf2000/ants/issues/10,2018-09-29T11:45:00.000+00:00,2018-09-04T08:26:55.000+00:00,2018-09-29T11:45:00.000+00:00,,,"{""ConnectionId"":1,""Name"":""panjf2000/ants""}",_raw_github_api_issues,16,
1,364361014,134018330,12,closed," chinese , chinese tag chinese ",""" chinese
dep chinese , chinese ants chinese , chinese tag chinese 。 chinese tag 3.6
chinese ed55924 chinese ,git chinese af376f1b chinese , chinese 5 chinese ,
chinese , chinese tag chinese 。( chinese
)""",,,29452204,edcismybrother,0,,7856149,1293,https://github.com/panjf2000/ants/issues/12,2018-09-28T06:05:58.000+00:00,2018-09-27T08:32:25.000+00:00,2019-04-21T08:19:58.000+00:00,,,"{""ConnectionId"":1,""Name"":""panjf20
[...]
-1,381941219,134018330,17,closed," chinese ",""" chinese package chinese ,
chinese Release chinese :\r\n\r\n`\r\n\t// Release Closed this pool.\r\n\tfunc
(p *PoolWithFunc) Release() error {\r\n\t\tp.once.Do(func()
{\r\n\t\t\tp.release <- sig{}\r\n\t\t\tp.lock.Lock()\r\n\t\t\tidleWorkers :=
p.workers\r\n\t\t\tfor i, w := range idleWorkers {\r\n\t\t\t\tw.args <-
nil\r\n\t\t\t\tidleWorkers[i] = nil\r\n\t\t\t}\r\n\t\t\tp.workers =
nil\r\n\t\t\tp.lock.Unlock()\r\n\t\t})\r\n\t\treturn nil\r\n\t [...]
-1,382039050,134018330,18,closed,go chinese ,""" chinese , chinese , chinese go
chinese , chinese , chinese 。\"" chinese : GOMAXPROCS sets the maximum number
of CPUs that can be executing simultaneously。 chinese cpu chinese , chinese ,
chinese ?, chinese ?, chinese ?, chinese
?\""""",,question,13944100,LinuxForYQH,0,,7856149,20213,https://github.com/panjf2000/ants/issues/18,2018-12-03T03:53:50.000+00:00,2018-11-19T02:59:53.000+00:00,2018-12-03T03:53:50.000+00:00,,,"{""ConnectionId"":1,""N
[...]
-1,382574800,134018330,20,closed," chinese
","""#""",,enhancement,5668717,kklinan,0,,7856149,95398,https://github.com/panjf2000/ants/issues/20,2019-01-25T15:34:03.000+00:00,2018-11-20T09:36:02.000+00:00,2019-01-25T15:34:03.000+00:00,,,"{""ConnectionId"":1,""Name"":""panjf2000/ants""}",_raw_github_api_issues,26,
+1,381941219,134018330,17,closed," chinese ",""" chinese package chinese ,
chinese Release chinese :\r\n\r\n`\r\n\t// Release Closed this pool.\r\n\tfunc
(p *PoolWithFunc) Release() error {\r\n\t\tp.once.Do(func()
{\r\n\t\t\tp.release <- sig{}\r\n\t\t\tp.lock.Lock()\r\n\t\t\tidleWorkers :=
p.workers\r\n\t\t\tfor i, w := range idleWorkers {\r\n\t\t\t\tw.args <-
nil\r\n\t\t\t\tidleWorkers[i] = nil\r\n\t\t\t}\r\n\t\t\tp.workers =
nil\r\n\t\t\tp.lock.Unlock()\r\n\t\t})\r\n\t\treturn nil\r\n\t [...]
+1,382039050,134018330,18,closed,go chinese ,""" chinese , chinese , chinese go
chinese , chinese , chinese 。\"" chinese : GOMAXPROCS sets the maximum number
of CPUs that can be executing simultaneously。 chinese cpu chinese , chinese ,
chinese ?, chinese ?, chinese ?, chinese
?\""""",,,13944100,LinuxForYQH,0,,7856149,20213,https://github.com/panjf2000/ants/issues/18,2018-12-03T03:53:50.000+00:00,2018-11-19T02:59:53.000+00:00,2018-12-03T03:53:50.000+00:00,,,"{""ConnectionId"":1,""Name"":""
[...]
+1,382574800,134018330,20,closed," chinese
","""#""",,,5668717,kklinan,0,,7856149,95398,https://github.com/panjf2000/ants/issues/20,2019-01-25T15:34:03.000+00:00,2018-11-20T09:36:02.000+00:00,2019-01-25T15:34:03.000+00:00,,,"{""ConnectionId"":1,""Name"":""panjf2000/ants""}",_raw_github_api_issues,26,
1,388907811,134018330,21,closed,Benchmark chinese Semaphore chinese ?,"""
chinese benchmark,Semaphore chinese \r\n\r\n```bash\r\n$ go test -bench
.\r\ngoos: darwin\r\ngoarch: amd64\r\npkg:
github.com/panjf2000/ants\r\nBenchmarkGoroutineWithFunc-4 \t
1\t3445631705 ns/op\r\nBenchmarkSemaphoreWithFunc-4 \t 1\t1037219073
ns/op\r\nBenchmarkAntsPoolWithFunc-4 \t 1\t1138053222
ns/op\r\nBenchmarkGoroutine-4 \t 2\t 731850771
ns/op\r\nBenchmarkSemaphor [...]
-1,401277739,134018330,22,closed," chinese worker chinese PanicHandler
?",""" chinese Pool chinese PanicHandler, chinese worker chinese recover
chinese PanicHandler chinese 。 chinese panic chinese
。""",,enhancement,8923413,choleraehyq,0,,7856149,1174,https://github.com/panjf2000/ants/issues/22,2019-01-22T05:41:34.000+00:00,2019-01-21T10:06:56.000+00:00,2019-01-22T05:41:34.000+00:00,,,"{""ConnectionId"":1,""Name"":""panjf2000/ants""}",_raw_github_api_issues,28,
-1,402513849,134018330,24,closed," chinese ","""`Pool.Submit` chinese
`PoolWithFunc.Server` chinese , chinese worker, chinese 。 chinese , chinese
。""",,enhancement,5044825,tenfyzhong,0,,7856149,300032,https://github.com/panjf2000/ants/issues/24,2019-08-20T10:56:30.000+00:00,2019-01-24T02:24:13.000+00:00,2019-08-20T10:56:30.000+00:00,,,"{""ConnectionId"":1,""Name"":""panjf2000/ants""}",_raw_github_api_issues,30,
+1,401277739,134018330,22,closed," chinese worker chinese PanicHandler
?",""" chinese Pool chinese PanicHandler, chinese worker chinese recover
chinese PanicHandler chinese 。 chinese panic chinese
。""",,,8923413,choleraehyq,0,,7856149,1174,https://github.com/panjf2000/ants/issues/22,2019-01-22T05:41:34.000+00:00,2019-01-21T10:06:56.000+00:00,2019-01-22T05:41:34.000+00:00,,,"{""ConnectionId"":1,""Name"":""panjf2000/ants""}",_raw_github_api_issues,28,
+1,402513849,134018330,24,closed," chinese ","""`Pool.Submit` chinese
`PoolWithFunc.Server` chinese , chinese worker, chinese 。 chinese , chinese
。""",,,5044825,tenfyzhong,0,,7856149,300032,https://github.com/panjf2000/ants/issues/24,2019-08-20T10:56:30.000+00:00,2019-01-24T02:24:13.000+00:00,2019-08-20T10:56:30.000+00:00,,,"{""ConnectionId"":1,""Name"":""panjf2000/ants""}",_raw_github_api_issues,30,
1,405951301,134018330,25,closed,use example errors,"""./antstest.go:37:14:
cannot use syncCalculateSum (type func()) as type ants.f in argument to
ants.Submit\r\n./antstest.go:45:35: cannot use func literal (type
func(interface {})) as type ants.pf in argument to
ants.NewPoolWithFunc\r\n""",,,5244267,jiashiwen,0,,7856149,3088,https://github.com/panjf2000/ants/issues/25,2019-02-04T09:11:52.000+00:00,2019-02-02T05:43:38.000+00:00,2019-02-04T09:11:52.000+00:00,,,"{""ConnectionId"":1,""Name"
[...]
1,413968505,134018330,26,closed,running chinese cap chinese ,"""running
chinese cap chinese incRuning chinese , chinese running chinese cap chinese
?\r\n`func (p *Pool) retrieveWorker() *Worker {\r\n\tvar w
*Worker\r\n\r\n\tp.lock.Lock()\r\n\tidleWorkers := p.workers\r\n\tn :=
len(idleWorkers) - 1\r\n\tif n >= 0 {\r\n\t\tw =
idleWorkers[n]\r\n\t\tidleWorkers[n] = nil\r\n\t\tp.workers =
idleWorkers[:n]\r\n\t\tp.lock.Unlock()\r\n\t} else if p.Running() < p.Cap()
{\r\n\t\tp.lock.Unlock()\r [...]
1,419183961,134018330,27,closed," chinese goroutine chinese , chinese ","""
chinese goroutine chinese , chinese \r\n chinese ?\r\n\r\nwebsocket
server\r\nhttps://github.com/im-ai/pushm/blob/master/learn/goroutine/goroutinepoolwebsocket.go\r\n\r\nwebsocket
cient\r\nhttps://github.com/im-ai/pushm/blob/master/learn/goroutine/goroutinepoolwebsocketclient.go\r\n""",,,38367404,liliang8858,0,,7856149,37496,https://github.com/panjf2000/ants/issues/27,2019-04-05T14:05:20.000+00:00,2019-03-10T13:0
[...]
1,419268851,134018330,28,closed,cap chinese running chinese ,""" chinese
Playground chinese https://play.golang.org/p/D94YUU3FnX6\r\natomic chinese ,
chinese , chinese chinese , chinese chinese , chinese chinese , chinese
\r\n chinese #26 chinese
""",,,29243953,naiba,0,,7856149,237002,https://github.com/panjf2000/ants/issues/28,2019-08-22T16:27:37.000+00:00,2019-03-11T02:24:41.000+00:00,2019-08-22T16:27:37.000+00:00,,,"{""ConnectionId"":1,""Name"":""panjf2000/ants""}",_raw
[...]
1,424634533,134018330,29,closed," chinese ",""" chinese , chinese
👍\r\n\r\nhttps://github.com/panjf2000/ants/blob/master/pool.go#L124 chinese ,
chinese
?\r\n""",,,8509898,prprprus,0,,7856149,999,https://github.com/panjf2000/ants/issues/29,2019-03-25T09:32:11.000+00:00,2019-03-24T16:52:21.000+00:00,2019-03-25T09:45:05.000+00:00,,,"{""ConnectionId"":1,""Name"":""panjf2000/ants""}",_raw_github_api_issues,35,
1,429972115,134018330,31,closed,Add
go.mod,"""""",,,48135919,tsatke,0,,7856149,3474,https://github.com/panjf2000/ants/issues/31,2019-04-08T09:45:31.000+00:00,2019-04-05T23:50:36.000+00:00,2019-10-17T03:12:19.000+00:00,,,"{""ConnectionId"":1,""Name"":""panjf2000/ants""}",_raw_github_api_issues,37,
-1,433564955,134018330,32,closed," chinese , chinese (0.0.x) chinese ?","""
chinese , chinese 。\r\n\r\n chinese \r\n\r\n chinese , chinese
。""",,enhancement,7931755,zplzpl,0,,7856149,7440,https://github.com/panjf2000/ants/issues/32,2019-04-21T07:16:26.000+00:00,2019-04-16T03:16:02.000+00:00,2019-04-21T07:16:26.000+00:00,,,"{""ConnectionId"":1,""Name"":""panjf2000/ants""}",_raw_github_api_issues,38,
-1,434069015,134018330,33,closed,support semantic versioning.,""" chinese tag
chinese semantic versioning,vX.Y.Z。go modules chinese
。\r\nhttps://semver.org/\r\nhttps://research.swtch.com/vgo-import""",,enhancement,1284892,jjeffcaii,0,,7856149,6090,https://github.com/panjf2000/ants/issues/33,2019-04-21T08:25:20.000+00:00,2019-04-17T02:55:11.000+00:00,2019-04-21T08:25:20.000+00:00,,,"{""ConnectionId"":1,""Name"":""panjf2000/ants""}",_raw_github_api_issues,39,
+1,433564955,134018330,32,closed," chinese , chinese (0.0.x) chinese ?","""
chinese , chinese 。\r\n\r\n chinese \r\n\r\n chinese , chinese
。""",,,7931755,zplzpl,0,,7856149,7440,https://github.com/panjf2000/ants/issues/32,2019-04-21T07:16:26.000+00:00,2019-04-16T03:16:02.000+00:00,2019-04-21T07:16:26.000+00:00,,,"{""ConnectionId"":1,""Name"":""panjf2000/ants""}",_raw_github_api_issues,38,
+1,434069015,134018330,33,closed,support semantic versioning.,""" chinese tag
chinese semantic versioning,vX.Y.Z。go modules chinese
。\r\nhttps://semver.org/\r\nhttps://research.swtch.com/vgo-import""",,,1284892,jjeffcaii,0,,7856149,6090,https://github.com/panjf2000/ants/issues/33,2019-04-21T08:25:20.000+00:00,2019-04-17T02:55:11.000+00:00,2019-04-21T08:25:20.000+00:00,,,"{""ConnectionId"":1,""Name"":""panjf2000/ants""}",_raw_github_api_issues,39,
1,435486645,134018330,34,closed,Important announcement about <ants> from
author !!!,"""**Dear users of `ants`:**\r\nI am apologetically telling you that
I have to dump all tags which already presents in `ants` repository.\r\n\r\nThe
reason why I'm doing so is to standardize the version management with `Semantic
Versioning`, which will make a formal and clear dependency management in go,
for go modules, godep, or glide, etc. So I decide to start over the tag
sequence, you could find more [...]
1,461280653,134018330,35,closed,worker exit on panic,""" chinese PanicHandler
chinese 。\r\n1. chinese PanicHandler chinese , chinese panic, chinese 。\r\n2.
chinese PanicHandler, chinese worker chinese , chinese pool chinese
。""",,,38849208,king526,0,,7856149,74481,https://github.com/panjf2000/ants/issues/35,2019-08-17T20:33:10.000+00:00,2019-06-27T03:11:49.000+00:00,2019-08-17T20:33:10.000+00:00,,,"{""ConnectionId"":1,""Name"":""panjf2000/ants""}",_raw_github_api_issues,41,
1,462631417,134018330,37,closed," chinese 。。。",""" chinese 3.9.9, chinese ,
chinese , chinese 1.0.0。 chinese 。 chinese
""",,,8923413,choleraehyq,0,,7856149,140,https://github.com/panjf2000/ants/issues/37,2019-07-01T12:37:55.000+00:00,2019-07-01T10:17:15.000+00:00,2019-07-02T10:17:31.000+00:00,,,"{""ConnectionId"":1,""Name"":""panjf2000/ants""}",_raw_github_api_issues,43,
diff --git a/backend/plugins/github/tasks/issue_extractor.go
b/backend/plugins/github/tasks/issue_extractor.go
index 0801302fb..974ad397d 100644
--- a/backend/plugins/github/tasks/issue_extractor.go
+++ b/backend/plugins/github/tasks/issue_extractor.go
@@ -210,32 +210,25 @@ func convertGithubLabels(issueRegexes *IssueRegexes,
issue *IssuesResponse, gith
IssueId: githubIssue.GithubId,
LabelName: label.Name,
})
- joinedLabels = append(joinedLabels, label.Name)
- if issueRegexes.SeverityRegex != nil {
- groups :=
issueRegexes.SeverityRegex.FindStringSubmatch(label.Name)
- if len(groups) > 0 {
- githubIssue.Severity = groups[0]
- }
+ if issueRegexes.SeverityRegex != nil &&
issueRegexes.SeverityRegex.MatchString(label.Name) {
+ githubIssue.Severity = label.Name
}
- if issueRegexes.ComponentRegex != nil {
- groups :=
issueRegexes.ComponentRegex.FindStringSubmatch(label.Name)
- if len(groups) > 0 {
- githubIssue.Component = groups[0]
- }
+ if issueRegexes.ComponentRegex != nil &&
issueRegexes.ComponentRegex.MatchString(label.Name) {
+ githubIssue.Component = label.Name
}
- if issueRegexes.PriorityRegex != nil {
- groups :=
issueRegexes.PriorityRegex.FindStringSubmatch(label.Name)
- if len(groups) > 0 {
- githubIssue.Priority = groups[0]
- }
+ if issueRegexes.PriorityRegex != nil &&
issueRegexes.PriorityRegex.MatchString(label.Name) {
+ githubIssue.Priority = label.Name
}
if issueRegexes.TypeRequirementRegex != nil &&
issueRegexes.TypeRequirementRegex.MatchString(label.Name) {
githubIssue.StdType = ticket.REQUIREMENT
+ joinedLabels = append(joinedLabels, label.Name)
} else if issueRegexes.TypeBugRegex != nil &&
issueRegexes.TypeBugRegex.MatchString(label.Name) {
githubIssue.StdType = ticket.BUG
+ joinedLabels = append(joinedLabels, label.Name)
} else if issueRegexes.TypeIncidentRegex != nil &&
issueRegexes.TypeIncidentRegex.MatchString(label.Name) {
githubIssue.StdType = ticket.INCIDENT
+ joinedLabels = append(joinedLabels, label.Name)
}
}
if len(joinedLabels) > 0 {
diff --git a/backend/plugins/github/tasks/pr_extractor.go
b/backend/plugins/github/tasks/pr_extractor.go
index e22265821..17fec4a45 100644
--- a/backend/plugins/github/tasks/pr_extractor.go
+++ b/backend/plugins/github/tasks/pr_extractor.go
@@ -143,19 +143,12 @@ func ExtractApiPullRequests(taskCtx
plugin.SubTaskContext) errors.Error {
LabelName: label.Name,
})
// if pr.Type has not been set and prType is
set in .env, process the below
- if labelTypeRegex != nil {
- groups :=
labelTypeRegex.FindStringSubmatch(label.Name)
- if len(groups) > 0 {
- githubPr.Type = groups[0]
- }
+ if labelTypeRegex != nil &&
labelTypeRegex.MatchString(label.Name) {
+ githubPr.Type = label.Name
}
-
// if pr.Component has not been set and
prComponent is set in .env, process
- if labelComponentRegex != nil {
- groups :=
labelComponentRegex.FindStringSubmatch(label.Name)
- if len(groups) > 0 {
- githubPr.Component = groups[0]
- }
+ if labelComponentRegex != nil &&
labelComponentRegex.MatchString(label.Name) {
+ githubPr.Component = label.Name
}
}
results = append(results, githubPr)
diff --git a/backend/plugins/github_graphql/tasks/issue_extractor.go
b/backend/plugins/github_graphql/tasks/issue_extractor.go
index deb54974b..355343e0c 100644
--- a/backend/plugins/github_graphql/tasks/issue_extractor.go
+++ b/backend/plugins/github_graphql/tasks/issue_extractor.go
@@ -171,32 +171,25 @@ func convertGithubLabels(issueRegexes
*githubTasks.IssueRegexes, issue GraphqlQu
IssueId: githubIssue.GithubId,
LabelName: label.Name,
})
- joinedLabels = append(joinedLabels, label.Name)
- if issueRegexes.SeverityRegex != nil {
- groups :=
issueRegexes.SeverityRegex.FindStringSubmatch(label.Name)
- if len(groups) > 0 {
- githubIssue.Severity = groups[0]
- }
+ if issueRegexes.SeverityRegex != nil &&
issueRegexes.SeverityRegex.MatchString(label.Name) {
+ githubIssue.Severity = label.Name
}
- if issueRegexes.ComponentRegex != nil {
- groups :=
issueRegexes.ComponentRegex.FindStringSubmatch(label.Name)
- if len(groups) > 0 {
- githubIssue.Component = groups[0]
- }
+ if issueRegexes.ComponentRegex != nil &&
issueRegexes.ComponentRegex.MatchString(label.Name) {
+ githubIssue.Component = label.Name
}
- if issueRegexes.PriorityRegex != nil {
- groups :=
issueRegexes.PriorityRegex.FindStringSubmatch(label.Name)
- if len(groups) > 0 {
- githubIssue.Priority = groups[0]
- }
+ if issueRegexes.PriorityRegex != nil &&
issueRegexes.PriorityRegex.MatchString(label.Name) {
+ githubIssue.Priority = label.Name
}
if issueRegexes.TypeRequirementRegex != nil &&
issueRegexes.TypeRequirementRegex.MatchString(label.Name) {
githubIssue.StdType = ticket.REQUIREMENT
+ joinedLabels = append(joinedLabels, label.Name)
} else if issueRegexes.TypeBugRegex != nil &&
issueRegexes.TypeBugRegex.MatchString(label.Name) {
githubIssue.StdType = ticket.BUG
+ joinedLabels = append(joinedLabels, label.Name)
} else if issueRegexes.TypeIncidentRegex != nil &&
issueRegexes.TypeIncidentRegex.MatchString(label.Name) {
githubIssue.StdType = ticket.INCIDENT
+ joinedLabels = append(joinedLabels, label.Name)
}
}
if len(joinedLabels) > 0 {
diff --git a/backend/plugins/github_graphql/tasks/pr_extractor.go
b/backend/plugins/github_graphql/tasks/pr_extractor.go
index 11bace53f..9abcc4a06 100644
--- a/backend/plugins/github_graphql/tasks/pr_extractor.go
+++ b/backend/plugins/github_graphql/tasks/pr_extractor.go
@@ -19,6 +19,7 @@ package tasks
import (
"encoding/json"
+ "fmt"
"regexp"
"github.com/apache/incubator-devlake/core/errors"
@@ -52,6 +53,7 @@ func ExtractPrs(taskCtx plugin.SubTaskContext) errors.Error {
}
}
if config != nil && len(config.PrComponent) > 0 {
+ fmt.Println("config.PrComponent1", config.PrComponent)
labelComponentRegex, err =
errors.Convert01(regexp.Compile(config.PrComponent))
if err != nil {
return errors.Default.Wrap(err, "regexp Compile
prComponent failed")
@@ -88,19 +90,13 @@ func ExtractPrs(taskCtx plugin.SubTaskContext) errors.Error
{
LabelName: label.Name,
})
// if pr.Type has not been set and
prType is set in .env, process the below
- if labelTypeRegex != nil {
- groups :=
labelTypeRegex.FindStringSubmatch(label.Name)
- if len(groups) > 0 {
- githubPr.Type =
groups[0]
- }
+ if labelTypeRegex != nil &&
labelTypeRegex.MatchString(label.Name) {
+ githubPr.Type = label.Name
}
-
// if pr.Component has not been set and
prComponent is set in .env, process
- if labelComponentRegex != nil {
- groups :=
labelComponentRegex.FindStringSubmatch(label.Name)
- if len(groups) > 0 {
- githubPr.Component =
groups[0]
- }
+ if labelComponentRegex != nil &&
labelComponentRegex.MatchString(label.Name) {
+ githubPr.Component = label.Name
+
}
}
results = append(results, githubPr)
diff --git a/backend/plugins/gitlab/tasks/issue_extractor.go
b/backend/plugins/gitlab/tasks/issue_extractor.go
index 2ae75e773..116dc9aca 100644
--- a/backend/plugins/gitlab/tasks/issue_extractor.go
+++ b/backend/plugins/gitlab/tasks/issue_extractor.go
@@ -20,6 +20,7 @@ package tasks
import (
"encoding/json"
"regexp"
+ "strings"
"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/models/common"
@@ -202,55 +203,38 @@ func ExtractApiIssues(taskCtx plugin.SubTaskContext)
errors.Error {
if err != nil {
return nil, err
}
-
+ var joinedLabels []string
for _, label := range body.Labels {
results = append(results,
&models.GitlabIssueLabel{
IssueId: gitlabIssue.GitlabId,
LabelName: label,
ConnectionId: data.Options.ConnectionId,
})
- if issueSeverityRegex != nil {
- groups :=
issueSeverityRegex.FindStringSubmatch(label)
- if len(groups) > 0 {
- gitlabIssue.Severity = groups[0]
- }
+ if issueSeverityRegex != nil &&
issueSeverityRegex.MatchString(label) {
+ gitlabIssue.Severity = label
}
-
- if issueComponentRegex != nil {
- groups :=
issueComponentRegex.FindStringSubmatch(label)
- if len(groups) > 0 {
- gitlabIssue.Component =
groups[0]
- }
+ if issueComponentRegex != nil &&
issueComponentRegex.MatchString(label) {
+ gitlabIssue.Component = label
}
-
- if issuePriorityRegex != nil {
- groups :=
issuePriorityRegex.FindStringSubmatch(label)
- if len(groups) > 0 {
- gitlabIssue.Priority = groups[0]
- }
- }
-
- if issueTypeBugRegex != nil {
- if ok :=
issueTypeBugRegex.MatchString(label); ok {
- gitlabIssue.StdType = ticket.BUG
- gitlabIssue.Type = label
- }
+ if issuePriorityRegex != nil &&
issuePriorityRegex.MatchString(label) {
+ gitlabIssue.Priority = label
}
- if issueTypeRequirementRegex != nil {
- if ok :=
issueTypeRequirementRegex.MatchString(label); ok {
- gitlabIssue.StdType =
ticket.REQUIREMENT
- gitlabIssue.Type = label
- }
- }
-
- if issueTypeIncidentRegex != nil {
- if ok :=
issueTypeIncidentRegex.MatchString(label); ok {
- gitlabIssue.StdType =
ticket.INCIDENT
- gitlabIssue.Type = label
- }
+ if issueTypeRequirementRegex != nil &&
issueTypeRequirementRegex.MatchString(label) {
+ gitlabIssue.StdType = ticket.REQUIREMENT
+ joinedLabels = append(joinedLabels,
label)
+ } else if issueTypeBugRegex != nil &&
issueTypeBugRegex.MatchString(label) {
+ gitlabIssue.StdType = ticket.BUG
+ joinedLabels = append(joinedLabels,
label)
+ } else if issueTypeIncidentRegex != nil &&
issueTypeIncidentRegex.MatchString(label) {
+ gitlabIssue.StdType = ticket.INCIDENT
+ joinedLabels = append(joinedLabels,
label)
}
}
+ if len(joinedLabels) > 0 {
+ gitlabIssue.Type = strings.Join(joinedLabels,
",")
+ }
+
gitlabIssue.ConnectionId = data.Options.ConnectionId
if body.Author != nil {
gitlabAuthor, err := convertGitlabAuthor(body,
data.Options.ConnectionId)
diff --git a/backend/plugins/gitlab/tasks/mr_detail_extractor.go
b/backend/plugins/gitlab/tasks/mr_detail_extractor.go
index b4666f7ea..9453a59fc 100644
--- a/backend/plugins/gitlab/tasks/mr_detail_extractor.go
+++ b/backend/plugins/gitlab/tasks/mr_detail_extractor.go
@@ -84,19 +84,12 @@ func ExtractApiMergeRequestDetails(taskCtx
plugin.SubTaskContext) errors.Error {
ConnectionId: data.Options.ConnectionId,
})
// if pr.Type has not been set and prType is
set in .env, process the below
- if labelTypeRegex != nil {
- groups :=
labelTypeRegex.FindStringSubmatch(label)
- if len(groups) > 0 {
- gitlabMergeRequest.Type =
groups[0]
- }
+ if labelTypeRegex != nil &&
labelTypeRegex.MatchString(label) {
+ gitlabMergeRequest.Type = label
}
-
// if pr.Component has not been set and
prComponent is set in .env, process
- if labelComponentRegex != nil {
- groups :=
labelComponentRegex.FindStringSubmatch(label)
- if len(groups) > 0 {
- gitlabMergeRequest.Component =
groups[0]
- }
+ if labelComponentRegex != nil &&
labelComponentRegex.MatchString(label) {
+ gitlabMergeRequest.Component = label
}
}
for _, reviewer := range mr.Reviewers {
diff --git a/backend/plugins/gitlab/tasks/mr_extractor.go
b/backend/plugins/gitlab/tasks/mr_extractor.go
index 2f59a03ad..92bfccfa3 100644
--- a/backend/plugins/gitlab/tasks/mr_extractor.go
+++ b/backend/plugins/gitlab/tasks/mr_extractor.go
@@ -141,19 +141,12 @@ func ExtractApiMergeRequests(taskCtx
plugin.SubTaskContext) errors.Error {
ConnectionId: data.Options.ConnectionId,
})
// if pr.Type has not been set and prType is
set in .env, process the below
- if labelTypeRegex != nil {
- groups :=
labelTypeRegex.FindStringSubmatch(label)
- if len(groups) > 0 {
- gitlabMergeRequest.Type =
groups[0]
- }
+ if labelTypeRegex != nil &&
labelTypeRegex.MatchString(label) {
+ gitlabMergeRequest.Type = label
}
-
// if pr.Component has not been set and
prComponent is set in .env, process
- if labelComponentRegex != nil {
- groups :=
labelComponentRegex.FindStringSubmatch(label)
- if len(groups) > 0 {
- gitlabMergeRequest.Component =
groups[0]
- }
+ if labelComponentRegex != nil &&
labelComponentRegex.MatchString(label) {
+ gitlabMergeRequest.Component = label
}
}
for _, reviewer := range mr.Reviewers {