Skip to content

Commit de61b2b

Browse files
feat(pr): add changeType field to files JSON output
Add the changeType field from the PullRequestChangedFile GraphQL type to the PullRequestFile struct. This exposes the file status (added, modified, deleted, renamed, copied, changed) in gh pr list --json files and gh pr view --json files output. Closes cli#11385
1 parent 097bad6 commit de61b2b

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

api/queries_pr.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,10 @@ type PullRequestCommitCommit struct {
296296
}
297297

298298
type PullRequestFile struct {
299-
Path string `json:"path"`
300-
Additions int `json:"additions"`
301-
Deletions int `json:"deletions"`
299+
Path string `json:"path"`
300+
Additions int `json:"additions"`
301+
Deletions int `json:"deletions"`
302+
ChangeType string `json:"changeType"`
302303
}
303304

304305
type ReviewRequests struct {

api/query_builder.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ var prFiles = shortenQuery(`
148148
nodes {
149149
additions,
150150
deletions,
151-
path
151+
path,
152+
changeType
152153
}
153154
}
154155
`)

api/query_builder_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestPullRequestGraphQL(t *testing.T) {
2626
{
2727
name: "compressed query",
2828
fields: []string{"files"},
29-
want: "files(first: 100) {nodes {additions,deletions,path}}",
29+
want: "files(first: 100) {nodes {additions,deletions,path,changeType}}",
3030
},
3131
{
3232
name: "invalid fields",
@@ -72,7 +72,7 @@ func TestIssueGraphQL(t *testing.T) {
7272
{
7373
name: "compressed query",
7474
fields: []string{"files"},
75-
want: "files(first: 100) {nodes {additions,deletions,path}}",
75+
want: "files(first: 100) {nodes {additions,deletions,path,changeType}}",
7676
},
7777
{
7878
name: "projectItems",

0 commit comments

Comments
 (0)