Skip to content

Commit

Permalink
trim whitespace from comments before parsing (#2287)
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicbarnes authored Jun 22, 2022
1 parent ff1094f commit 5da6962
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions server/events/comment_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 5 additions & 1 deletion server/events/comment_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 5da6962

Please sign in to comment.