From 4b7b903aac3671f839115f6240d4e12e5256e742 Mon Sep 17 00:00:00 2001 From: Andrew Rynhard Date: Thu, 11 Jan 2018 07:14:25 -0800 Subject: [PATCH] fix(policy): strip leading newline from commit message (#50) --- pkg/policy/conventionalcommit/conventionalcommit.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/policy/conventionalcommit/conventionalcommit.go b/pkg/policy/conventionalcommit/conventionalcommit.go index 4224163b..02d8c15d 100644 --- a/pkg/policy/conventionalcommit/conventionalcommit.go +++ b/pkg/policy/conventionalcommit/conventionalcommit.go @@ -104,7 +104,10 @@ func parseHeader(message string) []string { if err != nil { return nil } - header := strings.Split(message, "\n")[0] + // To circumvent any policy violation due to the leading \n that GitHub + // prefixes to the commit message on a squash merge, we remove it from the + // message. + header := strings.Split(strings.TrimPrefix(message, "\n"), "\n")[0] groups := re.FindStringSubmatch(header) return groups