Skip to content

Commit

Permalink
fix: print an error message
Browse files Browse the repository at this point in the history
This PR adds in conditionals to send the proper message in the case of an error.

Signed-off-by: Andrew Rynhard <andrew@andrewrynhard.com>
  • Loading branch information
andrewrynhard committed Jul 5, 2019
1 parent 4716823 commit 3b208c1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/policy/commit/check_body.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ func (h Body) Name() string {

// Message returns to check message.
func (h Body) Message() string {
if len(h.errors) != 0 {
return h.errors[0].Error()
}
return "Commit body is valid"
}

Expand Down
3 changes: 3 additions & 0 deletions internal/policy/commit/check_number_of_commits.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ func (h NumberOfCommits) Name() string {

// Message returns to check message.
func (h NumberOfCommits) Message() string {
if len(h.errors) != 0 {
return h.errors[0].Error()
}
return fmt.Sprintf("HEAD is %d commit(s) ahead of %s", h.ahead, h.ref)
}

Expand Down

0 comments on commit 3b208c1

Please sign in to comment.