mirror of
https://gitea.com/gitea/tea.git
synced 2024-06-03 10:11:22 +05:30
refactor: improve API usage and test robustness
- Extract the part after the last colon in the input string for `GetDefaultPRTitle` function Signed-off-by: appleboy <appleboy.tw@gmail.com>
This commit is contained in:
parent
6da66a0318
commit
a554c30e6c
|
@ -140,10 +140,17 @@ func GetHeadSpec(owner, branch, baseOwner string) string {
|
|||
|
||||
// GetDefaultPRTitle transforms a string like a branchname to a readable text
|
||||
func GetDefaultPRTitle(header string) string {
|
||||
// Extract the part after the last colon in the input string
|
||||
colonIndex := strings.LastIndex(header, ":")
|
||||
if colonIndex != -1 {
|
||||
header = header[colonIndex+1:]
|
||||
}
|
||||
|
||||
title := noSpace.ReplaceAllString(header, "")
|
||||
title = spaceRegex.ReplaceAllString(title, " ")
|
||||
title = strings.TrimSpace(title)
|
||||
title = strings.Title(strings.ToLower(title))
|
||||
title = consecutive.ReplaceAllString(title, " ")
|
||||
|
||||
return title
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue