File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -66,16 +66,28 @@ async function getCommitRange(
66
66
// if there are no args or the arg is a number, we're talking about a PR
67
67
if ( args . length === 0 || typeof args [ 0 ] === 'number' ) {
68
68
const prNum = args [ 0 ] || ( await pickPr ( ) )
69
+ // This commits and parents thing is absurd, but the idea is to use the
70
+ // parent of the first commit as the base. If we just use the base ref
71
+ // directly, hwe get the current state of main, which means the diff will
72
+ // reflect both the current PR and any changes made on main since it branch
73
+ // edoff.
69
74
const query = `{
70
75
repository(owner: "oxidecomputer", name: "omicron") {
71
76
pullRequest(number: ${ prNum } ) {
72
- baseRefOid
73
77
headRefOid
78
+ commits(first: 1) {
79
+ nodes {
80
+ commit {
81
+ parents(first: 1) { nodes { oid } }
82
+ }
83
+ }
84
+ }
74
85
}
75
86
}
76
87
}`
77
88
const pr = await $ `gh api graphql -f query=${ query } ` . json ( )
78
- const { baseRefOid : base , headRefOid : head } = pr . data . repository . pullRequest
89
+ const head = pr . data . repository . pullRequest . headRefOid
90
+ const base = pr . data . repository . pullRequest . commits . nodes [ 0 ] . commit . parents . nodes [ 0 ] . oid
79
91
return { base, head }
80
92
}
81
93
You can’t perform that action at this time.
0 commit comments