@gitkraken/core-gitlens 0.46.0 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -1
- package/dist/git-cli/providers/config.js +2 -2
- package/dist/git-cli/providers/pausedOperations.js +2 -2
- package/dist/git-cli/providers/pausedOperations.js.map +1 -1
- package/dist/git-cli/providers/staging.js +1 -1
- package/dist/ipc/discovery.js +1 -1
- package/dist/plus/agents/providers/claudeCodeTranscript.js +6 -6
- package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
- package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -1
- package/dist/plus/git-github/api/enterprisePullRequestMergePolicy.d.ts +31 -0
- package/dist/plus/git-github/api/enterprisePullRequestMergePolicy.js +166 -0
- package/dist/plus/git-github/api/enterprisePullRequestMergePolicy.js.map +1 -0
- package/dist/plus/git-github/api/github.d.ts +7 -4
- package/dist/plus/git-github/api/github.js +44 -14
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/api/issueWrites.d.ts +1 -0
- package/dist/plus/git-github/api/issueWrites.js +5 -5
- package/dist/plus/git-github/api/issueWrites.js.map +1 -1
- package/dist/plus/git-github/api/pullRequestWrites.d.ts +7 -3
- package/dist/plus/git-github/api/pullRequestWrites.js +120 -67
- package/dist/plus/git-github/api/pullRequestWrites.js.map +1 -1
- package/dist/plus/integrations/authentication/configuredIntegrationService.d.ts +4 -4
- package/dist/plus/integrations/authentication/configuredIntegrationService.js +14 -14
- package/dist/plus/integrations/authentication/configuredIntegrationService.js.map +1 -1
- package/dist/plus/integrations/authentication/integrationAuthenticationService.js +3 -3
- package/dist/plus/integrations/authentication/integrationAuthenticationService.js.map +1 -1
- package/dist/plus/integrations/context.d.ts +4 -4
- package/dist/plus/integrations/index.d.ts +8 -4
- package/dist/plus/integrations/index.js +2 -1
- package/dist/plus/integrations/index.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +9 -2
- package/dist/plus/integrations/integrationService.js +95 -31
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +16 -4
- package/dist/plus/integrations/models/gitHostIntegration.js +7 -4
- package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
- package/dist/plus/integrations/models/integration.d.ts +2 -1
- package/dist/plus/integrations/models/integration.js +11 -4
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/models/issueTrackerWrites.d.ts +128 -0
- package/dist/plus/integrations/models/issueTrackerWrites.js +0 -0
- package/dist/plus/integrations/models/publicIntegration.d.ts +5 -0
- package/dist/plus/integrations/models/publicIntegration.js.map +1 -1
- package/dist/plus/integrations/providers/azure/azure.js +1 -1
- package/dist/plus/integrations/providers/github.d.ts +19 -6
- package/dist/plus/integrations/providers/github.js +126 -53
- package/dist/plus/integrations/providers/github.js.map +1 -1
- package/dist/plus/integrations/providers/issueSorts.d.ts +1 -0
- package/dist/plus/integrations/providers/jira.js +1 -1
- package/dist/plus/integrations/providers/jiraIssueByKey.d.ts +2 -0
- package/dist/plus/integrations/providers/jiraIssueByKey.js +1 -1
- package/dist/plus/integrations/providers/jiraIssueByKey.js.map +1 -1
- package/dist/plus/integrations/providers/jiraIssueWriteErrors.d.ts +10 -0
- package/dist/plus/integrations/providers/jiraIssueWriteErrors.js +68 -0
- package/dist/plus/integrations/providers/jiraIssueWriteErrors.js.map +1 -0
- package/dist/plus/integrations/providers/jiraIssueWrites.d.ts +40 -0
- package/dist/plus/integrations/providers/jiraIssueWrites.js +397 -0
- package/dist/plus/integrations/providers/jiraIssueWrites.js.map +1 -0
- package/dist/plus/integrations/providers/providersApi.d.ts +4 -1
- package/dist/plus/integrations/providers/providersApi.js +21 -10
- package/dist/plus/integrations/providers/providersApi.js.map +1 -1
- package/dist/plus/integrations/reads/drains.d.ts +1 -0
- package/dist/plus/integrations/utils/integration.utils.d.ts +1 -0
- package/dist/plus/integrations/utils/integration.utils.js +7 -1
- package/dist/plus/integrations/utils/integration.utils.js.map +1 -1
- package/dist/utils/env/node/exec.js +2 -2
- package/docs/integrations.md +80 -8
- package/package.json +1 -1
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { RequestError } from "@octokit/request-error";
|
|
2
|
+
//#region ../plus/git-github/src/api/enterprisePullRequestMergePolicy.ts
|
|
3
|
+
async function readEnterprisePullRequestMergePolicy({ id, baseRef, baseRefId }, repository, graphql, readBranchRules) {
|
|
4
|
+
const schema = await readEnterpriseMergeSchema(graphql);
|
|
5
|
+
if (schema == null) return {
|
|
6
|
+
kind: "unavailable",
|
|
7
|
+
reason: "unknown"
|
|
8
|
+
};
|
|
9
|
+
if (schema.hasQueue && !schema.queueFields) return {
|
|
10
|
+
kind: "unavailable",
|
|
11
|
+
reason: "unknown"
|
|
12
|
+
};
|
|
13
|
+
if (schema.queueFields || schema.stack) {
|
|
14
|
+
const current = (await graphql(`query PullRequestMergeFeatures($id: ID!) {
|
|
15
|
+
node(id: $id) {
|
|
16
|
+
... on PullRequest {
|
|
17
|
+
id baseRefName baseRef { id }
|
|
18
|
+
${schema.queueFields ? "isInMergeQueue isMergeQueueEnabled" : ""}
|
|
19
|
+
${schema.stack ? "stack { id }" : ""}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}`, { id }))?.node;
|
|
23
|
+
if (current?.id !== id || current.baseRefName !== baseRef || current.baseRef?.id !== baseRefId || schema.queueFields && (typeof current.isInMergeQueue !== "boolean" || typeof current.isMergeQueueEnabled !== "boolean") || schema.stack && current.stack === void 0) return {
|
|
24
|
+
kind: "unavailable",
|
|
25
|
+
reason: "unknown"
|
|
26
|
+
};
|
|
27
|
+
if (current.isInMergeQueue) return {
|
|
28
|
+
kind: "unavailable",
|
|
29
|
+
reason: "blocked"
|
|
30
|
+
};
|
|
31
|
+
if (current.stack != null) return {
|
|
32
|
+
kind: "unavailable",
|
|
33
|
+
reason: "unsupported"
|
|
34
|
+
};
|
|
35
|
+
if (current.isMergeQueueEnabled) return enterpriseQueueCapability(schema.canEnqueue);
|
|
36
|
+
}
|
|
37
|
+
const activeRules = normalizeEnterpriseBranchRules(await readBranchRules(repository, baseRef).catch((ex) => {
|
|
38
|
+
if (ex instanceof RequestError && ex.status === 404) return void 0;
|
|
39
|
+
throw ex;
|
|
40
|
+
}));
|
|
41
|
+
if (activeRules == null) return {
|
|
42
|
+
kind: "unavailable",
|
|
43
|
+
reason: "unknown"
|
|
44
|
+
};
|
|
45
|
+
if (activeRules.some((rule) => rule.type === "MERGE_QUEUE")) return enterpriseQueueCapability(schema.queueFields && schema.canEnqueue);
|
|
46
|
+
if (!schema.canMerge || !schema.linearHistory) return {
|
|
47
|
+
kind: "unavailable",
|
|
48
|
+
reason: "unsupported"
|
|
49
|
+
};
|
|
50
|
+
const ref = (await graphql(`
|
|
51
|
+
query PullRequestLegacyBranchRule($id: ID!) {
|
|
52
|
+
node(id: $id) {
|
|
53
|
+
... on Ref {
|
|
54
|
+
id
|
|
55
|
+
refUpdateRule {
|
|
56
|
+
requiresLinearHistory
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
`, { id: baseRefId }))?.node;
|
|
62
|
+
if (ref?.id !== baseRefId || ref.refUpdateRule !== null && typeof ref.refUpdateRule?.requiresLinearHistory !== "boolean") return {
|
|
63
|
+
kind: "unavailable",
|
|
64
|
+
reason: "unknown"
|
|
65
|
+
};
|
|
66
|
+
return {
|
|
67
|
+
rules: activeRules,
|
|
68
|
+
requiresLinearHistory: ref.refUpdateRule?.requiresLinearHistory === true
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function normalizeEnterpriseBranchRules(data) {
|
|
72
|
+
if (data == null) return void 0;
|
|
73
|
+
const rules = [];
|
|
74
|
+
for (const value of data) {
|
|
75
|
+
const rule = value;
|
|
76
|
+
if (typeof rule?.type !== "string" || !rule.type) return void 0;
|
|
77
|
+
const type = rule.type.toUpperCase();
|
|
78
|
+
const parameters = type === "PULL_REQUEST" ? rule.parameters : void 0;
|
|
79
|
+
if (parameters != null && (typeof parameters !== "object" || Array.isArray(parameters))) return void 0;
|
|
80
|
+
const methods = parameters?.allowed_merge_methods;
|
|
81
|
+
if (methods == null) rules.push({ type });
|
|
82
|
+
else if (Array.isArray(methods) && methods.every((method) => typeof method === "string")) rules.push({
|
|
83
|
+
type,
|
|
84
|
+
parameters: { allowedMergeMethods: methods }
|
|
85
|
+
});
|
|
86
|
+
else return;
|
|
87
|
+
}
|
|
88
|
+
return rules;
|
|
89
|
+
}
|
|
90
|
+
function enterpriseQueueCapability(supported) {
|
|
91
|
+
return supported ? { kind: "queue" } : {
|
|
92
|
+
kind: "unavailable",
|
|
93
|
+
reason: "unsupported"
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
async function readEnterpriseMergeSchema(graphql) {
|
|
97
|
+
const [operations, branch, queue] = await Promise.all([
|
|
98
|
+
graphql(`
|
|
99
|
+
query PullRequestMergeSchemaOperations {
|
|
100
|
+
mutation: __type(name: "Mutation") {
|
|
101
|
+
fields {
|
|
102
|
+
name
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
pr: __type(name: "PullRequest") {
|
|
106
|
+
fields {
|
|
107
|
+
name
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
enqueue: __type(name: "EnqueuePullRequestInput") {
|
|
111
|
+
inputFields {
|
|
112
|
+
name
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
merge: __type(name: "MergePullRequestInput") {
|
|
116
|
+
inputFields {
|
|
117
|
+
name
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
`, {}),
|
|
122
|
+
graphql(`
|
|
123
|
+
query PullRequestMergeSchemaBranch {
|
|
124
|
+
ref: __type(name: "Ref") {
|
|
125
|
+
fields {
|
|
126
|
+
name
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
legacy: __type(name: "RefUpdateRule") {
|
|
130
|
+
fields {
|
|
131
|
+
name
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
`, {}),
|
|
136
|
+
graphql(`
|
|
137
|
+
query PullRequestMergeSchemaQueue {
|
|
138
|
+
enqueuePayload: __type(name: "EnqueuePullRequestPayload") {
|
|
139
|
+
fields {
|
|
140
|
+
name
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
entry: __type(name: "MergeQueueEntry") {
|
|
144
|
+
fields {
|
|
145
|
+
name
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
`, {})
|
|
150
|
+
]);
|
|
151
|
+
if (!Array.isArray(operations?.mutation?.fields) || !Array.isArray(operations.pr?.fields) || operations.enqueue === void 0 || operations.merge === void 0 || branch?.ref === void 0 || branch.legacy === void 0 || queue?.enqueuePayload === void 0 || queue.entry === void 0) return;
|
|
152
|
+
const has = (members, ...names) => names.every((name) => members?.some((member) => member.name === name) === true);
|
|
153
|
+
const hasEnqueue = has(operations.mutation.fields, "enqueuePullRequest");
|
|
154
|
+
return {
|
|
155
|
+
stack: has(operations.pr.fields, "stack"),
|
|
156
|
+
queueFields: has(operations.pr.fields, "isInMergeQueue", "isMergeQueueEnabled"),
|
|
157
|
+
hasQueue: hasEnqueue || has(operations.pr.fields, "isInMergeQueue") || has(operations.pr.fields, "isMergeQueueEnabled"),
|
|
158
|
+
canEnqueue: hasEnqueue && has(operations.enqueue?.inputFields, "pullRequestId", "expectedHeadOid") && has(queue.enqueuePayload?.fields, "mergeQueueEntry") && has(queue.entry?.fields, "id", "pullRequest"),
|
|
159
|
+
canMerge: has(operations.mutation.fields, "mergePullRequest") && has(operations.merge?.inputFields, "pullRequestId", "expectedHeadOid", "mergeMethod"),
|
|
160
|
+
linearHistory: has(branch.ref?.fields, "refUpdateRule") && has(branch.legacy?.fields, "requiresLinearHistory")
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
//#endregion
|
|
164
|
+
export { readEnterprisePullRequestMergePolicy };
|
|
165
|
+
|
|
166
|
+
//# sourceMappingURL=enterprisePullRequestMergePolicy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enterprisePullRequestMergePolicy.js","names":[],"sources":["../../../../../plus/git-github/src/api/enterprisePullRequestMergePolicy.ts"],"sourcesContent":["import { RequestError } from '@octokit/request-error';\nimport type { RequestParameters } from '@octokit/types';\nimport type { GitHubPullRequestCreateTarget, PullRequestWriteFailure } from './pullRequestWrites.js';\n\nexport type GraphqlRequest = <T>(query: string, variables: RequestParameters) => Promise<T | undefined>;\nexport type BranchRule = {\n\ttype: string;\n\tparameters?: { allowedMergeMethods?: readonly string[] | null } | null;\n};\nexport type BranchPolicy = { rules: BranchRule[]; requiresLinearHistory: boolean };\n\nexport type EnterprisePullRequestWriteOptions = {\n\torigin: string;\n\treadBranchRules: (target: GitHubPullRequestCreateTarget, branch: string) => Promise<unknown[] | undefined>;\n};\n\ntype MergePolicy =\n\t| BranchPolicy\n\t| { kind: 'queue' }\n\t| { kind: 'unavailable'; reason: PullRequestWriteFailure['reason'] };\n\nexport async function readEnterprisePullRequestMergePolicy(\n\t{ id, baseRef, baseRefId }: { id: string; baseRef: string; baseRefId: string },\n\trepository: GitHubPullRequestCreateTarget,\n\tgraphql: GraphqlRequest,\n\treadBranchRules: EnterprisePullRequestWriteOptions['readBranchRules'],\n): Promise<MergePolicy> {\n\tconst schema = await readEnterpriseMergeSchema(graphql);\n\tif (schema == null) return { kind: 'unavailable', reason: 'unknown' };\n\tif (schema.hasQueue && !schema.queueFields) return { kind: 'unavailable', reason: 'unknown' };\n\n\tif (schema.queueFields || schema.stack) {\n\t\tconst result = await graphql<{\n\t\t\tnode: {\n\t\t\t\tid: string;\n\t\t\t\tbaseRefName: string;\n\t\t\t\tbaseRef: { id: string } | null;\n\t\t\t\tisInMergeQueue?: boolean;\n\t\t\t\tisMergeQueueEnabled?: boolean;\n\t\t\t\tstack?: { id: string } | null;\n\t\t\t} | null;\n\t\t}>(\n\t\t\t`query PullRequestMergeFeatures($id: ID!) {\n\t\t\t\tnode(id: $id) {\n\t\t\t\t\t... on PullRequest {\n\t\t\t\t\t\tid baseRefName baseRef { id }\n\t\t\t\t\t\t${schema.queueFields ? 'isInMergeQueue isMergeQueueEnabled' : ''}\n\t\t\t\t\t\t${schema.stack ? 'stack { id }' : ''}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}`,\n\t\t\t{ id: id },\n\t\t);\n\t\tconst current = result?.node;\n\t\tif (\n\t\t\tcurrent?.id !== id ||\n\t\t\tcurrent.baseRefName !== baseRef ||\n\t\t\tcurrent.baseRef?.id !== baseRefId ||\n\t\t\t(schema.queueFields &&\n\t\t\t\t(typeof current.isInMergeQueue !== 'boolean' || typeof current.isMergeQueueEnabled !== 'boolean')) ||\n\t\t\t(schema.stack && current.stack === undefined)\n\t\t) {\n\t\t\treturn { kind: 'unavailable', reason: 'unknown' };\n\t\t}\n\n\t\tif (current.isInMergeQueue) return { kind: 'unavailable', reason: 'blocked' };\n\t\tif (current.stack != null) return { kind: 'unavailable', reason: 'unsupported' };\n\t\tif (current.isMergeQueueEnabled) return enterpriseQueueCapability(schema.canEnqueue);\n\t}\n\n\tconst activeRules = normalizeEnterpriseBranchRules(\n\t\tawait readBranchRules(repository, baseRef).catch((ex: unknown) => {\n\t\t\tif (ex instanceof RequestError && ex.status === 404) return undefined;\n\n\t\t\tthrow ex;\n\t\t}),\n\t);\n\tif (activeRules == null) return { kind: 'unavailable', reason: 'unknown' };\n\tif (activeRules.some(rule => rule.type === 'MERGE_QUEUE')) {\n\t\treturn enterpriseQueueCapability(schema.queueFields && schema.canEnqueue);\n\t}\n\n\tif (!schema.canMerge || !schema.linearHistory) return { kind: 'unavailable', reason: 'unsupported' };\n\n\tconst response = await graphql<{\n\t\tnode: { id: string; refUpdateRule: { requiresLinearHistory: boolean } | null } | null;\n\t}>(\n\t\t`\n\t\t\tquery PullRequestLegacyBranchRule($id: ID!) {\n\t\t\t\tnode(id: $id) {\n\t\t\t\t\t... on Ref {\n\t\t\t\t\t\tid\n\t\t\t\t\t\trefUpdateRule {\n\t\t\t\t\t\t\trequiresLinearHistory\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t`,\n\t\t{ id: baseRefId },\n\t);\n\tconst ref = response?.node;\n\tif (\n\t\tref?.id !== baseRefId ||\n\t\t(ref.refUpdateRule !== null && typeof ref.refUpdateRule?.requiresLinearHistory !== 'boolean')\n\t) {\n\t\treturn { kind: 'unavailable', reason: 'unknown' };\n\t}\n\n\treturn {\n\t\trules: activeRules,\n\t\trequiresLinearHistory: ref.refUpdateRule?.requiresLinearHistory === true,\n\t};\n}\n\nfunction normalizeEnterpriseBranchRules(data: unknown[] | undefined): BranchRule[] | undefined {\n\tif (data == null) return undefined;\n\n\tconst rules: BranchRule[] = [];\n\tfor (const value of data) {\n\t\tconst rule = value as { type?: unknown; parameters?: { allowed_merge_methods?: unknown } } | null;\n\t\tif (typeof rule?.type !== 'string' || !rule.type) return undefined;\n\n\t\tconst type = rule.type.toUpperCase();\n\t\tconst parameters = type === 'PULL_REQUEST' ? rule.parameters : undefined;\n\t\tif (parameters != null && (typeof parameters !== 'object' || Array.isArray(parameters))) return undefined;\n\n\t\tconst methods = parameters?.allowed_merge_methods;\n\t\tif (methods == null) {\n\t\t\trules.push({ type: type });\n\t\t} else if (Array.isArray(methods) && methods.every(method => typeof method === 'string')) {\n\t\t\trules.push({ type: type, parameters: { allowedMergeMethods: methods } });\n\t\t} else {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\treturn rules;\n}\n\nfunction enterpriseQueueCapability(supported: boolean): MergePolicy {\n\treturn supported ? { kind: 'queue' } : { kind: 'unavailable', reason: 'unsupported' };\n}\n\nasync function readEnterpriseMergeSchema(graphql: GraphqlRequest) {\n\ttype Member = { name: string };\n\ttype Response = {\n\t\tmutation: { fields: Member[] } | null;\n\t\tpr: { fields: Member[] } | null;\n\t\tref: { fields: Member[] } | null;\n\t\tlegacy: { fields: Member[] } | null;\n\t\tenqueue: { inputFields: Member[] } | null;\n\t\tenqueuePayload: { fields: Member[] } | null;\n\t\tentry: { fields: Member[] } | null;\n\t\tmerge: { inputFields: Member[] } | null;\n\t};\n\tconst [operations, branch, queue] = await Promise.all([\n\t\tgraphql<Pick<Response, 'mutation' | 'pr' | 'enqueue' | 'merge'>>(\n\t\t\t`\n\t\t\t\tquery PullRequestMergeSchemaOperations {\n\t\t\t\t\tmutation: __type(name: \"Mutation\") {\n\t\t\t\t\t\tfields {\n\t\t\t\t\t\t\tname\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tpr: __type(name: \"PullRequest\") {\n\t\t\t\t\t\tfields {\n\t\t\t\t\t\t\tname\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tenqueue: __type(name: \"EnqueuePullRequestInput\") {\n\t\t\t\t\t\tinputFields {\n\t\t\t\t\t\t\tname\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tmerge: __type(name: \"MergePullRequestInput\") {\n\t\t\t\t\t\tinputFields {\n\t\t\t\t\t\t\tname\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t`,\n\t\t\t{},\n\t\t),\n\t\tgraphql<Pick<Response, 'ref' | 'legacy'>>(\n\t\t\t`\n\t\t\t\tquery PullRequestMergeSchemaBranch {\n\t\t\t\t\tref: __type(name: \"Ref\") {\n\t\t\t\t\t\tfields {\n\t\t\t\t\t\t\tname\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tlegacy: __type(name: \"RefUpdateRule\") {\n\t\t\t\t\t\tfields {\n\t\t\t\t\t\t\tname\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t`,\n\t\t\t{},\n\t\t),\n\t\tgraphql<Pick<Response, 'enqueuePayload' | 'entry'>>(\n\t\t\t`\n\t\t\t\tquery PullRequestMergeSchemaQueue {\n\t\t\t\t\tenqueuePayload: __type(name: \"EnqueuePullRequestPayload\") {\n\t\t\t\t\t\tfields {\n\t\t\t\t\t\t\tname\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tentry: __type(name: \"MergeQueueEntry\") {\n\t\t\t\t\t\tfields {\n\t\t\t\t\t\t\tname\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t`,\n\t\t\t{},\n\t\t),\n\t]);\n\tif (\n\t\t!Array.isArray(operations?.mutation?.fields) ||\n\t\t!Array.isArray(operations.pr?.fields) ||\n\t\toperations.enqueue === undefined ||\n\t\toperations.merge === undefined ||\n\t\tbranch?.ref === undefined ||\n\t\tbranch.legacy === undefined ||\n\t\tqueue?.enqueuePayload === undefined ||\n\t\tqueue.entry === undefined\n\t) {\n\t\treturn undefined;\n\t}\n\n\tconst has = (members: Member[] | undefined, ...names: string[]) =>\n\t\tnames.every(name => members?.some(member => member.name === name) === true);\n\tconst hasEnqueue = has(operations.mutation.fields, 'enqueuePullRequest');\n\treturn {\n\t\tstack: has(operations.pr.fields, 'stack'),\n\t\tqueueFields: has(operations.pr.fields, 'isInMergeQueue', 'isMergeQueueEnabled'),\n\t\thasQueue:\n\t\t\thasEnqueue ||\n\t\t\thas(operations.pr.fields, 'isInMergeQueue') ||\n\t\t\thas(operations.pr.fields, 'isMergeQueueEnabled'),\n\t\tcanEnqueue:\n\t\t\thasEnqueue &&\n\t\t\thas(operations.enqueue?.inputFields, 'pullRequestId', 'expectedHeadOid') &&\n\t\t\thas(queue.enqueuePayload?.fields, 'mergeQueueEntry') &&\n\t\t\thas(queue.entry?.fields, 'id', 'pullRequest'),\n\t\tcanMerge:\n\t\t\thas(operations.mutation.fields, 'mergePullRequest') &&\n\t\t\thas(operations.merge?.inputFields, 'pullRequestId', 'expectedHeadOid', 'mergeMethod'),\n\t\tlinearHistory: has(branch.ref?.fields, 'refUpdateRule') && has(branch.legacy?.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;MAcA,CAAC,CACF;EACA,QACC;;;;;;;;;;;;;MAcA,CAAC,CACF;CACD,CAAC;CACD,IACC,CAAC,MAAM,QAAQ,YAAY,UAAU,MAAM,KAC3C,CAAC,MAAM,QAAQ,WAAW,IAAI,MAAM,KACpC,WAAW,YAAY,KAAA,KACvB,WAAW,UAAU,KAAA,KACrB,QAAQ,QAAQ,KAAA,KAChB,OAAO,WAAW,KAAA,KAClB,OAAO,mBAAmB,KAAA,KAC1B,MAAM,UAAU,KAAA,GAEhB;CAGD,MAAM,OAAO,SAA+B,GAAG,UAC9C,MAAM,OAAM,SAAQ,SAAS,MAAK,WAAU,OAAO,SAAS,IAAI,MAAM,IAAI;CAC3E,MAAM,aAAa,IAAI,WAAW,SAAS,QAAQ,oBAAoB;CACvE,OAAO;EACN,OAAO,IAAI,WAAW,GAAG,QAAQ,OAAO;EACxC,aAAa,IAAI,WAAW,GAAG,QAAQ,kBAAkB,qBAAqB;EAC9E,UACC,cACA,IAAI,WAAW,GAAG,QAAQ,gBAAgB,KAC1C,IAAI,WAAW,GAAG,QAAQ,qBAAqB;EAChD,YACC,cACA,IAAI,WAAW,SAAS,aAAa,iBAAiB,iBAAiB,KACvE,IAAI,MAAM,gBAAgB,QAAQ,iBAAiB,KACnD,IAAI,MAAM,OAAO,QAAQ,MAAM,aAAa;EAC7C,UACC,IAAI,WAAW,SAAS,QAAQ,kBAAkB,KAClD,IAAI,WAAW,OAAO,aAAa,iBAAiB,mBAAmB,aAAa;EACrF,eAAe,IAAI,OAAO,KAAK,QAAQ,eAAe,KAAK,IAAI,OAAO,QAAQ,QAAQ,uBAAuB;CAC9G;AACD"}
|
|
@@ -13,9 +13,9 @@ import { PullRequestActivityPage } from "../../../git/models/pullRequestActivity
|
|
|
13
13
|
import { RepositoryMetadata } from "../../../git/models/repositoryMetadata.js";
|
|
14
14
|
import { GitHubBlame, GitHubBranch, GitHubCheckRunRef, GitHubCommit, GitHubCommitRef, GitHubContributor, GitHubIssueEtagInclude, GitHubIssueEtagNode, GitHubPagedResult, GitHubPullRequestEtagInclude, GitHubPullRequestEtagNode, GitHubPullRequestState, GitHubSshSigningKey, GitHubTag } from "../models.js";
|
|
15
15
|
import { GitHubApiConfig } from "./config.js";
|
|
16
|
+
import { GitHubPullRequestCreateTarget, GitHubPullRequestWrite, GitHubPullRequestWriteTarget, PullRequestCreateCapabilityResult, PullRequestWriteResult, PullRequestWriteTargetResult } from "./pullRequestWrites.js";
|
|
16
17
|
import { GitHubIssueMutation, IssueWriteResult } from "./issueWrites.js";
|
|
17
18
|
import { GitHubPullRequestActivityTarget } from "./pullRequestActivity.js";
|
|
18
|
-
import { GitHubPullRequestCreateTarget, GitHubPullRequestWrite, GitHubPullRequestWriteTarget, PullRequestCreateCapabilityResult, PullRequestWriteResult, PullRequestWriteTargetResult } from "./pullRequestWrites.js";
|
|
19
19
|
import { GitHubTokenInfo } from "./token.js";
|
|
20
20
|
import { Endpoints } from "@octokit/types";
|
|
21
21
|
//#region ../plus/git-github/src/api/github.d.ts
|
|
@@ -252,10 +252,13 @@ export declare class GitHubApi {
|
|
|
252
252
|
onUnauthorized?: () => void;
|
|
253
253
|
}): Promise<IssueWriteResult>;
|
|
254
254
|
getIssueWriteViewer(provider: Provider, token: GitHubTokenInfo, baseUrl: string | undefined, onUnauthorized: () => void): Promise<string | undefined>;
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
255
|
+
getWriteViewer(provider: Provider, token: GitHubTokenInfo, baseUrl: string | undefined, onUnauthorized: () => void): Promise<string | undefined>;
|
|
256
|
+
resolvePullRequestWriteTarget(provider: Provider, token: GitHubTokenInfo, input: GitHubPullRequestWriteTarget, onUnauthorized: () => void, baseUrl?: string): Promise<PullRequestWriteTargetResult>;
|
|
257
|
+
getPullRequestCreateCapability(provider: Provider, token: GitHubTokenInfo, input: GitHubPullRequestCreateTarget, onUnauthorized: () => void, baseUrl?: string): Promise<PullRequestCreateCapabilityResult>;
|
|
258
|
+
writePullRequest(provider: Provider, token: GitHubTokenInfo, input: GitHubPullRequestWrite, isSessionCurrent: () => Promise<boolean>, onUnauthorized: () => void, baseUrl?: string): Promise<PullRequestWriteResult>;
|
|
259
|
+
private enterprisePullRequestWriteOptions;
|
|
258
260
|
private writeGraphql;
|
|
261
|
+
private writeRequest;
|
|
259
262
|
private readonly _pendingGraphQL;
|
|
260
263
|
private graphql;
|
|
261
264
|
private request;
|
|
@@ -2027,31 +2027,61 @@ var GitHubApi = class {
|
|
|
2027
2027
|
});
|
|
2028
2028
|
}
|
|
2029
2029
|
async getIssueWriteViewer(provider, token, baseUrl, onUnauthorized) {
|
|
2030
|
-
return
|
|
2030
|
+
return this.getWriteViewer(provider, token, baseUrl, onUnauthorized);
|
|
2031
2031
|
}
|
|
2032
|
-
async
|
|
2033
|
-
return
|
|
2032
|
+
async getWriteViewer(provider, token, baseUrl, onUnauthorized) {
|
|
2033
|
+
return (await this.writeGraphql(provider, token, "query WriteViewer { viewer { login } }", {}, onUnauthorized, baseUrl))?.viewer?.login;
|
|
2034
2034
|
}
|
|
2035
|
-
async
|
|
2036
|
-
return
|
|
2035
|
+
async resolvePullRequestWriteTarget(provider, token, input, onUnauthorized, baseUrl) {
|
|
2036
|
+
return resolveGitHubPullRequestWriteTarget(input, (query, variables) => this.writeGraphql(provider, token, query, variables, onUnauthorized, baseUrl), this.enterprisePullRequestWriteOptions(provider, token, baseUrl, onUnauthorized));
|
|
2037
2037
|
}
|
|
2038
|
-
async
|
|
2039
|
-
|
|
2038
|
+
async getPullRequestCreateCapability(provider, token, input, onUnauthorized, baseUrl) {
|
|
2039
|
+
return getGitHubPullRequestCreateCapability(input, (query, variables) => this.writeGraphql(provider, token, query, variables, onUnauthorized, baseUrl));
|
|
2040
|
+
}
|
|
2041
|
+
async writePullRequest(provider, token, input, isSessionCurrent, onUnauthorized, baseUrl) {
|
|
2042
|
+
const request = (query, variables) => this.writeGraphql(provider, token, query, variables, onUnauthorized, baseUrl);
|
|
2040
2043
|
return writeGitHubPullRequest(input, {
|
|
2041
2044
|
graphql: request,
|
|
2045
|
+
enterprise: this.enterprisePullRequestWriteOptions(provider, token, baseUrl, onUnauthorized),
|
|
2042
2046
|
isSessionCurrent,
|
|
2043
2047
|
enqueue: (nodeId, headSha) => this.enqueuePullRequestForWrite(nodeId, headSha, request)
|
|
2044
2048
|
});
|
|
2045
2049
|
}
|
|
2050
|
+
enterprisePullRequestWriteOptions(provider, token, baseUrl, onUnauthorized) {
|
|
2051
|
+
if (baseUrl == null) return void 0;
|
|
2052
|
+
return {
|
|
2053
|
+
origin: new URL(baseUrl).origin,
|
|
2054
|
+
readBranchRules: async ({ owner, repo }, branch) => {
|
|
2055
|
+
const rules = [];
|
|
2056
|
+
for (let page = 1; page <= 100; page++) {
|
|
2057
|
+
const response = await this.writeRequest(provider, () => this.getDefaults(token.accessToken, request)("GET /repos/{owner}/{repo}/rules/branches/{branch}", {
|
|
2058
|
+
baseUrl,
|
|
2059
|
+
owner,
|
|
2060
|
+
repo,
|
|
2061
|
+
branch,
|
|
2062
|
+
page,
|
|
2063
|
+
per_page: 100,
|
|
2064
|
+
request: { redirect: "error" }
|
|
2065
|
+
}), true, onUnauthorized);
|
|
2066
|
+
if (!Array.isArray(response.data)) return void 0;
|
|
2067
|
+
rules.push(...response.data);
|
|
2068
|
+
if (!response.headers.link?.includes("rel=\"next\"")) return rules;
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
};
|
|
2072
|
+
}
|
|
2046
2073
|
async writeGraphql(provider, token, query, variables, onUnauthorized, baseUrl) {
|
|
2074
|
+
return this.writeRequest(provider, () => this.getDefaults(token.accessToken, graphql)(query, {
|
|
2075
|
+
...variables,
|
|
2076
|
+
...baseUrl == null ? { headers: { "x-github-next-global-id": "1" } } : {
|
|
2077
|
+
baseUrl,
|
|
2078
|
+
request: { redirect: "error" }
|
|
2079
|
+
}
|
|
2080
|
+
}), graphqlReadQueryRegex.test(query), onUnauthorized);
|
|
2081
|
+
}
|
|
2082
|
+
async writeRequest(provider, run, retryable, onUnauthorized) {
|
|
2047
2083
|
try {
|
|
2048
|
-
return await this.requestWithRetries(() => this.config.wrapForForcedInsecureSSL(provider.getIgnoreSSLErrors(),
|
|
2049
|
-
...variables,
|
|
2050
|
-
...baseUrl == null ? { headers: { "x-github-next-global-id": "1" } } : {
|
|
2051
|
-
baseUrl,
|
|
2052
|
-
request: { redirect: "error" }
|
|
2053
|
-
}
|
|
2054
|
-
})), graphqlReadQueryRegex.test(query), void 0, void 0);
|
|
2084
|
+
return await this.requestWithRetries(() => this.config.wrapForForcedInsecureSSL(provider.getIgnoreSSLErrors(), run), retryable, void 0, void 0);
|
|
2055
2085
|
} catch (ex) {
|
|
2056
2086
|
if (ex instanceof RequestError && ex.status === 401) onUnauthorized?.();
|
|
2057
2087
|
throw ex;
|