Skip to content

Commit 14ecb63

Browse files
committed
Address more comments
1 parent 2798f37 commit 14ecb63

File tree

4 files changed

+23
-27
lines changed

4 files changed

+23
-27
lines changed

github.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func (m *GithubClient) ListOpenPullRequests() ([]*PullRequest, error) {
127127
"prFirst": githubv4.Int(100),
128128
"prStates": []githubv4.PullRequestState{githubv4.PullRequestStateOpen},
129129
"prCursor": (*githubv4.String)(nil),
130-
"commitsLast": githubv4.Int(100),
130+
"commitsLast": githubv4.Int(1),
131131
}
132132

133133
var response []*PullRequest
@@ -281,7 +281,7 @@ func (m *GithubClient) GetPullRequest(prNumber, commitRef string) (*PullRequest,
281281
"repositoryOwner": githubv4.String(m.Owner),
282282
"repositoryName": githubv4.String(m.Repository),
283283
"prNumber": githubv4.Int(pr),
284-
"commitsLast": githubv4.Int(1),
284+
"commitsLast": githubv4.Int(100),
285285
}
286286

287287
// TODO: Pagination - in case someone pushes > 100 commits before the build has time to start :p
@@ -290,14 +290,12 @@ func (m *GithubClient) GetPullRequest(prNumber, commitRef string) (*PullRequest,
290290
}
291291

292292
for _, c := range query.Repository.PullRequest.Commits.Edges {
293-
prObj := PullRequest{
294-
PullRequestObject: query.Repository.PullRequest.PullRequestObject,
295-
Tip: c.Node.Commit,
296-
}
297-
298293
if c.Node.Commit.OID == commitRef {
299294
// Return as soon as we find the correct ref.
300-
return &prObj, nil
295+
return &PullRequest{
296+
PullRequestObject: query.Repository.PullRequest.PullRequestObject,
297+
Tip: c.Node.Commit,
298+
}, nil
301299
}
302300
}
303301

in.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func Get(request GetRequest, github Github, git Git, outputDir string) (*GetResp
102102

103103
}
104104

105-
if request.Params.GenerateChangedFileList {
105+
if request.Params.ListChangedFiles {
106106
cfol, err := github.GetChangedFiles(request.Version.PR, request.Version.Commit)
107107
if err != nil {
108108
return nil, fmt.Errorf("failed to fetch list of changed files: %s", err)
@@ -128,10 +128,10 @@ func Get(request GetRequest, github Github, git Git, outputDir string) (*GetResp
128128

129129
// GetParameters ...
130130
type GetParameters struct {
131-
SkipDownload bool `json:"skip_download"`
132-
IntegrationTool string `json:"integration_tool"`
133-
GitDepth int `json:"git_depth"`
134-
GenerateChangedFileList bool `json:"list_changed_files"`
131+
SkipDownload bool `json:"skip_download"`
132+
IntegrationTool string `json:"integration_tool"`
133+
GitDepth int `json:"git_depth"`
134+
ListChangedFiles bool `json:"list_changed_files"`
135135
}
136136

137137
// GetRequest ...

in_test.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func TestGet(t *testing.T) {
4040
CommittedDate: time.Time{},
4141
},
4242
parameters: resource.GetParameters{
43-
GenerateChangedFileList: true,
43+
ListChangedFiles: true,
4444
},
4545
pullRequest: createTestPR(1, "master", false, false),
4646
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z"}`,
@@ -68,7 +68,7 @@ func TestGet(t *testing.T) {
6868
CommittedDate: time.Time{},
6969
},
7070
parameters: resource.GetParameters{
71-
GenerateChangedFileList: true,
71+
ListChangedFiles: true,
7272
},
7373
pullRequest: createTestPR(1, "master", false, false),
7474
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z"}`,
@@ -95,8 +95,8 @@ func TestGet(t *testing.T) {
9595
CommittedDate: time.Time{},
9696
},
9797
parameters: resource.GetParameters{
98-
IntegrationTool: "rebase",
99-
GenerateChangedFileList: true,
98+
IntegrationTool: "rebase",
99+
ListChangedFiles: true,
100100
},
101101
pullRequest: createTestPR(1, "master", false, false),
102102
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z"}`,
@@ -123,8 +123,8 @@ func TestGet(t *testing.T) {
123123
CommittedDate: time.Time{},
124124
},
125125
parameters: resource.GetParameters{
126-
IntegrationTool: "checkout",
127-
GenerateChangedFileList: true,
126+
IntegrationTool: "checkout",
127+
ListChangedFiles: true,
128128
},
129129
pullRequest: createTestPR(1, "master", false, false),
130130
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z"}`,
@@ -151,8 +151,8 @@ func TestGet(t *testing.T) {
151151
CommittedDate: time.Time{},
152152
},
153153
parameters: resource.GetParameters{
154-
GitDepth: 2,
155-
GenerateChangedFileList: true,
154+
GitDepth: 2,
155+
ListChangedFiles: true,
156156
},
157157
pullRequest: createTestPR(1, "master", false, false),
158158
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z"}`,
@@ -179,7 +179,7 @@ func TestGet(t *testing.T) {
179179
CommittedDate: time.Time{},
180180
},
181181
parameters: resource.GetParameters{
182-
GenerateChangedFileList: false,
182+
ListChangedFiles: false,
183183
},
184184
pullRequest: createTestPR(1, "master", false, false),
185185
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z"}`,
@@ -349,7 +349,7 @@ func createTestPR(count int, baseName string, skipCI bool, isCrossRepo bool) *re
349349
m = "[skip ci]" + m
350350
}
351351

352-
retpr := resource.PullRequest{
352+
return &resource.PullRequest{
353353
PullRequestObject: resource.PullRequestObject{
354354
ID: fmt.Sprintf("pr%s", n),
355355
Number: count,
@@ -374,8 +374,6 @@ func createTestPR(count int, baseName string, skipCI bool, isCrossRepo bool) *re
374374
},
375375
},
376376
}
377-
378-
return &retpr
379377
}
380378

381379
func createTestDirectory(t *testing.T) string {

models.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func NewVersion(p *PullRequest) Version {
7373
// PullRequest represents a pull request and includes the tip (commit).
7474
type PullRequest struct {
7575
PullRequestObject
76-
Tip CommitObject
76+
Tip CommitObject
7777
}
7878

7979
// PullRequestObject represents the GraphQL commit node.
@@ -109,4 +109,4 @@ type CommitObject struct {
109109
// https://developer.github.com/v4/object/pullrequestchangedfile/
110110
type ChangedFileObject struct {
111111
Path string
112-
}
112+
}

0 commit comments

Comments
 (0)