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(
6666 // if there are no args or the arg is a number, we're talking about a PR
6767 if ( args . length === 0 || typeof args [ 0 ] === 'number' ) {
6868 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.
6974 const query = `{
7075 repository(owner: "oxidecomputer", name: "omicron") {
7176 pullRequest(number: ${ prNum } ) {
72- baseRefOid
7377 headRefOid
78+ commits(first: 1) {
79+ nodes {
80+ commit {
81+ parents(first: 1) { nodes { oid } }
82+ }
83+ }
84+ }
7485 }
7586 }
7687 }`
7788 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
7991 return { base, head }
8092 }
8193
You can’t perform that action at this time.
0 commit comments