From 0ffaf44ba279be0697692d4f5617e463e74f7df6 Mon Sep 17 00:00:00 2001 From: Beatriz Vieira Date: Thu, 11 Mar 2021 23:13:56 -0300 Subject: [PATCH] refactor: do not extract issue from branch if branches.disable-issue is true or commit-message.issue.regex is empty issue: #13 --- sv/message.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sv/message.go b/sv/message.go index 53fc2bc..02ed33c 100644 --- a/sv/message.go +++ b/sv/message.go @@ -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") }