Skip to content

Commit 995d12a

Browse files
certikzeripath
andcommitted
Make WIP prefixes case insensitive, e.g. allow Draft as a WIP prefix (go-gitea#19780)
Backport go-gitea#19780 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 go-gitea#19779. Co-authored-by: zeripath <[email protected]>
1 parent ccc11c1 commit 995d12a

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

custom/conf/app.example.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ PATH =
880880
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
881881
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
882882
;;
883-
;; List of prefixes used in Pull Request title to mark them as Work In Progress
883+
;; List of prefixes used in Pull Request title to mark them as Work In Progress (matched in a case-insensitive manner)
884884
;WORK_IN_PROGRESS_PREFIXES = WIP:,[WIP]
885885
;;
886886
;; List of keywords used in Pull Request comments to automatically close a related issue

docs/content/doc/advanced/config-cheat-sheet.en-us.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
8787
### Repository - Pull Request (`repository.pull-request`)
8888

8989
- `WORK_IN_PROGRESS_PREFIXES`: **WIP:,\[WIP\]**: List of prefixes used in Pull Request
90-
title to mark them as Work In Progress
90+
title to mark them as Work In Progress. These are matched in a case-insensitive manner.
9191
- `CLOSE_KEYWORDS`: **close**, **closes**, **closed**, **fix**, **fixes**, **fixed**, **resolve**, **resolves**, **resolved**: List of
9292
keywords used in Pull Request comments to automatically close a related issue
9393
- `REOPEN_KEYWORDS`: **reopen**, **reopens**, **reopened**: List of keywords used in Pull Request comments to automatically reopen

models/pull.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ func (pr *PullRequest) IsWorkInProgress() bool {
622622
// HasWorkInProgressPrefix determines if the given PR title has a Work In Progress prefix
623623
func HasWorkInProgressPrefix(title string) bool {
624624
for _, prefix := range setting.Repository.PullRequest.WorkInProgressPrefixes {
625-
if strings.HasPrefix(strings.ToUpper(title), prefix) {
625+
if strings.HasPrefix(strings.ToUpper(title), strings.ToUpper(prefix)) {
626626
return true
627627
}
628628
}
@@ -643,7 +643,7 @@ func (pr *PullRequest) GetWorkInProgressPrefix() string {
643643
}
644644

645645
for _, prefix := range setting.Repository.PullRequest.WorkInProgressPrefixes {
646-
if strings.HasPrefix(strings.ToUpper(pr.Issue.Title), prefix) {
646+
if strings.HasPrefix(strings.ToUpper(pr.Issue.Title), strings.ToUpper(prefix)) {
647647
return pr.Issue.Title[0:len(prefix)]
648648
}
649649
}

0 commit comments

Comments
 (0)