Skip to content

Commit 418fd90

Browse files
Merge pull request #20 from NeowayLabs/fix-commit-lint-to-allow-merge-from-master
fix(commit-lint): Fix IsValidMessage method to skip commit lint when …
2 parents 4c031f7 + 273ca2a commit 418fd90

File tree

6 files changed

+34
-4
lines changed

6 files changed

+34
-4
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
v2.0.1:
2+
- Fix IsValidMessage method to skip commit lint when the message is a merge from master to a developer branch. (@esequiel.virtuoso)
3+
- Add chore option. (@esequiel.virtuoso)
4+
5+
v2.0.0:
6+
- Change semantic-release message pattern to 'type(scope?): message here'. (@esequiel.virtuoso)
7+
18
v1.0.5
29
- Fix isSetNewVersion function logic (@esequiel.virtuoso)
310

cmd/semantic-release/semantic-release.go

+1
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ func printCommitTypes() {
183183
fmt.Println(colorYellow + "\t* [refactor]" + colorReset + ": A code change that neither fixes a bug nor adds a feature")
184184
fmt.Println(colorYellow + "\t* [style]" + colorReset + ": Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)")
185185
fmt.Println(colorYellow + "\t* [test]" + colorReset + ": Adding missing tests or correcting existing tests")
186+
fmt.Println(colorYellow + "\t* [chore]" + colorReset + ": No production code change. It won't release a new version.")
186187
fmt.Println(colorYellow + "\t* [skip]" + colorReset + ": Skip versioning")
187188
fmt.Println(colorYellow + "\t* [bc]" + colorReset + ": Changes that will require other changes in dependant applications")
188189
fmt.Println(colorYellow + "\t* [breaking]" + colorReset + ": ||")

src/commit-message/commit_message_manager.go

+15
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,22 @@ func (f *CommitMessage) PrettifyCommitMessage(commitMessage string) (string, err
7575
return f.upperFirstLetterOfSentence(message), nil
7676
}
7777

78+
func isMergeMasterToBranch(message string) bool {
79+
splitedMessage := strings.Split(strings.ToLower(message), "\n")
80+
81+
for _, row := range splitedMessage {
82+
if strings.Contains(row, "'origin/master' into") {
83+
return true
84+
}
85+
}
86+
return false
87+
}
88+
7889
func (f *CommitMessage) IsValidMessage(message string) bool {
90+
if isMergeMasterToBranch(message) {
91+
return true
92+
}
93+
7994
index := strings.Index(message, ":")
8095

8196
if f.commitType.IndexNotFound(index) {

src/commit-message/commit_message_manager_test.go

+7
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,10 @@ func TestIsValidMessageFalse(t *testing.T) {
9494
actual = f.commitMessageManager.IsValidMessage(message)
9595
tests.AssertFalse(t, actual)
9696
}
97+
98+
func TestIsValidMessageMergeMasterBranchSuccess(t *testing.T) {
99+
f := setup(t)
100+
message := "first message row \n Merge remote-tracking branch 'origin/master' into something \n last message row"
101+
actual := f.commitMessageManager.IsValidMessage(message)
102+
tests.AssertTrue(t, actual)
103+
}

src/commit-type/commit_type.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type CommitType struct {
1515
}
1616

1717
func (c *CommitType) GetAll() []string {
18-
return []string{"build", "ci", "docs", "fix", "feat", "feature", "feature", "perf", "performance", "refactor", "style", "test", "bc", "breaking", "breaking change", "skip"}
18+
return []string{"build", "ci", "docs", "fix", "feat", "feature", "feature", "perf", "performance", "refactor", "style", "test", "bc", "breaking", "breaking change", "chore", "skip"}
1919
}
2020

2121
func (c *CommitType) GetMajorUpgrade() []string {
@@ -31,7 +31,7 @@ func (c *CommitType) GetPatchUpgrade() []string {
3131
}
3232

3333
func (c *CommitType) GetSkipVersioning() []string {
34-
return []string{"skip"}
34+
return []string{"skip", "chore"}
3535
}
3636

3737
func (c *CommitType) isValidCommitType(commitTypeScope string) bool {

src/commit-type/commit_type_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func setup(t *testing.T) *fixture {
2727

2828
func TestGetAll(t *testing.T) {
2929
f := setup(t)
30-
expected := []string{"build", "ci", "docs", "fix", "feat", "feature", "feature", "perf", "performance", "refactor", "style", "test", "bc", "breaking", "breaking change", "skip"}
30+
expected := []string{"build", "ci", "docs", "fix", "feat", "feature", "feature", "perf", "performance", "refactor", "style", "test", "bc", "breaking", "breaking change", "chore", "skip"}
3131
actual := f.commitType.GetAll()
3232

3333
tests.AssertDeepEqualValues(t, expected, actual)
@@ -59,7 +59,7 @@ func TestGetPatchUpgrade(t *testing.T) {
5959

6060
func TestGetSkipVersioning(t *testing.T) {
6161
f := setup(t)
62-
expected := []string{"skip"}
62+
expected := []string{"skip", "chore"}
6363
actual := f.commitType.GetSkipVersioning()
6464

6565
tests.AssertDeepEqualValues(t, expected, actual)

0 commit comments

Comments
 (0)