diff --git a/contrib/submit-queue/github/github.go b/contrib/submit-queue/github/github.go index f1a4d88f18f..5a84a1aaa78 100644 --- a/contrib/submit-queue/github/github.go +++ b/contrib/submit-queue/github/github.go @@ -111,7 +111,9 @@ func validateLGTMAfterPush(client *github.Client, user, project string, pr *gith for ix := range events { event := &events[ix] if *event.Event == "labeled" && *event.Label.Name == "lgtm" { - lgtmTime = event.CreatedAt + if lgtmTime == nil || event.CreatedAt.After(*lgtmTime) { + lgtmTime = event.CreatedAt + } } } if lgtmTime == nil { diff --git a/contrib/submit-queue/github/github_test.go b/contrib/submit-queue/github/github_test.go index f0c8b759992..84396b7e23c 100644 --- a/contrib/submit-queue/github/github_test.go +++ b/contrib/submit-queue/github/github_test.go @@ -424,6 +424,60 @@ func TestValidateLGTMAfterPush(t *testing.T) { lastModified: time.Unix(11, 0), shouldPass: false, }, + { + issueEvents: []github.IssueEvent{ + { + Event: stringPtr("labeled"), + Label: &github.Label{ + Name: stringPtr("lgtm"), + }, + CreatedAt: timePtr(time.Unix(12, 0)), + }, + { + Event: stringPtr("labeled"), + Label: &github.Label{ + Name: stringPtr("lgtm"), + }, + CreatedAt: timePtr(time.Unix(11, 0)), + }, + { + Event: stringPtr("labeled"), + Label: &github.Label{ + Name: stringPtr("lgtm"), + }, + CreatedAt: timePtr(time.Unix(10, 0)), + }, + }, + lastModified: time.Unix(11, 0), + shouldPass: true, + }, + { + issueEvents: []github.IssueEvent{ + { + Event: stringPtr("labeled"), + Label: &github.Label{ + Name: stringPtr("lgtm"), + }, + CreatedAt: timePtr(time.Unix(10, 0)), + }, + { + Event: stringPtr("labeled"), + Label: &github.Label{ + Name: stringPtr("lgtm"), + }, + CreatedAt: timePtr(time.Unix(11, 0)), + }, + { + Event: stringPtr("labeled"), + Label: &github.Label{ + Name: stringPtr("lgtm"), + }, + CreatedAt: timePtr(time.Unix(12, 0)), + }, + }, + lastModified: time.Unix(11, 0), + shouldPass: true, + }, } for _, test := range tests { client, server, mux := initTest()