From c5643c3c0364ee8f1d0cc7bd7ae2c82f604ea78a Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Tue, 4 Aug 2015 21:51:54 -0700 Subject: [PATCH] Fix submit queue when there are multiple LGTMs --- contrib/submit-queue/github/github.go | 4 +- contrib/submit-queue/github/github_test.go | 54 ++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) 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()