0
0
mirror of https://github.com/thegeeklab/git-sv.git synced 2024-11-28 06:30:35 +00:00

refactor: merge breaking change key and tag

This commit is contained in:
Beatriz Vieira 2020-02-01 21:15:12 -03:00
parent 2cd32e3ed3
commit e18b0cc08f
3 changed files with 10 additions and 10 deletions

View File

@ -15,8 +15,11 @@ import (
const ( const (
logSeparator = "##" logSeparator = "##"
endLine = "~~" endLine = "~~"
breakingChangesKey = "breakingchange"
issueIDKey = "issueid" // BreakingChangesKey key to breaking change metadata
BreakingChangesKey = "breakingchange"
// IssueIDKey key to issue id metadata
IssueIDKey = "issueid"
) )
// Git commands // Git commands
@ -52,7 +55,7 @@ type GitImpl struct {
// NewGit constructor // NewGit constructor
func NewGit(breakinChangePrefixes, issueIDPrefixes []string, tagPattern string) *GitImpl { func NewGit(breakinChangePrefixes, issueIDPrefixes []string, tagPattern string) *GitImpl {
return &GitImpl{ return &GitImpl{
messageMetadata: map[string][]string{breakingChangesKey: breakinChangePrefixes, issueIDKey: issueIDPrefixes}, messageMetadata: map[string][]string{BreakingChangesKey: breakinChangePrefixes, IssueIDKey: issueIDPrefixes},
tagPattern: tagPattern, tagPattern: tagPattern,
} }
} }

View File

@ -62,7 +62,7 @@ func (p ReleaseNoteProcessorImpl) Create(version semver.Version, date time.Time,
section.Items = append(section.Items, commit) section.Items = append(section.Items, commit)
sections[commit.Type] = section sections[commit.Type] = section
} }
if value, exists := commit.Metadata[BreakingChangeTag]; exists { if value, exists := commit.Metadata[BreakingChangesKey]; exists {
breakingChanges = append(breakingChanges, value) breakingChanges = append(breakingChanges, value)
} }
} }

View File

@ -24,9 +24,6 @@ func ToVersion(value string) (semver.Version, error) {
return *v, nil return *v, nil
} }
// BreakingChangeTag breaking change tag from commit metadata
const BreakingChangeTag string = "breakingchange"
// SemVerCommitsProcessor interface // SemVerCommitsProcessor interface
type SemVerCommitsProcessor interface { type SemVerCommitsProcessor interface {
NextVersion(version semver.Version, commits []GitCommitLog) semver.Version NextVersion(version semver.Version, commits []GitCommitLog) semver.Version
@ -72,7 +69,7 @@ func (p SemVerCommitsProcessorImpl) NextVersion(version semver.Version, commits
} }
func (p SemVerCommitsProcessorImpl) versionTypeToUpdate(commit GitCommitLog) versionType { func (p SemVerCommitsProcessorImpl) versionTypeToUpdate(commit GitCommitLog) versionType {
if _, exists := commit.Metadata[BreakingChangeTag]; exists { if _, exists := commit.Metadata[BreakingChangesKey]; exists {
return major return major
} }
if _, exists := p.MajorVersionTypes[commit.Type]; exists { if _, exists := p.MajorVersionTypes[commit.Type]; exists {