MCPcopy Index your code
hub / github.com/refined-github/refined-github / getPrInfo

Function getPrInfo

source/github-helpers/get-pr-info.ts:19–64  ·  view source on GitHub ↗
(base: string, number = getConversationNumber()!)

Source from the content-addressed store, hash-verified

17};
18
19export default async function getPrInfo(base: string, number = getConversationNumber()!): Promise<PullRequestInfo> {
20 const {repository} = await api.v4uncached(`
21 repository() {
22 pullRequest(number: ${number}) {
23 id
24 baseRefOid
25 headRefOid
26 mergeable
27 viewerCanUpdate
28 viewerCanEditFiles
29 headRef {
30 compare(headRef: "${base}") {
31 status
32 aheadBy
33 }
34 }
35 headRepository {
36 viewerPermission
37 }
38 }
39 }
40 `);
41
42 const {
43 id,
44 baseRefOid,
45 headRefOid,
46 mergeable,
47 viewerCanUpdate,
48 viewerCanEditFiles,
49 headRef,
50 headRepository,
51 } = repository.pullRequest;
52 return {
53 id,
54 baseRefOid,
55 headRefOid,
56 viewerCanUpdate,
57 mergeable,
58 viewerCanEditFiles,
59 // The comparison in the API is base -> head, so it must be flipped
60 behindBy: headRef.compare.aheadBy,
61 needsUpdate: headRef.compare.status === 'DIVERGED',
62 headRepoPerm: headRepository.viewerPermission,
63 };
64}

Callers 4

getHeadReferenceFunction · 0.85
addInfoFunction · 0.85
handlerFunction · 0.85
isBranchUpdatableFunction · 0.85

Calls 1

getConversationNumberFunction · 0.85

Tested by

no test coverage detected