mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-08-03 15:08:49 +00:00
Fix body string check
This commit is contained in:
@@ -159,7 +159,8 @@ func (g *GithubClient) HideOldComments(repo models.Repo, pullNum int) error {
|
||||
// a reasonable one, given we've already filtered the comments by the
|
||||
// configured Atlantis user.
|
||||
body := strings.Split(comment.GetBody(), "\n")
|
||||
if !strings.Contains(body[0], models.ApplyCommand.String()) {
|
||||
firstLine := strings.ToLower(body[0])
|
||||
if !strings.Contains(firstLine, models.PlanCommand.String()) {
|
||||
continue
|
||||
}
|
||||
var m struct {
|
||||
|
||||
@@ -137,14 +137,14 @@ func TestGithubClient_GetModifiedFilesMovedFile(t *testing.T) {
|
||||
|
||||
func TestGithubClient_HideOldComments(t *testing.T) {
|
||||
// Only comment 6 should be minimized, because it's by the same Atlantis bot user
|
||||
// and it has "apply" in the first line of the comment body.
|
||||
// and it has "plan" in the first line of the comment body.
|
||||
issueResp := `[
|
||||
{"node_id": "1", "body": "asd\napply\nasd", "user": {"login": "someone-else"}},
|
||||
{"node_id": "2", "body": "asd apply\nasd", "user": {"login": "someone-else"}},
|
||||
{"node_id": "1", "body": "asd\nplan\nasd", "user": {"login": "someone-else"}},
|
||||
{"node_id": "2", "body": "asd plan\nasd", "user": {"login": "someone-else"}},
|
||||
{"node_id": "3", "body": "asdasdasd\nasdasdasd", "user": {"login": "someone-else"}},
|
||||
{"node_id": "4", "body": "asdasdasd\nasdasdasd", "user": {"login": "user"}},
|
||||
{"node_id": "5", "body": "asd\napply\nasd", "user": {"login": "user"}},
|
||||
{"node_id": "6", "body": "asd apply\nasd", "user": {"login": "user"}},
|
||||
{"node_id": "5", "body": "asd\nplan\nasd", "user": {"login": "user"}},
|
||||
{"node_id": "6", "body": "asd plan\nasd", "user": {"login": "user"}},
|
||||
{"node_id": "7", "body": "asdasdasd", "user": {"login": "user"}}
|
||||
]`
|
||||
minimizeResp := "{}"
|
||||
|
||||
Reference in New Issue
Block a user