trim whitespace from comments before parsing (#2287)

This commit is contained in:
Dominic Barnes
2022-06-22 11:34:12 -07:00
committed by GitHub
parent ff1094fa04
commit 5da69620cf
2 changed files with 9 additions and 3 deletions

View File

@@ -113,7 +113,9 @@ type CommentParseResult struct {
// - atlantis version
// - atlantis approve_policies
//
func (e *CommentParser) Parse(comment string, vcsHost models.VCSHostType) CommentParseResult {
func (e *CommentParser) Parse(rawComment string, vcsHost models.VCSHostType) CommentParseResult {
comment := strings.TrimSpace(rawComment)
if multiLineRegex.MatchString(comment) {
return CommentParseResult{Ignore: true}
}
@@ -427,7 +429,7 @@ var DidYouMeanAtlantisComment = "Did you mean to use `atlantis` instead of `terr
// `atlantis unlock` with flags.
var UnlockUsage = "`Usage of unlock:`\n\n ```cmake\n" +
`atlantis unlock
`atlantis unlock
Unlocks the entire PR and discards all plans in this PR.
Arguments or flags are not supported at the moment.

View File

@@ -280,6 +280,10 @@ func TestParse_Multiline(t *testing.T) {
"atlantis plan\n\n",
"atlantis plan\r\n",
"atlantis plan\r\n\r\n",
"\natlantis plan",
"\r\natlantis plan",
"\natlantis plan\n",
"\r\natlantis plan\r\n",
}
for _, comment := range comments {
t.Run(comment, func(t *testing.T) {
@@ -845,7 +849,7 @@ var ApprovePolicyUsage = `Usage of approve_policies:
--verbose Append Atlantis log to comment.
`
var UnlockUsage = "`Usage of unlock:`\n\n ```cmake\n" +
`atlantis unlock
`atlantis unlock
Unlocks the entire PR and discards all plans in this PR.
Arguments or flags are not supported at the moment.