diff --git a/cmd/git-sv/main.go b/cmd/git-sv/main.go index b1ad572..4b93359 100644 --- a/cmd/git-sv/main.go +++ b/cmd/git-sv/main.go @@ -27,7 +27,7 @@ func main() { } //// - git := sv.NewGit(sv.NewCommitMessageParser(commitMessageCfg), cfg.TagPattern) + git := sv.NewGit(sv.NewCommitMessageProcessor(commitMessageCfg), cfg.TagPattern) semverProcessor := sv.NewSemVerCommitsProcessor(cfg.IncludeUnknownTypeAsPatch, cfg.MajorVersionTypes, cfg.MinorVersionTypes, cfg.PatchVersionTypes) releasenotesProcessor := sv.NewReleaseNoteProcessor(cfg.ReleaseNotesTags) outputFormatter := sv.NewOutputFormatter() diff --git a/sv/conventional_commit.go b/sv/conventional_commit.go index 43439a1..f15e6a8 100644 --- a/sv/conventional_commit.go +++ b/sv/conventional_commit.go @@ -52,23 +52,23 @@ func (m CommitMessage) BreakingMessage() string { return m.Metadata[breakingKey] } -// CommitMessageParser parse commit messages. -type CommitMessageParser interface { +// CommitMessageProcessor parse commit messages. +type CommitMessageProcessor interface { Parse(subject, body string) CommitMessage } -// CommitMessageParserImpl commit message parser implementation -type CommitMessageParserImpl struct { +// CommitMessageProcessorImpl commit message processor implementation +type CommitMessageProcessorImpl struct { cfg CommitMessageConfig } -// NewCommitMessageParser CommitMessageParserImpl constructor -func NewCommitMessageParser(cfg CommitMessageConfig) CommitMessageParser { - return &CommitMessageParserImpl{cfg: cfg} +// NewCommitMessageProcessor CommitMessageProcessorImpl constructor +func NewCommitMessageProcessor(cfg CommitMessageConfig) CommitMessageProcessor { + return &CommitMessageProcessorImpl{cfg: cfg} } // Parse parse a commit message -func (p CommitMessageParserImpl) Parse(subject, body string) CommitMessage { +func (p CommitMessageProcessorImpl) Parse(subject, body string) CommitMessage { commitType, scope, description, hasBreakingChange := parseSubjectMessage(subject) metadata := make(map[string]string) diff --git a/sv/conventional_commit_test.go b/sv/conventional_commit_test.go index ac11881..da87580 100644 --- a/sv/conventional_commit_test.go +++ b/sv/conventional_commit_test.go @@ -33,7 +33,7 @@ var hashMetadataBody = `some descriptions Jira: JIRA-999 Refs #123` -func TestCommitMessageParserImpl_Parse(t *testing.T) { +func TestCommitMessageProcessorImpl_Parse(t *testing.T) { tests := []struct { name string subject string @@ -51,9 +51,9 @@ func TestCommitMessageParserImpl_Parse(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - p := NewCommitMessageParser(cfg) + p := NewCommitMessageProcessor(cfg) if got := p.Parse(tt.subject, tt.body); !reflect.DeepEqual(got, tt.want) { - t.Errorf("CommitMessageParserImpl.Parse() = %v, want %v", got, tt.want) + t.Errorf("CommitMessageProcessorImpl.Parse() = %v, want %v", got, tt.want) } }) } diff --git a/sv/git.go b/sv/git.go index 41794ea..bffcbe9 100644 --- a/sv/git.go +++ b/sv/git.go @@ -64,15 +64,15 @@ func NewLogRange(t LogRangeType, start, end string) LogRange { // GitImpl git command implementation type GitImpl struct { - messageParser CommitMessageParser - tagPattern string + messageProcessor CommitMessageProcessor + tagPattern string } // NewGit constructor -func NewGit(messageParser CommitMessageParser, tagPattern string) *GitImpl { +func NewGit(messageProcessor CommitMessageProcessor, tagPattern string) *GitImpl { return &GitImpl{ - messageParser: messageParser, - tagPattern: tagPattern, + messageProcessor: messageProcessor, + tagPattern: tagPattern, } } @@ -109,7 +109,7 @@ func (g GitImpl) Log(lr LogRange) ([]GitCommitLog, error) { if err != nil { return nil, combinedOutputErr(err, out) } - return parseLogOutput(g.messageParser, string(out)), nil + return parseLogOutput(g.messageProcessor, string(out)), nil } // Commit runs git commit @@ -167,25 +167,25 @@ func parseTagsOutput(input string) ([]GitTag, error) { return result, nil } -func parseLogOutput(messageParser CommitMessageParser, log string) []GitCommitLog { +func parseLogOutput(messageProcessor CommitMessageProcessor, log string) []GitCommitLog { scanner := bufio.NewScanner(strings.NewReader(log)) scanner.Split(splitAt([]byte(endLine))) var logs []GitCommitLog for scanner.Scan() { if text := strings.TrimSpace(strings.Trim(scanner.Text(), "\"")); text != "" { - logs = append(logs, parseCommitLog(messageParser, text)) + logs = append(logs, parseCommitLog(messageProcessor, text)) } } return logs } -func parseCommitLog(messageParser CommitMessageParser, commit string) GitCommitLog { +func parseCommitLog(messageProcessor CommitMessageProcessor, commit string) GitCommitLog { content := strings.Split(strings.Trim(commit, "\""), logSeparator) return GitCommitLog{ Date: content[0], Hash: content[1], - Message: messageParser.Parse(content[2], content[3]), + Message: messageProcessor.Parse(content[2], content[3]), } }