-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: check empty commit-msg prior to parsing (#118)
Signed-off-by: Don Bowman <[email protected]>
- Loading branch information
1 parent
1473b44
commit 37e0e69
Showing
2 changed files
with
51 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,33 @@ func TestInvalidConventionalCommitPolicy(t *testing.T) { | |
} | ||
} | ||
|
||
func TestEmptyConventionalCommitPolicy(t *testing.T) { | ||
dir, err := ioutil.TempDir("", "test") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
defer RemoveAll(dir) | ||
err = os.Chdir(dir) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
err = initRepo() | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
err = createEmptyCommit() | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
report, err := runCompliance() | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
if report.Valid() { | ||
t.Error("Report is valid with invalid conventional commit") | ||
} | ||
} | ||
|
||
func runCompliance() (*policy.Report, error) { | ||
c := &Commit{ | ||
Conventional: &Conventional{ | ||
|
@@ -113,3 +140,9 @@ func createInvalidCommit() error { | |
|
||
return err | ||
} | ||
|
||
func createEmptyCommit() error { | ||
_, err := exec.Command("git", "-c", "user.name='test'", "-c", "user.email='[email protected]'", "commit", "--allow-empty-message", "-m", "").Output() | ||
|
||
return err | ||
} |