mirror of
https://gitea.com/gitea/gitea-mirror.git
synced 2026-03-20 03:40:27 +00:00
Improve timeline entries for WIP prefix changes in pull requests (#36518)
Add new timeline event types when the WIP prefix is added or removed, replacing the previous ugly title change messages. Fixes: https://github.com/go-gitea/gitea/issues/36517 --------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -658,12 +658,18 @@ func (pr *PullRequest) IsWorkInProgress(ctx context.Context) bool {
|
||||
|
||||
// HasWorkInProgressPrefix determines if the given PR title has a Work In Progress prefix
|
||||
func HasWorkInProgressPrefix(title string) bool {
|
||||
_, ok := CutWorkInProgressPrefix(title)
|
||||
return ok
|
||||
}
|
||||
|
||||
func CutWorkInProgressPrefix(title string) (origTitle string, ok bool) {
|
||||
for _, prefix := range setting.Repository.PullRequest.WorkInProgressPrefixes {
|
||||
if strings.HasPrefix(strings.ToUpper(title), strings.ToUpper(prefix)) {
|
||||
return true
|
||||
prefixLen := len(prefix)
|
||||
if prefixLen <= len(title) && util.AsciiEqualFold(title[:prefixLen], prefix) {
|
||||
return title[len(prefix):], true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return title, false
|
||||
}
|
||||
|
||||
// IsFilesConflicted determines if the Pull Request has changes conflicting with the target branch.
|
||||
|
||||
Reference in New Issue
Block a user