Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions check.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Loop:
continue
}

versionTime := p.Tip.CommittedDate.Time
versionTime := p.Age()
if len(request.Source.StatusFilters) > 0 {
for _, statusFilter := range request.Source.StatusFilters {
// "zero time - epoch = 0"
Expand All @@ -70,7 +70,7 @@ Loop:
}

// Filter out commits that are too old.
if !versionTime.After(request.Version.CommittedDate) {
if !p.Age().After(request.Version.ChangedDate) {
continue
}

Expand Down Expand Up @@ -232,7 +232,7 @@ func (r CheckResponse) Len() int {
}

func (r CheckResponse) Less(i, j int) bool {
return r[j].CommittedDate.After(r[i].CommittedDate)
return r[j].ChangedDate.After(r[i].ChangedDate)
}

func (r CheckResponse) Swap(i, j int) {
Expand Down
66 changes: 33 additions & 33 deletions check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestCheck(t *testing.T) {
pullRequests: testPullRequests,
files: [][]string{},
expected: resource.CheckResponse{
resource.NewVersion(testPullRequests[1], testPullRequests[1].Tip.CommittedDate.Time),
resource.NewVersion(testPullRequests[1], testPullRequests[1].Tip.PushedDate.Time),
},
},

Expand All @@ -69,11 +69,11 @@ func TestCheck(t *testing.T) {
Repository: "itsdalmo/test-repository",
AccessToken: "oauthtoken",
},
version: resource.NewVersion(testPullRequests[1], testPullRequests[1].Tip.CommittedDate.Time),
version: resource.NewVersion(testPullRequests[1], testPullRequests[1].Tip.PushedDate.Time),
pullRequests: testPullRequests,
files: [][]string{},
expected: resource.CheckResponse{
resource.NewVersion(testPullRequests[1], testPullRequests[1].Tip.CommittedDate.Time),
resource.NewVersion(testPullRequests[1], testPullRequests[1].Tip.PushedDate.Time),
},
},

Expand All @@ -83,12 +83,12 @@ func TestCheck(t *testing.T) {
Repository: "itsdalmo/test-repository",
AccessToken: "oauthtoken",
},
version: resource.NewVersion(testPullRequests[3], testPullRequests[3].Tip.CommittedDate.Time),
version: resource.NewVersion(testPullRequests[3], testPullRequests[3].Tip.PushedDate.Time),
pullRequests: testPullRequests,
files: [][]string{},
expected: resource.CheckResponse{
resource.NewVersion(testPullRequests[2], testPullRequests[2].Tip.CommittedDate.Time),
resource.NewVersion(testPullRequests[1], testPullRequests[1].Tip.CommittedDate.Time),
resource.NewVersion(testPullRequests[2], testPullRequests[2].Tip.PushedDate.Time),
resource.NewVersion(testPullRequests[1], testPullRequests[1].Tip.PushedDate.Time),
},
},

Expand All @@ -99,15 +99,15 @@ func TestCheck(t *testing.T) {
AccessToken: "oauthtoken",
Paths: []string{"terraform/*/*.tf", "terraform/*/*/*.tf"},
},
version: resource.NewVersion(testPullRequests[3], testPullRequests[3].Tip.CommittedDate.Time),
version: resource.NewVersion(testPullRequests[3], testPullRequests[3].Tip.PushedDate.Time),
pullRequests: testPullRequests,
files: [][]string{
{"README.md", "travis.yml"},
{"terraform/modules/ecs/main.tf", "README.md"},
{"terraform/modules/variables.tf", "travis.yml"},
},
expected: resource.CheckResponse{
resource.NewVersion(testPullRequests[2], testPullRequests[2].Tip.CommittedDate.Time),
resource.NewVersion(testPullRequests[2], testPullRequests[2].Tip.PushedDate.Time),
},
},

Expand All @@ -118,15 +118,15 @@ func TestCheck(t *testing.T) {
AccessToken: "oauthtoken",
IgnorePaths: []string{"*.md", "*.yml"},
},
version: resource.NewVersion(testPullRequests[3], testPullRequests[3].Tip.CommittedDate.Time),
version: resource.NewVersion(testPullRequests[3], testPullRequests[3].Tip.PushedDate.Time),
pullRequests: testPullRequests,
files: [][]string{
{"README.md", "travis.yml"},
{"terraform/modules/ecs/main.tf", "README.md"},
{"terraform/modules/variables.tf", "travis.yml"},
},
expected: resource.CheckResponse{
resource.NewVersion(testPullRequests[2], testPullRequests[2].Tip.CommittedDate.Time),
resource.NewVersion(testPullRequests[2], testPullRequests[2].Tip.PushedDate.Time),
},
},

Expand All @@ -137,10 +137,10 @@ func TestCheck(t *testing.T) {
AccessToken: "oauthtoken",
DisableCISkip: true,
},
version: resource.NewVersion(testPullRequests[1], testPullRequests[1].Tip.CommittedDate.Time),
version: resource.NewVersion(testPullRequests[1], testPullRequests[1].Tip.PushedDate.Time),
pullRequests: testPullRequests,
expected: resource.CheckResponse{
resource.NewVersion(testPullRequests[0], testPullRequests[0].Tip.CommittedDate.Time),
resource.NewVersion(testPullRequests[0], testPullRequests[0].Tip.PushedDate.Time),
},
},

Expand All @@ -151,10 +151,10 @@ func TestCheck(t *testing.T) {
AccessToken: "oauthtoken",
IgnoreDrafts: true,
},
version: resource.NewVersion(testPullRequests[3], testPullRequests[3].Tip.CommittedDate.Time),
version: resource.NewVersion(testPullRequests[3], testPullRequests[3].Tip.PushedDate.Time),
pullRequests: testPullRequests,
expected: resource.CheckResponse{
resource.NewVersion(testPullRequests[1], testPullRequests[1].Tip.CommittedDate.Time),
resource.NewVersion(testPullRequests[1], testPullRequests[1].Tip.PushedDate.Time),
},
},

Expand All @@ -165,11 +165,11 @@ func TestCheck(t *testing.T) {
AccessToken: "oauthtoken",
IgnoreDrafts: false,
},
version: resource.NewVersion(testPullRequests[3], testPullRequests[3].Tip.CommittedDate.Time),
version: resource.NewVersion(testPullRequests[3], testPullRequests[3].Tip.PushedDate.Time),
pullRequests: testPullRequests,
expected: resource.CheckResponse{
resource.NewVersion(testPullRequests[2], testPullRequests[2].Tip.CommittedDate.Time),
resource.NewVersion(testPullRequests[1], testPullRequests[1].Tip.CommittedDate.Time),
resource.NewVersion(testPullRequests[2], testPullRequests[2].Tip.PushedDate.Time),
resource.NewVersion(testPullRequests[1], testPullRequests[1].Tip.PushedDate.Time),
},
},

Expand All @@ -180,12 +180,12 @@ func TestCheck(t *testing.T) {
AccessToken: "oauthtoken",
DisableForks: true,
},
version: resource.NewVersion(testPullRequests[5], testPullRequests[5].Tip.CommittedDate.Time),
version: resource.NewVersion(testPullRequests[5], testPullRequests[5].Tip.PushedDate.Time),
pullRequests: testPullRequests,
expected: resource.CheckResponse{
resource.NewVersion(testPullRequests[3], testPullRequests[3].Tip.CommittedDate.Time),
resource.NewVersion(testPullRequests[2], testPullRequests[2].Tip.CommittedDate.Time),
resource.NewVersion(testPullRequests[1], testPullRequests[1].Tip.CommittedDate.Time),
resource.NewVersion(testPullRequests[3], testPullRequests[3].Tip.PushedDate.Time),
resource.NewVersion(testPullRequests[2], testPullRequests[2].Tip.PushedDate.Time),
resource.NewVersion(testPullRequests[1], testPullRequests[1].Tip.PushedDate.Time),
},
},

Expand All @@ -200,7 +200,7 @@ func TestCheck(t *testing.T) {
pullRequests: testPullRequests,
files: [][]string{},
expected: resource.CheckResponse{
resource.NewVersion(testPullRequests[6], testPullRequests[6].Tip.CommittedDate.Time),
resource.NewVersion(testPullRequests[6], testPullRequests[6].Tip.PushedDate.Time),
},
},

Expand All @@ -211,10 +211,10 @@ func TestCheck(t *testing.T) {
AccessToken: "oauthtoken",
RequiredReviewApprovals: 1,
},
version: resource.NewVersion(testPullRequests[8], testPullRequests[8].Tip.CommittedDate.Time),
version: resource.NewVersion(testPullRequests[8], testPullRequests[8].Tip.PushedDate.Time),
pullRequests: testPullRequests,
expected: resource.CheckResponse{
resource.NewVersion(testPullRequests[7], testPullRequests[7].Tip.CommittedDate.Time),
resource.NewVersion(testPullRequests[7], testPullRequests[7].Tip.PushedDate.Time),
},
},

Expand All @@ -229,7 +229,7 @@ func TestCheck(t *testing.T) {
pullRequests: testPullRequests,
files: [][]string{},
expected: resource.CheckResponse{
resource.NewVersion(testPullRequests[6], testPullRequests[6].Tip.CommittedDate.Time),
resource.NewVersion(testPullRequests[6], testPullRequests[6].Tip.PushedDate.Time),
},
},

Expand All @@ -244,7 +244,7 @@ func TestCheck(t *testing.T) {
pullRequests: testPullRequests,
files: [][]string{},
expected: resource.CheckResponse{
resource.NewVersion(testPullRequests[9], testPullRequests[9].Tip.CommittedDate.Time),
resource.NewVersion(testPullRequests[9], testPullRequests[9].Tip.PushedDate.Time),
},
},

Expand All @@ -267,12 +267,12 @@ func TestCheck(t *testing.T) {
AccessToken: "oauthtoken",
States: []githubv4.PullRequestState{githubv4.PullRequestStateClosed, githubv4.PullRequestStateMerged},
},
version: resource.NewVersion(testPullRequests[11], testPullRequests[11].Tip.CommittedDate.Time),
version: resource.NewVersion(testPullRequests[11], testPullRequests[11].Tip.PushedDate.Time),
pullRequests: testPullRequests,
files: [][]string{},
expected: resource.CheckResponse{
resource.NewVersion(testPullRequests[10], testPullRequests[10].Tip.CommittedDate.Time),
resource.NewVersion(testPullRequests[9], testPullRequests[9].Tip.CommittedDate.Time),
resource.NewVersion(testPullRequests[10], testPullRequests[10].Tip.PushedDate.Time),
resource.NewVersion(testPullRequests[9], testPullRequests[9].Tip.PushedDate.Time),
},
},
{
Expand All @@ -288,7 +288,7 @@ func TestCheck(t *testing.T) {
pullRequests: testPullRequests,
files: [][]string{},
expected: resource.CheckResponse{
resource.NewVersion(testPullRequests[12], testPullRequests[12].Tip.CommittedDate.Time),
resource.NewVersion(testPullRequests[12], testPullRequests[12].Tip.PushedDate.Time),
},
},
{
Expand All @@ -300,11 +300,11 @@ func TestCheck(t *testing.T) {
{Context: "my-status-check-2", State: "success"},
},
},
version: resource.NewVersion(testPullRequests[9], testPullRequests[9].Tip.CommittedDate.Time),
version: resource.NewVersion(testPullRequests[9], testPullRequests[9].Tip.PushedDate.Time),
pullRequests: testPullRequests,
files: [][]string{},
expected: resource.CheckResponse{
resource.NewVersion(testPullRequests[14], testPullRequests[14].Tip.Status.Contexts[0].CreatedAt.Time),
resource.NewVersion(testPullRequests[9], testPullRequests[9].Tip.PushedDate.Time),
},
},
{
Expand All @@ -322,7 +322,7 @@ func TestCheck(t *testing.T) {
files: [][]string{},
expected: resource.CheckResponse{
// todo: pull request index
resource.NewVersion(testPullRequests[13], testPullRequests[13].Tip.CommittedDate.Time),
resource.NewVersion(testPullRequests[13], testPullRequests[13].Tip.PushedDate.Time),
},
},
}
Expand Down
38 changes: 19 additions & 19 deletions in_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ func TestGet(t *testing.T) {
version: resource.Version{
PR: "pr1",
Commit: "commit1",
CommittedDate: time.Time{},
ChangedDate: time.Time{},
ApprovedReviewCount: "0",
State: githubv4.PullRequestStateOpen,
},
parameters: resource.GetParameters{},
pullRequest: createTestPR(1, "master", false, false, 0, nil, false, githubv4.PullRequestStateOpen, []resource.StatusContext{}),
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","approved_review_count":"0","state":"OPEN"}`,
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","changed":"0001-01-01T00:00:00Z","approved_review_count":"0","state":"OPEN"}`,
metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`,
},
{
Expand All @@ -56,13 +56,13 @@ func TestGet(t *testing.T) {
version: resource.Version{
PR: "pr1",
Commit: "commit1",
CommittedDate: time.Time{},
ChangedDate: time.Time{},
ApprovedReviewCount: "0",
State: githubv4.PullRequestStateOpen,
},
parameters: resource.GetParameters{},
pullRequest: createTestPR(1, "master", false, false, 0, nil, false, githubv4.PullRequestStateOpen, []resource.StatusContext{}),
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","approved_review_count":"0","state":"OPEN"}`,
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","changed":"0001-01-01T00:00:00Z","approved_review_count":"0","state":"OPEN"}`,
metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`,
},
{
Expand All @@ -74,15 +74,15 @@ func TestGet(t *testing.T) {
version: resource.Version{
PR: "pr1",
Commit: "commit1",
CommittedDate: time.Time{},
ChangedDate: time.Time{},
ApprovedReviewCount: "0",
State: githubv4.PullRequestStateOpen,
},
parameters: resource.GetParameters{
IntegrationTool: "rebase",
},
pullRequest: createTestPR(1, "master", false, false, 0, nil, false, githubv4.PullRequestStateOpen, []resource.StatusContext{}),
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","approved_review_count":"0","state":"OPEN"}`,
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","changed":"0001-01-01T00:00:00Z","approved_review_count":"0","state":"OPEN"}`,
metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`,
},
{
Expand All @@ -94,15 +94,15 @@ func TestGet(t *testing.T) {
version: resource.Version{
PR: "pr1",
Commit: "commit1",
CommittedDate: time.Time{},
ChangedDate: time.Time{},
ApprovedReviewCount: "0",
State: githubv4.PullRequestStateOpen,
},
parameters: resource.GetParameters{
IntegrationTool: "checkout",
},
pullRequest: createTestPR(1, "master", false, false, 0, nil, false, githubv4.PullRequestStateOpen, []resource.StatusContext{}),
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","approved_review_count":"0","state":"OPEN"}`,
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","changed":"0001-01-01T00:00:00Z","approved_review_count":"0","state":"OPEN"}`,
metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`,
},
{
Expand All @@ -114,15 +114,15 @@ func TestGet(t *testing.T) {
version: resource.Version{
PR: "pr1",
Commit: "commit1",
CommittedDate: time.Time{},
ChangedDate: time.Time{},
ApprovedReviewCount: "0",
State: githubv4.PullRequestStateOpen,
},
parameters: resource.GetParameters{
GitDepth: 2,
},
pullRequest: createTestPR(1, "master", false, false, 0, nil, false, githubv4.PullRequestStateOpen, []resource.StatusContext{}),
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","approved_review_count":"0","state":"OPEN"}`,
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","changed":"0001-01-01T00:00:00Z","approved_review_count":"0","state":"OPEN"}`,
metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`,
},
{
Expand All @@ -134,7 +134,7 @@ func TestGet(t *testing.T) {
version: resource.Version{
PR: "pr1",
Commit: "commit1",
CommittedDate: time.Time{},
ChangedDate: time.Time{},
ApprovedReviewCount: "0",
State: githubv4.PullRequestStateOpen,
},
Expand All @@ -150,7 +150,7 @@ func TestGet(t *testing.T) {
Path: "Other.md",
},
},
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","approved_review_count":"0","state":"OPEN"}`,
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","changed":"0001-01-01T00:00:00Z","approved_review_count":"0","state":"OPEN"}`,
metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`,
filesString: "README.md\nOther.md\n",
},
Expand Down Expand Up @@ -292,9 +292,9 @@ func TestGetSkipDownload(t *testing.T) {
AccessToken: "oauthtoken",
},
version: resource.Version{
PR: "pr1",
Commit: "commit1",
CommittedDate: time.Time{},
PR: "pr1",
Commit: "commit1",
ChangedDate: time.Time{},
},
parameters: resource.GetParameters{SkipDownload: true},
},
Expand Down Expand Up @@ -376,10 +376,10 @@ func createTestPR(
MergedAt: githubv4.DateTime{Time: time.Now()},
},
Tip: resource.CommitObject{
ID: fmt.Sprintf("commit%s", n),
OID: fmt.Sprintf("oid%s", n),
CommittedDate: githubv4.DateTime{Time: d},
Message: m,
ID: fmt.Sprintf("commit%s", n),
OID: fmt.Sprintf("oid%s", n),
PushedDate: &githubv4.DateTime{Time: d},
Message: m,
Author: struct {
User struct{ Login string }
Email string
Expand Down
Loading