From 7073cee8b3eea00d330cb9ebb4657accef2e5e32 Mon Sep 17 00:00:00 2001 From: hypervtechnics Date: Thu, 7 Apr 2022 11:12:14 +0200 Subject: [PATCH] refactor: revert "make handling with unconventional commits configurable" issue: #45 --- README.md | 1 - cmd/git-sv/config.go | 1 - cmd/git-sv/main.go | 2 +- sv/config.go | 1 - sv/git.go | 20 +++++++------------- 5 files changed, 8 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 502504b..726d651 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,6 @@ branches: # Git branches config. commit-message: types: [build, ci, chore, docs, feat, fix, perf, refactor, revert, style, test] # Supported commit types. header-selector: '' # You can put in a regex here to select only a certain part of the commit message. Please define a regex group 'header'. - skip-unconventional: false # Allows to skip commits that do not comply with conventional commits. Otherwise those will cause errors. scope: # Define supported scopes, if blank, scope will not be validated, if not, only scope listed will be valid. # Don't forget to add "" on your list if you need to define scopes and keep it optional. diff --git a/cmd/git-sv/config.go b/cmd/git-sv/config.go index b7a2f17..04fc14b 100644 --- a/cmd/git-sv/config.go +++ b/cmd/git-sv/config.go @@ -103,7 +103,6 @@ func defaultConfig() Config { }, Issue: sv.CommitMessageIssueConfig{Regex: "[A-Z]+-[0-9]+"}, HeaderSelector: "", - SkipUnconventional: false, }, } } diff --git a/cmd/git-sv/main.go b/cmd/git-sv/main.go index 56e1055..b2a4a02 100644 --- a/cmd/git-sv/main.go +++ b/cmd/git-sv/main.go @@ -43,7 +43,7 @@ func main() { cfg := loadCfg(repoPath) messageProcessor := sv.NewMessageProcessor(cfg.CommitMessage, cfg.Branches) - git := sv.NewGit(messageProcessor, cfg.Tag, cfg.CommitMessage) + git := sv.NewGit(messageProcessor, cfg.Tag) semverProcessor := sv.NewSemVerCommitsProcessor(cfg.Versioning, cfg.CommitMessage) releasenotesProcessor := sv.NewReleaseNoteProcessor(cfg.ReleaseNotes) outputFormatter := sv.NewOutputFormatter(templateFS(filepath.Join(repoPath, configDir, "templates"))) diff --git a/sv/config.go b/sv/config.go index 617d84b..264755b 100644 --- a/sv/config.go +++ b/sv/config.go @@ -9,7 +9,6 @@ type CommitMessageConfig struct { Scope CommitMessageScopeConfig `yaml:"scope"` Footer map[string]CommitMessageFooterConfig `yaml:"footer"` Issue CommitMessageIssueConfig `yaml:"issue"` - SkipUnconventional bool `yaml:"skip-unconventional"` } // IssueFooterConfig config for issue. diff --git a/sv/git.go b/sv/git.go index 0ee0a5f..70605e7 100644 --- a/sv/git.go +++ b/sv/git.go @@ -71,15 +71,13 @@ func NewLogRange(t LogRangeType, start, end string) LogRange { type GitImpl struct { messageProcessor MessageProcessor tagCfg TagConfig - messageCfg CommitMessageConfig } // NewGit constructor. -func NewGit(messageProcessor MessageProcessor, tagCfg TagConfig, messageCfg CommitMessageConfig) *GitImpl { +func NewGit(messageProcessor MessageProcessor, cfg TagConfig) *GitImpl { return &GitImpl{ messageProcessor: messageProcessor, - tagCfg: tagCfg, - messageCfg: messageCfg, + tagCfg: cfg, } } @@ -116,13 +114,10 @@ func (g GitImpl) Log(lr LogRange) ([]GitCommitLog, error) { if err != nil { return nil, combinedOutputErr(err, out) } - - logs, parseErr := g.parseLogOutput(g.messageProcessor, string(out)) - + logs, parseErr := parseLogOutput(g.messageProcessor, string(out)) if parseErr != nil { return nil, parseErr } - return logs, nil } @@ -197,18 +192,17 @@ func parseTagsOutput(input string) ([]GitTag, error) { return result, nil } -func (g GitImpl) parseLogOutput(messageProcessor MessageProcessor, log string) ([]GitCommitLog, error) { +func parseLogOutput(messageProcessor MessageProcessor, log string) ([]GitCommitLog, error) { 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 != "" { log, err := parseCommitLog(messageProcessor, text) - if err == nil { - logs = append(logs, log) - } else if !g.messageCfg.SkipUnconventional { - return logs, err + if err != nil { + return nil, err } + logs = append(logs, log) } } return logs, nil