0
0
mirror of https://github.com/thegeeklab/git-sv.git synced 2024-06-03 03:49:39 +02:00

refactor: do not extract issue from branch if branches.disable-issue is true or commit-message.issue.regex is empty

issue: #13
This commit is contained in:
Beatriz Vieira 2021-03-11 23:13:56 -03:00
parent 935e3fa8d0
commit 0ffaf44ba2

View File

@ -119,6 +119,10 @@ func (p MessageProcessorImpl) Enhance(branch string, message string) (string, er
// IssueID try to extract issue id from branch, return empty if not found.
func (p MessageProcessorImpl) IssueID(branch string) (string, error) {
if p.branchesCfg.DisableIssue || p.messageCfg.Issue.Regex == "" {
return "", nil
}
rstr := fmt.Sprintf("^%s(%s)%s$", p.branchesCfg.PrefixRegex, p.messageCfg.Issue.Regex, p.branchesCfg.SuffixRegex)
r, err := regexp.Compile(rstr)
if err != nil {
@ -146,7 +150,7 @@ func (p MessageProcessorImpl) Format(msg CommitMessage) (string, string, string)
if msg.BreakingMessage() != "" {
footer.WriteString(fmt.Sprintf("%s: %s", breakingChangeFooterKey, msg.BreakingMessage()))
}
if issue, exists := msg.Metadata[issueMetadataKey]; exists {
if issue, exists := msg.Metadata[issueMetadataKey]; exists && p.messageCfg.IssueFooterConfig().Key != "" {
if footer.Len() > 0 {
footer.WriteString("\n")
}