mirror of
https://github.com/thegeeklab/git-sv.git
synced 2024-11-24 11:10:39 +00:00
parent
81c97c21ba
commit
4a15a659d9
@ -83,7 +83,7 @@ func (p MessageProcessorImpl) Validate(message string) error {
|
|||||||
subject, body := splitCommitMessageContent(message)
|
subject, body := splitCommitMessageContent(message)
|
||||||
msg, parseErr := p.Parse(subject, body)
|
msg, parseErr := p.Parse(subject, body)
|
||||||
|
|
||||||
if (parseErr != nil) {
|
if parseErr != nil {
|
||||||
return parseErr
|
return parseErr
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,9 +205,14 @@ func (p MessageProcessorImpl) Format(msg CommitMessage) (string, string, string)
|
|||||||
return header.String(), msg.Body, footer.String()
|
return header.String(), msg.Body, footer.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func removeCarriage(commit string) string {
|
||||||
|
return regexp.MustCompile(`\r`).ReplaceAllString(commit, "")
|
||||||
|
}
|
||||||
|
|
||||||
// Parse a commit message.
|
// Parse a commit message.
|
||||||
func (p MessageProcessorImpl) Parse(subject, body string) (CommitMessage, error) {
|
func (p MessageProcessorImpl) Parse(subject, body string) (CommitMessage, error) {
|
||||||
preparedSubject, err := p.prepareHeader(subject)
|
preparedSubject, err := p.prepareHeader(subject)
|
||||||
|
commitBody := removeCarriage(body)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return CommitMessage{}, err
|
return CommitMessage{}, err
|
||||||
@ -220,14 +225,14 @@ func (p MessageProcessorImpl) Parse(subject, body string) (CommitMessage, error)
|
|||||||
if mdCfg.Key != "" {
|
if mdCfg.Key != "" {
|
||||||
prefixes := append([]string{mdCfg.Key}, mdCfg.KeySynonyms...)
|
prefixes := append([]string{mdCfg.Key}, mdCfg.KeySynonyms...)
|
||||||
for _, prefix := range prefixes {
|
for _, prefix := range prefixes {
|
||||||
if tagValue := extractFooterMetadata(prefix, body, mdCfg.UseHash); tagValue != "" {
|
if tagValue := extractFooterMetadata(prefix, commitBody, mdCfg.UseHash); tagValue != "" {
|
||||||
metadata[key] = tagValue
|
metadata[key] = tagValue
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if tagValue := extractFooterMetadata(breakingChangeFooterKey, body, false); tagValue != "" {
|
if tagValue := extractFooterMetadata(breakingChangeFooterKey, commitBody, false); tagValue != "" {
|
||||||
metadata[breakingChangeMetadataKey] = tagValue
|
metadata[breakingChangeMetadataKey] = tagValue
|
||||||
hasBreakingChange = true
|
hasBreakingChange = true
|
||||||
}
|
}
|
||||||
@ -236,7 +241,7 @@ func (p MessageProcessorImpl) Parse(subject, body string) (CommitMessage, error)
|
|||||||
Type: commitType,
|
Type: commitType,
|
||||||
Scope: scope,
|
Scope: scope,
|
||||||
Description: description,
|
Description: description,
|
||||||
Body: body,
|
Body: commitBody,
|
||||||
IsBreakingChange: hasBreakingChange,
|
IsBreakingChange: hasBreakingChange,
|
||||||
Metadata: metadata,
|
Metadata: metadata,
|
||||||
}, nil
|
}, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user