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 #11385
This commit is contained in:
yuvrajangadsingh 2026-02-10 16:57:25 +05:30
parent 097bad6f73
commit de61b2b65d
3 changed files with 8 additions and 6 deletions

View file

@ -296,9 +296,10 @@ type PullRequestCommitCommit struct {
} }
type PullRequestFile struct { type PullRequestFile struct {
Path string `json:"path"` Path string `json:"path"`
Additions int `json:"additions"` Additions int `json:"additions"`
Deletions int `json:"deletions"` Deletions int `json:"deletions"`
ChangeType string `json:"changeType"`
} }
type ReviewRequests struct { type ReviewRequests struct {

View file

@ -148,7 +148,8 @@ var prFiles = shortenQuery(`
nodes { nodes {
additions, additions,
deletions, deletions,
path path,
changeType
} }
} }
`) `)

View file

@ -26,7 +26,7 @@ func TestPullRequestGraphQL(t *testing.T) {
{ {
name: "compressed query", name: "compressed query",
fields: []string{"files"}, fields: []string{"files"},
want: "files(first: 100) {nodes {additions,deletions,path}}", want: "files(first: 100) {nodes {additions,deletions,path,changeType}}",
}, },
{ {
name: "invalid fields", name: "invalid fields",
@ -72,7 +72,7 @@ func TestIssueGraphQL(t *testing.T) {
{ {
name: "compressed query", name: "compressed query",
fields: []string{"files"}, fields: []string{"files"},
want: "files(first: 100) {nodes {additions,deletions,path}}", want: "files(first: 100) {nodes {additions,deletions,path,changeType}}",
}, },
{ {
name: "projectItems", name: "projectItems",