Skip to content

Commit 9a56bb9

Browse files
authored
Revert "Return all open PRs instead of filtering by date" (#5)
* Revert "fix up cherry-pick to pass tests" This reverts commit e7c80e8. * Revert "Close #26: Return all open PRs instead of filtering by date" This reverts commit fd89b79.
1 parent b992455 commit 9a56bb9

File tree

3 files changed

+19
-70
lines changed

3 files changed

+19
-70
lines changed

check.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ Loop:
6969
}
7070
}
7171

72+
// Filter out commits that are too old.
73+
if !versionTime.After(request.Version.CommittedDate) {
74+
continue
75+
}
76+
7277
// Filter out pull request if it does not contain at least one of the desired labels
7378
if len(request.Source.Labels) > 0 {
7479
labelFound := false

check_test.go

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func TestCheck(t *testing.T) {
6464
},
6565

6666
{
67-
description: "check returns all open PRs if there is a previous",
67+
description: "check returns the previous version when its still latest",
6868
source: resource.Source{
6969
Repository: "itsdalmo/test-repository",
7070
AccessToken: "oauthtoken",
@@ -73,17 +73,6 @@ func TestCheck(t *testing.T) {
7373
pullRequests: testPullRequests,
7474
files: [][]string{},
7575
expected: resource.CheckResponse{
76-
resource.NewVersion(testPullRequests[14], testPullRequests[14].Tip.CommittedDate.Time),
77-
resource.NewVersion(testPullRequests[13], testPullRequests[13].Tip.CommittedDate.Time),
78-
resource.NewVersion(testPullRequests[12], testPullRequests[12].Tip.CommittedDate.Time),
79-
resource.NewVersion(testPullRequests[11], testPullRequests[11].Tip.CommittedDate.Time),
80-
resource.NewVersion(testPullRequests[8], testPullRequests[8].Tip.CommittedDate.Time),
81-
resource.NewVersion(testPullRequests[7], testPullRequests[7].Tip.CommittedDate.Time),
82-
resource.NewVersion(testPullRequests[6], testPullRequests[6].Tip.CommittedDate.Time),
83-
resource.NewVersion(testPullRequests[5], testPullRequests[5].Tip.CommittedDate.Time),
84-
resource.NewVersion(testPullRequests[4], testPullRequests[4].Tip.CommittedDate.Time),
85-
resource.NewVersion(testPullRequests[3], testPullRequests[3].Tip.CommittedDate.Time),
86-
resource.NewVersion(testPullRequests[2], testPullRequests[2].Tip.CommittedDate.Time),
8776
resource.NewVersion(testPullRequests[1], testPullRequests[1].Tip.CommittedDate.Time),
8877
},
8978
},
@@ -98,16 +87,6 @@ func TestCheck(t *testing.T) {
9887
pullRequests: testPullRequests,
9988
files: [][]string{},
10089
expected: resource.CheckResponse{
101-
resource.NewVersion(testPullRequests[14], testPullRequests[14].Tip.CommittedDate.Time),
102-
resource.NewVersion(testPullRequests[13], testPullRequests[13].Tip.CommittedDate.Time),
103-
resource.NewVersion(testPullRequests[12], testPullRequests[12].Tip.CommittedDate.Time),
104-
resource.NewVersion(testPullRequests[11], testPullRequests[11].Tip.CommittedDate.Time),
105-
resource.NewVersion(testPullRequests[8], testPullRequests[8].Tip.CommittedDate.Time),
106-
resource.NewVersion(testPullRequests[7], testPullRequests[7].Tip.CommittedDate.Time),
107-
resource.NewVersion(testPullRequests[6], testPullRequests[6].Tip.CommittedDate.Time),
108-
resource.NewVersion(testPullRequests[5], testPullRequests[5].Tip.CommittedDate.Time),
109-
resource.NewVersion(testPullRequests[4], testPullRequests[4].Tip.CommittedDate.Time),
110-
resource.NewVersion(testPullRequests[3], testPullRequests[3].Tip.CommittedDate.Time),
11190
resource.NewVersion(testPullRequests[2], testPullRequests[2].Tip.CommittedDate.Time),
11291
resource.NewVersion(testPullRequests[1], testPullRequests[1].Tip.CommittedDate.Time),
11392
},
@@ -128,7 +107,6 @@ func TestCheck(t *testing.T) {
128107
{"terraform/modules/variables.tf", "travis.yml"},
129108
},
130109
expected: resource.CheckResponse{
131-
resource.NewVersion(testPullRequests[3], testPullRequests[3].Tip.CommittedDate.Time),
132110
resource.NewVersion(testPullRequests[2], testPullRequests[2].Tip.CommittedDate.Time),
133111
},
134112
},
@@ -148,7 +126,6 @@ func TestCheck(t *testing.T) {
148126
{"terraform/modules/variables.tf", "travis.yml"},
149127
},
150128
expected: resource.CheckResponse{
151-
resource.NewVersion(testPullRequests[3], testPullRequests[3].Tip.CommittedDate.Time),
152129
resource.NewVersion(testPullRequests[2], testPullRequests[2].Tip.CommittedDate.Time),
153130
},
154131
},
@@ -163,18 +140,6 @@ func TestCheck(t *testing.T) {
163140
version: resource.NewVersion(testPullRequests[1], testPullRequests[1].Tip.CommittedDate.Time),
164141
pullRequests: testPullRequests,
165142
expected: resource.CheckResponse{
166-
resource.NewVersion(testPullRequests[14], testPullRequests[14].Tip.CommittedDate.Time),
167-
resource.NewVersion(testPullRequests[13], testPullRequests[13].Tip.CommittedDate.Time),
168-
resource.NewVersion(testPullRequests[12], testPullRequests[12].Tip.CommittedDate.Time),
169-
resource.NewVersion(testPullRequests[11], testPullRequests[11].Tip.CommittedDate.Time),
170-
resource.NewVersion(testPullRequests[8], testPullRequests[8].Tip.CommittedDate.Time),
171-
resource.NewVersion(testPullRequests[7], testPullRequests[7].Tip.CommittedDate.Time),
172-
resource.NewVersion(testPullRequests[6], testPullRequests[6].Tip.CommittedDate.Time),
173-
resource.NewVersion(testPullRequests[5], testPullRequests[5].Tip.CommittedDate.Time),
174-
resource.NewVersion(testPullRequests[4], testPullRequests[4].Tip.CommittedDate.Time),
175-
resource.NewVersion(testPullRequests[3], testPullRequests[3].Tip.CommittedDate.Time),
176-
resource.NewVersion(testPullRequests[2], testPullRequests[2].Tip.CommittedDate.Time),
177-
resource.NewVersion(testPullRequests[1], testPullRequests[1].Tip.CommittedDate.Time),
178143
resource.NewVersion(testPullRequests[0], testPullRequests[0].Tip.CommittedDate.Time),
179144
},
180145
},
@@ -189,16 +154,6 @@ func TestCheck(t *testing.T) {
189154
version: resource.NewVersion(testPullRequests[3], testPullRequests[3].Tip.CommittedDate.Time),
190155
pullRequests: testPullRequests,
191156
expected: resource.CheckResponse{
192-
resource.NewVersion(testPullRequests[14], testPullRequests[14].Tip.CommittedDate.Time),
193-
resource.NewVersion(testPullRequests[13], testPullRequests[13].Tip.CommittedDate.Time),
194-
resource.NewVersion(testPullRequests[12], testPullRequests[12].Tip.CommittedDate.Time),
195-
resource.NewVersion(testPullRequests[11], testPullRequests[11].Tip.CommittedDate.Time),
196-
resource.NewVersion(testPullRequests[8], testPullRequests[8].Tip.CommittedDate.Time),
197-
resource.NewVersion(testPullRequests[7], testPullRequests[7].Tip.CommittedDate.Time),
198-
resource.NewVersion(testPullRequests[6], testPullRequests[6].Tip.CommittedDate.Time),
199-
resource.NewVersion(testPullRequests[5], testPullRequests[5].Tip.CommittedDate.Time),
200-
resource.NewVersion(testPullRequests[4], testPullRequests[4].Tip.CommittedDate.Time),
201-
resource.NewVersion(testPullRequests[3], testPullRequests[3].Tip.CommittedDate.Time),
202157
resource.NewVersion(testPullRequests[1], testPullRequests[1].Tip.CommittedDate.Time),
203158
},
204159
},
@@ -213,16 +168,6 @@ func TestCheck(t *testing.T) {
213168
version: resource.NewVersion(testPullRequests[3], testPullRequests[3].Tip.CommittedDate.Time),
214169
pullRequests: testPullRequests,
215170
expected: resource.CheckResponse{
216-
resource.NewVersion(testPullRequests[14], testPullRequests[14].Tip.CommittedDate.Time),
217-
resource.NewVersion(testPullRequests[13], testPullRequests[13].Tip.CommittedDate.Time),
218-
resource.NewVersion(testPullRequests[12], testPullRequests[12].Tip.CommittedDate.Time),
219-
resource.NewVersion(testPullRequests[11], testPullRequests[11].Tip.CommittedDate.Time),
220-
resource.NewVersion(testPullRequests[8], testPullRequests[8].Tip.CommittedDate.Time),
221-
resource.NewVersion(testPullRequests[7], testPullRequests[7].Tip.CommittedDate.Time),
222-
resource.NewVersion(testPullRequests[6], testPullRequests[6].Tip.CommittedDate.Time),
223-
resource.NewVersion(testPullRequests[5], testPullRequests[5].Tip.CommittedDate.Time),
224-
resource.NewVersion(testPullRequests[4], testPullRequests[4].Tip.CommittedDate.Time),
225-
resource.NewVersion(testPullRequests[3], testPullRequests[3].Tip.CommittedDate.Time),
226171
resource.NewVersion(testPullRequests[2], testPullRequests[2].Tip.CommittedDate.Time),
227172
resource.NewVersion(testPullRequests[1], testPullRequests[1].Tip.CommittedDate.Time),
228173
},
@@ -238,14 +183,6 @@ func TestCheck(t *testing.T) {
238183
version: resource.NewVersion(testPullRequests[5], testPullRequests[5].Tip.CommittedDate.Time),
239184
pullRequests: testPullRequests,
240185
expected: resource.CheckResponse{
241-
resource.NewVersion(testPullRequests[14], testPullRequests[14].Tip.CommittedDate.Time),
242-
resource.NewVersion(testPullRequests[13], testPullRequests[13].Tip.CommittedDate.Time),
243-
resource.NewVersion(testPullRequests[12], testPullRequests[12].Tip.CommittedDate.Time),
244-
resource.NewVersion(testPullRequests[11], testPullRequests[11].Tip.CommittedDate.Time),
245-
resource.NewVersion(testPullRequests[8], testPullRequests[8].Tip.CommittedDate.Time),
246-
resource.NewVersion(testPullRequests[7], testPullRequests[7].Tip.CommittedDate.Time),
247-
resource.NewVersion(testPullRequests[6], testPullRequests[6].Tip.CommittedDate.Time),
248-
resource.NewVersion(testPullRequests[5], testPullRequests[5].Tip.CommittedDate.Time),
249186
resource.NewVersion(testPullRequests[3], testPullRequests[3].Tip.CommittedDate.Time),
250187
resource.NewVersion(testPullRequests[2], testPullRequests[2].Tip.CommittedDate.Time),
251188
resource.NewVersion(testPullRequests[1], testPullRequests[1].Tip.CommittedDate.Time),

e2e/e2e_test.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ import (
2424
)
2525

2626
var (
27-
firstCommitID = "23dc9f552bf989d1a4aeb65ce23351dee0ec9019"
28-
firstPullRequestID = "3"
29-
firstDateTime = time.Date(2018, time.May, 11, 7, 28, 56, 0, time.UTC)
3027
targetCommitID = "a5114f6ab89f4b736655642a11e8d15ce363d882"
3128
targetPullRequestID = "4"
3229
targetDateTime = time.Date(2018, time.May, 11, 8, 43, 48, 0, time.UTC)
@@ -58,15 +55,25 @@ func TestCheckE2E(t *testing.T) {
5855
},
5956

6057
{
61-
description: "check returns all open PRs if there is a previous version",
58+
description: "check returns the previous version when its still latest",
6259
source: resource.Source{
6360
Repository: "itsdalmo/test-repository",
6461
AccessToken: os.Getenv("GITHUB_ACCESS_TOKEN"),
6562
},
6663
version: resource.Version{PR: latestPullRequestID, Commit: latestCommitID, CommittedDate: latestDateTime},
6764
expected: resource.CheckResponse{
68-
resource.Version{PR: firstPullRequestID, Commit: firstCommitID, CommittedDate: firstDateTime},
69-
resource.Version{PR: targetPullRequestID, Commit: targetCommitID, CommittedDate: targetDateTime},
65+
resource.Version{PR: latestPullRequestID, Commit: latestCommitID, CommittedDate: latestDateTime},
66+
},
67+
},
68+
69+
{
70+
description: "check returns all new versions since the last",
71+
source: resource.Source{
72+
Repository: "itsdalmo/test-repository",
73+
AccessToken: os.Getenv("GITHUB_ACCESS_TOKEN"),
74+
},
75+
version: resource.Version{PR: targetPullRequestID, Commit: targetCommitID, CommittedDate: targetDateTime},
76+
expected: resource.CheckResponse{
7077
resource.Version{PR: latestPullRequestID, Commit: latestCommitID, CommittedDate: latestDateTime},
7178
},
7279
},

0 commit comments

Comments
 (0)