Skip to content

Commit

Permalink
Trim backticks from comments
Browse files Browse the repository at this point in the history
Signed-off-by: Clement Debiaune <[email protected]>
  • Loading branch information
Unibozu committed Jan 18, 2025
1 parent f3ed6c4 commit 7a936d9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions server/events/comment_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ type CommentParseResult struct {
// - atlantis import ADDRESS ID
func (e *CommentParser) Parse(rawComment string, vcsHost models.VCSHostType) CommentParseResult {
comment := strings.TrimSpace(rawComment)
// comment = strings.Trim(comment, "`")

if multiLineRegex.MatchString(comment) {
return CommentParseResult{Ignore: true}
Expand Down
27 changes: 27 additions & 0 deletions server/events/comment_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,33 @@ func TestParse_HelpResponse(t *testing.T) {
}
}

func TestParse_TrimCommandString(t *testing.T) {
t.Log("commands should be trimmed of whitespace and backtick (helps with Gitlab copy/paste issues)")
allowCommandsCases := [][]command.Name{
command.AllCommentCommands,
{}, // empty case
}
helpComments := []string{
"`atlantis help`",
"` atlantis help `",
"`atlantis help` ",
" `atlantis help",
}
for _, allowCommandCase := range allowCommandsCases {
for _, c := range helpComments {
t.Run(fmt.Sprintf("%s with allow commands %v", c, allowCommandCase), func(t *testing.T) {
commentParser := events.CommentParser{
GithubUser: "github-user",
ExecutableName: "atlantis",
AllowCommands: allowCommandCase,
}
r := commentParser.Parse(c, models.Github)
Equals(t, commentParser.HelpComment(), r.CommentResponse)
})
}
}
}

func TestParse_UnusedArguments(t *testing.T) {
t.Log("if there are unused flags we return an error")
cases := []struct {
Expand Down

0 comments on commit 7a936d9

Please sign in to comment.