From bd9ff099373e56cdd85aa4b42661698afa74b210 Mon Sep 17 00:00:00 2001
From: Kimmo Saari <kimmo.saari@worddive.com>
Date: Mon, 26 Oct 2020 11:50:16 +0200
Subject: [PATCH] fix: Moved the `!` after the scope

Accidentally added the `!` in the Regex before the Scope. Now it is moved to it's proper place, right after the scope and before the `: `
---
 pkg/analyzer/commit_analyzer.go      | 6 +++---
 pkg/analyzer/commit_analyzer_test.go | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/pkg/analyzer/commit_analyzer.go b/pkg/analyzer/commit_analyzer.go
index ec18659..cfc725e 100644
--- a/pkg/analyzer/commit_analyzer.go
+++ b/pkg/analyzer/commit_analyzer.go
@@ -8,7 +8,7 @@ import (
 )
 
 var CAVERSION = "dev"
-var commitPattern = regexp.MustCompile(`^(\w*)(!)?(?:\((.*)\))?\: (.*)$`)
+var commitPattern = regexp.MustCompile(`^(\w*)(?:\((.*)\))?(\!)?\: (.*)$`)
 var breakingPattern = regexp.MustCompile("BREAKING CHANGES?")
 
 type DefaultCommitAnalyzer struct{}
@@ -34,8 +34,8 @@ func (da *DefaultCommitAnalyzer) analyzeSingleCommit(rawCommit *semrel.RawCommit
 		return c
 	}
 	c.Type = strings.ToLower(found[0][1])
-	breakingChange := found[0][2]
-	c.Scope = found[0][3]
+	c.Scope = found[0][2]
+	breakingChange := found[0][3]
 	c.Message = found[0][4]
 
 	isMajorChange := breakingPattern.MatchString(rawCommit.RawMessage)
diff --git a/pkg/analyzer/commit_analyzer_test.go b/pkg/analyzer/commit_analyzer_test.go
index 74911d0..43ca160 100644
--- a/pkg/analyzer/commit_analyzer_test.go
+++ b/pkg/analyzer/commit_analyzer_test.go
@@ -71,9 +71,9 @@ func TestDefaultAnalyzer(t *testing.T) {
 			&semrel.Change{Major: true, Minor: false, Patch: false},
 		},
 		{
-			createRawCommit("g", "refactor!: drop support for Node 6\n\nBREAKING CHANGE: refactor to use JavaScript features not available in Node 6."),
+			createRawCommit("g", "refactor(parser)!: drop support for Node 6\n\nBREAKING CHANGE: refactor to use JavaScript features not available in Node 6."),
 			"refactor",
-			"",
+			"parser",
 			&semrel.Change{Major: true, Minor: false, Patch: false},
 		},
 		{
-- 
GitLab