mirror of
https://github.com/ivabus/pantry
synced 2024-11-23 08:55:07 +03:00
better undefined resolution
This commit is contained in:
parent
95ecc17d79
commit
d919815397
1 changed files with 3 additions and 1 deletions
|
@ -52,7 +52,9 @@ export async function find_pr(repo: string, ref: string): Promise<number | undef
|
||||||
const res = await queryGraphQL<CommitQuery>(prQuery(repo))
|
const res = await queryGraphQL<CommitQuery>(prQuery(repo))
|
||||||
|
|
||||||
const node = res.repository?.ref?.target?.history?.edges.find(n => n.node.oid === ref)
|
const node = res.repository?.ref?.target?.history?.edges.find(n => n.node.oid === ref)
|
||||||
return node?.node.associatedPullRequests.nodes[0].number
|
const nodes = node?.node.associatedPullRequests.nodes
|
||||||
|
if (!nodes || nodes.length === 0) return
|
||||||
|
return nodes[0].number
|
||||||
}
|
}
|
||||||
|
|
||||||
async function queryGraphQL<T>(query: string): Promise<T> {
|
async function queryGraphQL<T>(query: string): Promise<T> {
|
||||||
|
|
Loading…
Reference in a new issue