From 93ed7a0e0fc94cb23f41525bc10c65fcdb5d5004 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Sat, 21 May 2022 22:20:33 -0600 Subject: [PATCH 1/5] Make `Draft` working as a WIP prefix The issue was that only the actual title was converted to uppercase, but not the prefix as specified in `WORK_IN_PROGRESS_PREFIXES`. As a result, the following did not work: WORK_IN_PROGRESS_PREFIXES=Draft:,[Draft],WIP:,[WIP] One possible workaround was: WORK_IN_PROGRESS_PREFIXES=DRAFT:,[DRAFT],WIP:,[WIP] Then indeed one could use `Draft` (as well as `DRAFT`) in the title. However, the link `Start the title with DRAFT: to prevent the pull request from being merged accidentally.` showed the suggestion in uppercase; so it is not possible to show it as `Draft`. This PR fixes it, and allows to use `Draft` in `WORK_IN_PROGRESS_PREFIXES`. Fixes #19779. --- models/pull.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/pull.go b/models/pull.go index bb5bb118122fa..8177daf1b528d 100644 --- a/models/pull.go +++ b/models/pull.go @@ -588,7 +588,7 @@ func (pr *PullRequest) IsWorkInProgress() bool { // HasWorkInProgressPrefix determines if the given PR title has a Work In Progress prefix func HasWorkInProgressPrefix(title string) bool { for _, prefix := range setting.Repository.PullRequest.WorkInProgressPrefixes { - if strings.HasPrefix(strings.ToUpper(title), prefix) { + if strings.HasPrefix(strings.ToUpper(title), strings.ToUpper(prefix)) { return true } } From 11754a123b4a4da732114efc4cba60a739fdd6a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Sun, 22 May 2022 09:21:58 -0600 Subject: [PATCH 2/5] Also change GetWorkInProgressPrefix() --- models/pull.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/pull.go b/models/pull.go index 8177daf1b528d..df96e2dc74582 100644 --- a/models/pull.go +++ b/models/pull.go @@ -609,7 +609,7 @@ func (pr *PullRequest) GetWorkInProgressPrefix() string { } for _, prefix := range setting.Repository.PullRequest.WorkInProgressPrefixes { - if strings.HasPrefix(strings.ToUpper(pr.Issue.Title), prefix) { + if strings.HasPrefix(strings.ToUpper(pr.Issue.Title), strings.ToUpper(prefix)) { return pr.Issue.Title[0:len(prefix)] } } From 9df3edd171843b6132c09a1b32340e600df469e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Wed, 25 May 2022 23:09:01 -0600 Subject: [PATCH 3/5] Add Draft as an example in app.example.ini --- custom/conf/app.example.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 476b30502681c..f969a96a9038e 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -938,8 +938,8 @@ PATH = ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; -;; List of prefixes used in Pull Request title to mark them as Work In Progress -;WORK_IN_PROGRESS_PREFIXES = WIP:,[WIP] +;; List of prefixes used in Pull Request title to mark them as Work In Progress (matched in a case-insensitive manner) +;WORK_IN_PROGRESS_PREFIXES = Draft:,[Draft],WIP:,[WIP] ;; ;; List of keywords used in Pull Request comments to automatically close a related issue ;CLOSE_KEYWORDS = close,closes,closed,fix,fixes,fixed,resolve,resolves,resolved From 82418eb726910edbfca58332456ddc8f868e249c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Wed, 25 May 2022 23:15:24 -0600 Subject: [PATCH 4/5] Update documentation --- docs/content/doc/advanced/config-cheat-sheet.en-us.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/content/doc/advanced/config-cheat-sheet.en-us.md b/docs/content/doc/advanced/config-cheat-sheet.en-us.md index 4c43ba7ddb9f6..5cbe28891ec3b 100644 --- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md +++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md @@ -86,8 +86,8 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`. ### Repository - Pull Request (`repository.pull-request`) -- `WORK_IN_PROGRESS_PREFIXES`: **WIP:,\[WIP\]**: List of prefixes used in Pull Request - title to mark them as Work In Progress +- `WORK_IN_PROGRESS_PREFIXES`: **Draft:,\[Draft\],WIP:,\[WIP\]**: List of prefixes used in Pull Request + title to mark them as Work In Progress. These are matched in a case-insensitive manner. - `CLOSE_KEYWORDS`: **close**, **closes**, **closed**, **fix**, **fixes**, **fixed**, **resolve**, **resolves**, **resolved**: List of keywords used in Pull Request comments to automatically close a related issue - `REOPEN_KEYWORDS`: **reopen**, **reopens**, **reopened**: List of keywords used in Pull Request comments to automatically reopen From 5307b29afcb399e4561f0f9e386ea6c59238643a Mon Sep 17 00:00:00 2001 From: zeripath Date: Thu, 26 May 2022 09:35:02 +0100 Subject: [PATCH 5/5] Restore default values. --- custom/conf/app.example.ini | 2 +- docs/content/doc/advanced/config-cheat-sheet.en-us.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index f969a96a9038e..8362f228123da 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -939,7 +939,7 @@ PATH = ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; List of prefixes used in Pull Request title to mark them as Work In Progress (matched in a case-insensitive manner) -;WORK_IN_PROGRESS_PREFIXES = Draft:,[Draft],WIP:,[WIP] +;WORK_IN_PROGRESS_PREFIXES = WIP:,[WIP] ;; ;; List of keywords used in Pull Request comments to automatically close a related issue ;CLOSE_KEYWORDS = close,closes,closed,fix,fixes,fixed,resolve,resolves,resolved diff --git a/docs/content/doc/advanced/config-cheat-sheet.en-us.md b/docs/content/doc/advanced/config-cheat-sheet.en-us.md index 5cbe28891ec3b..785fd3d6c25e3 100644 --- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md +++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md @@ -86,7 +86,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`. ### Repository - Pull Request (`repository.pull-request`) -- `WORK_IN_PROGRESS_PREFIXES`: **Draft:,\[Draft\],WIP:,\[WIP\]**: List of prefixes used in Pull Request +- `WORK_IN_PROGRESS_PREFIXES`: **WIP:,\[WIP\]**: List of prefixes used in Pull Request title to mark them as Work In Progress. These are matched in a case-insensitive manner. - `CLOSE_KEYWORDS`: **close**, **closes**, **closed**, **fix**, **fixes**, **fixed**, **resolve**, **resolves**, **resolved**: List of keywords used in Pull Request comments to automatically close a related issue