From 3b208c1f665672ce64673b7a89a159de67d99f85 Mon Sep 17 00:00:00 2001 From: Andrew Rynhard Date: Fri, 5 Jul 2019 00:27:41 +0000 Subject: [PATCH] fix: print an error message This PR adds in conditionals to send the proper message in the case of an error. Signed-off-by: Andrew Rynhard --- internal/policy/commit/check_body.go | 3 +++ internal/policy/commit/check_number_of_commits.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/internal/policy/commit/check_body.go b/internal/policy/commit/check_body.go index a462a319..0a69dec5 100644 --- a/internal/policy/commit/check_body.go +++ b/internal/policy/commit/check_body.go @@ -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" } diff --git a/internal/policy/commit/check_number_of_commits.go b/internal/policy/commit/check_number_of_commits.go index 3c98201d..2c5ff52f 100644 --- a/internal/policy/commit/check_number_of_commits.go +++ b/internal/policy/commit/check_number_of_commits.go @@ -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) }