@gitkraken/core-gitlens 0.32.0 → 0.34.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 +42 -1
- package/dist/git/cache.d.ts +121 -15
- package/dist/git/cache.js +316 -74
- package/dist/git/cache.js.map +1 -1
- package/dist/git/context.d.ts +3 -1
- package/dist/git/context.js.map +1 -1
- package/dist/git/errors.d.ts +3 -1
- package/dist/git/errors.js +4 -1
- package/dist/git/errors.js.map +1 -1
- package/dist/git/models/pullRequest.d.ts +90 -1
- package/dist/git/models/pullRequest.js +18 -2
- package/dist/git/models/pullRequest.js.map +1 -1
- package/dist/git/models/repositoryIdentities.d.ts +0 -1
- package/dist/git/models/repositoryIdentities.js +1 -4
- package/dist/git/models/repositoryIdentities.js.map +1 -1
- package/dist/git/providers/provider.d.ts +7 -0
- package/dist/git/providers/shared/remotes.js +2 -0
- package/dist/git/providers/shared/remotes.js.map +1 -1
- package/dist/git/remotes/gitlab.js +15 -9
- package/dist/git/remotes/gitlab.js.map +1 -1
- package/dist/git/service.js +4 -1
- package/dist/git/service.js.map +1 -1
- package/dist/git/utils/pullRequest.utils.d.ts +72 -1
- package/dist/git/utils/pullRequest.utils.js +99 -1
- package/dist/git/utils/pullRequest.utils.js.map +1 -1
- package/dist/git/utils/repository.utils.d.ts +16 -0
- package/dist/git/utils/repository.utils.js +37 -2
- package/dist/git/utils/repository.utils.js.map +1 -1
- package/dist/git/watching/changeEvent.d.ts +13 -3
- package/dist/git/watching/changeEvent.js +19 -4
- package/dist/git/watching/changeEvent.js.map +1 -1
- package/dist/git/watching/gitDirPoller.d.ts +10 -1
- package/dist/git/watching/gitDirPoller.js +9 -3
- package/dist/git/watching/gitDirPoller.js.map +1 -1
- package/dist/git/watching/unwatchedCacheValidator.d.ts +144 -0
- package/dist/git/watching/unwatchedCacheValidator.js +884 -0
- package/dist/git/watching/unwatchedCacheValidator.js.map +1 -0
- package/dist/git/watching/watchGroup.d.ts +6 -2
- package/dist/git/watching/watchGroup.js +35 -24
- package/dist/git/watching/watchGroup.js.map +1 -1
- package/dist/git/watching/watchService.d.ts +27 -1
- package/dist/git/watching/watchService.js +60 -17
- package/dist/git/watching/watchService.js.map +1 -1
- package/dist/git/watching/watchSession.d.ts +29 -12
- package/dist/git/watching/watchSession.js +52 -21
- package/dist/git/watching/watchSession.js.map +1 -1
- package/dist/git/watching/worktreeSummary.js +7 -7
- package/dist/git/watching/worktreeSummary.js.map +1 -1
- package/dist/git-cli/cliGitProvider.d.ts +28 -2
- package/dist/git-cli/cliGitProvider.js +63 -20
- package/dist/git-cli/cliGitProvider.js.map +1 -1
- package/dist/git-cli/exec/commandClassifier.d.ts +31 -1
- package/dist/git-cli/exec/commandClassifier.js +67 -16
- package/dist/git-cli/exec/commandClassifier.js.map +1 -1
- package/dist/git-cli/exec/git.d.ts +46 -2
- package/dist/git-cli/exec/git.js +87 -9
- package/dist/git-cli/exec/git.js.map +1 -1
- package/dist/git-cli/exec/gitDirResolver.d.ts +11 -0
- package/dist/git-cli/exec/gitDirResolver.js +34 -1
- package/dist/git-cli/exec/gitDirResolver.js.map +1 -1
- package/dist/git-cli/exec/gitQueue.js +2 -28
- package/dist/git-cli/exec/gitQueue.js.map +1 -1
- package/dist/git-cli/providers/branches.d.ts +1 -0
- package/dist/git-cli/providers/branches.js +21 -10
- package/dist/git-cli/providers/branches.js.map +1 -1
- package/dist/git-cli/providers/config.d.ts +15 -1
- package/dist/git-cli/providers/config.js +67 -22
- package/dist/git-cli/providers/config.js.map +1 -1
- package/dist/git-cli/providers/pausedOperations.d.ts +1 -0
- package/dist/git-cli/providers/pausedOperations.js +4 -0
- package/dist/git-cli/providers/pausedOperations.js.map +1 -1
- package/dist/git-cli/providers/revision.js +2 -0
- package/dist/git-cli/providers/revision.js.map +1 -1
- package/dist/git-cli/providers/worktrees.js +36 -10
- package/dist/git-cli/providers/worktrees.js.map +1 -1
- package/dist/git-cli/service.d.ts +25 -1
- package/dist/git-cli/service.js +46 -1
- package/dist/git-cli/service.js.map +1 -1
- package/dist/plus/ai/errors.d.ts +8 -2
- package/dist/plus/ai/errors.js +15 -3
- package/dist/plus/ai/errors.js.map +1 -1
- package/dist/plus/git-github/api/github.d.ts +51 -1
- package/dist/plus/git-github/api/github.js +276 -3
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/models.d.ts +54 -1
- package/dist/plus/git-github/models.js +48 -3
- package/dist/plus/git-github/models.js.map +1 -1
- package/dist/plus/integrations/fieldPresence.d.ts +6 -1
- package/dist/plus/integrations/fieldPresence.js +19 -9
- package/dist/plus/integrations/fieldPresence.js.map +1 -1
- package/dist/plus/integrations/models/gitHostIntegration.d.ts +26 -1
- package/dist/plus/integrations/models/gitHostIntegration.js +51 -0
- package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
- package/dist/plus/integrations/models/integration.d.ts +15 -2
- package/dist/plus/integrations/models/integration.js +1 -1
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/providers/github.d.ts +16 -1
- package/dist/plus/integrations/providers/github.js +53 -1
- package/dist/plus/integrations/providers/github.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/gitlab.d.ts +10 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.js +62 -15
- package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.d.ts +8 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.js +32 -16
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.js.map +1 -1
- package/dist/plus/integrations/reads/etag.js +11 -0
- package/dist/plus/integrations/reads/etag.js.map +1 -1
- package/docs/integrations.md +39 -6
- package/package.json +1 -1
|
@@ -17,7 +17,7 @@ import { defaultIssueSort } from "../../../git/models/issue.js";
|
|
|
17
17
|
import "../../../git/models/pullRequest.js";
|
|
18
18
|
import { effectiveIssueSort, getIssueComparator } from "../../../git/utils/issue.utils.js";
|
|
19
19
|
import { getPullRequestComparator } from "../../../git/utils/pullRequest.utils.js";
|
|
20
|
-
import { fromGitHubIssue, fromGitHubIssueOrPullRequestState, fromGitHubPullRequest, fromGitHubPullRequestLite } from "../models.js";
|
|
20
|
+
import { fromGitHubIssue, fromGitHubIssueOrPullRequestState, fromGitHubMergeQueueEntry, fromGitHubPullRequest, fromGitHubPullRequestLite } from "../models.js";
|
|
21
21
|
import { githubSearchResultLimit } from "./config.js";
|
|
22
22
|
import { gitHubIssueSearchRelationships, toGitHubIssueSearchQualifiers, toGitHubIssueSearchScopeQualifiers, toGitHubIssueSearchSlideQualifier, toGitHubIssueSortQualifier } from "./issueSearchQuery.js";
|
|
23
23
|
import { toGitHubPullRequestSearchFacets } from "./pullRequestSearchQuery.js";
|
|
@@ -146,6 +146,50 @@ stackEntry {
|
|
|
146
146
|
function gqlPullRequestStackFragmentFor(options) {
|
|
147
147
|
return isGitHubDotCom(options) ? gqlPullRequestStackFragment : "";
|
|
148
148
|
}
|
|
149
|
+
/** A `MergeQueueEntry`'s selection, shared by the per-pull-request fragment and the per-branch queue read so both
|
|
150
|
+
* answer the one `GitHubMergeQueueEntry` shape `fromGitHubMergeQueueEntry` maps. */
|
|
151
|
+
const gqlMergeQueueEntryFields = `
|
|
152
|
+
state
|
|
153
|
+
enqueuedAt
|
|
154
|
+
estimatedTimeToMerge
|
|
155
|
+
mergeQueue {
|
|
156
|
+
url
|
|
157
|
+
}
|
|
158
|
+
position
|
|
159
|
+
`;
|
|
160
|
+
/**
|
|
161
|
+
* The pull request's latest merge-queue event, which `fromGitHubMergeQueueRemoval` reads for a removal that hasn't
|
|
162
|
+
* been followed by a rejoin. Shared by the full read and the etag's cheap check so both derive the same removal.
|
|
163
|
+
* Aliased so it can never collide with another `timelineItems` selection. One extra connection per pull request:
|
|
164
|
+
* against GitHub's rate-limit formula (a request per connection per parent node, summed, divided by 100) that adds
|
|
165
|
+
* a point per 100 pull requests a document reads — see the `mergeQueue` cost note in core's integrations docs.
|
|
166
|
+
*/
|
|
167
|
+
const gqlPullRequestMergeQueueEventsFragment = `
|
|
168
|
+
mergeQueueEvents: timelineItems(last: 1, itemTypes: [ADDED_TO_MERGE_QUEUE_EVENT, REMOVED_FROM_MERGE_QUEUE_EVENT]) {
|
|
169
|
+
nodes {
|
|
170
|
+
__typename
|
|
171
|
+
... on RemovedFromMergeQueueEvent {
|
|
172
|
+
createdAt
|
|
173
|
+
reason
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
`;
|
|
178
|
+
/**
|
|
179
|
+
* Merge-queue selection, appended alongside the stack one and for the same reason: GitHub Enterprise Server's schema
|
|
180
|
+
* isn't verified to have `mergeQueueEntry`, and an unknown field fails the whole query rather than the field. Always
|
|
181
|
+
* add it via `gqlPullRequestMergeQueueFragmentFor`, at every site that adds the stack selection.
|
|
182
|
+
*/
|
|
183
|
+
const gqlPullRequestMergeQueueFragment = `
|
|
184
|
+
mergeQueueEntry {
|
|
185
|
+
${gqlMergeQueueEntryFields}
|
|
186
|
+
}
|
|
187
|
+
isMergeQueueEnabled
|
|
188
|
+
${gqlPullRequestMergeQueueEventsFragment}
|
|
189
|
+
`;
|
|
190
|
+
function gqlPullRequestMergeQueueFragmentFor(options) {
|
|
191
|
+
return isGitHubDotCom(options) ? gqlPullRequestMergeQueueFragment : "";
|
|
192
|
+
}
|
|
149
193
|
/**
|
|
150
194
|
* A 409 means a merge request is already in flight and carries its ticket, so it resumes rather than fails.
|
|
151
195
|
*
|
|
@@ -322,7 +366,8 @@ repository {
|
|
|
322
366
|
* The change state a pull request's etag reads (see {@link GitHubPullRequestEtagNode}). Every selection is copied
|
|
323
367
|
* from {@link gqlPullRequestFragment} — same arguments, same nesting — so the cheap read sees exactly the values
|
|
324
368
|
* the full read maps; only a requested reviewer drops its avatar and URL, since its nullness is all the etag reads.
|
|
325
|
-
* `merged` is not needed: `state` already reads `MERGED`.
|
|
369
|
+
* `merged` is not needed: `state` already reads `MERGED`. The merge-queue entry's state is added against github.com
|
|
370
|
+
* only, by {@link gqlPullRequestEtagMergeQueueFragmentFor}, as the full read adds its entry.
|
|
326
371
|
*/
|
|
327
372
|
const gqlPullRequestEtagFragment = `
|
|
328
373
|
id
|
|
@@ -333,6 +378,24 @@ updatedAt
|
|
|
333
378
|
headRefOid
|
|
334
379
|
`;
|
|
335
380
|
/**
|
|
381
|
+
* The slice of {@link gqlPullRequestMergeQueueFragment} a pull request's etag reads: whether it's queued, in which
|
|
382
|
+
* state, and since when (so leaving and rejoining the queue between checks still reads as a change), and its latest
|
|
383
|
+
* merge-queue event, so a pull request that joined and was removed between two checks (neither of which moves the
|
|
384
|
+
* update time) still reads as a change. Not the estimate, which GitHub recomputes as the queue moves and would fail
|
|
385
|
+
* every check of a queued pull request, nor the position, which moves as the entries ahead of it merge, nor
|
|
386
|
+
* `isMergeQueueEnabled`, which only a change to the base branch's rules moves.
|
|
387
|
+
*/
|
|
388
|
+
const gqlPullRequestEtagMergeQueueFragment = `
|
|
389
|
+
mergeQueueEntry {
|
|
390
|
+
state
|
|
391
|
+
enqueuedAt
|
|
392
|
+
}
|
|
393
|
+
${gqlPullRequestMergeQueueEventsFragment}
|
|
394
|
+
`;
|
|
395
|
+
function gqlPullRequestEtagMergeQueueFragmentFor(options) {
|
|
396
|
+
return isGitHubDotCom(options) ? gqlPullRequestEtagMergeQueueFragment : "";
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
336
399
|
* The selection each {@link GitHubPullRequestEtagInclude} adds to {@link gqlPullRequestEtagFragment}, copied from
|
|
337
400
|
* {@link gqlPullRequestFragment} like it.
|
|
338
401
|
*/
|
|
@@ -659,6 +722,7 @@ var GitHubApi = class {
|
|
|
659
722
|
pullRequest(number: $number) {
|
|
660
723
|
${gqlPullRequestLiteFragment}
|
|
661
724
|
${gqlPullRequestStackFragmentFor(options)}
|
|
725
|
+
${gqlPullRequestMergeQueueFragmentFor(options)}
|
|
662
726
|
}
|
|
663
727
|
}
|
|
664
728
|
}`;
|
|
@@ -692,6 +756,7 @@ var GitHubApi = class {
|
|
|
692
756
|
nodes {
|
|
693
757
|
${gqlPullRequestLiteFragment}
|
|
694
758
|
${gqlPullRequestStackFragmentFor(options)}
|
|
759
|
+
${gqlPullRequestMergeQueueFragmentFor(options)}
|
|
695
760
|
}
|
|
696
761
|
}
|
|
697
762
|
}
|
|
@@ -729,6 +794,7 @@ var GitHubApi = class {
|
|
|
729
794
|
nodes {
|
|
730
795
|
${gqlPullRequestLiteFragment}
|
|
731
796
|
${gqlPullRequestStackFragmentFor(options)}
|
|
797
|
+
${gqlPullRequestMergeQueueFragmentFor(options)}
|
|
732
798
|
}
|
|
733
799
|
}
|
|
734
800
|
}
|
|
@@ -2095,6 +2161,7 @@ var GitHubApi = class {
|
|
|
2095
2161
|
...on PullRequest {
|
|
2096
2162
|
${options?.summary ? gqlPullRequestLiteFragment : gqlPullRequestFragment}
|
|
2097
2163
|
${gqlPullRequestStackFragmentFor(options)}
|
|
2164
|
+
${gqlPullRequestMergeQueueFragmentFor(options)}
|
|
2098
2165
|
}
|
|
2099
2166
|
}
|
|
2100
2167
|
}
|
|
@@ -2429,6 +2496,7 @@ var GitHubApi = class {
|
|
|
2429
2496
|
pullRequest(number: $k${i}) {
|
|
2430
2497
|
${gqlPullRequestFragment}
|
|
2431
2498
|
${gqlPullRequestStackFragmentFor(options)}
|
|
2499
|
+
${gqlPullRequestMergeQueueFragmentFor(options)}
|
|
2432
2500
|
}
|
|
2433
2501
|
}`).join("\n ")}
|
|
2434
2502
|
}`;
|
|
@@ -2493,6 +2561,7 @@ var GitHubApi = class {
|
|
|
2493
2561
|
${coordinates.map((_, i) => `p${i}: repository(owner: $o${i}, name: $n${i}) {
|
|
2494
2562
|
pullRequest(number: $k${i}) {
|
|
2495
2563
|
${gqlPullRequestEtagFragment}
|
|
2564
|
+
${gqlPullRequestEtagMergeQueueFragmentFor(options)}
|
|
2496
2565
|
${includeFragments.join("")}
|
|
2497
2566
|
}
|
|
2498
2567
|
}`).join("\n ")}
|
|
@@ -2616,6 +2685,7 @@ var GitHubApi = class {
|
|
|
2616
2685
|
nodes {
|
|
2617
2686
|
${gqlPullRequestFragment}
|
|
2618
2687
|
${gqlPullRequestStackFragmentFor(options)}
|
|
2688
|
+
${gqlPullRequestMergeQueueFragmentFor(options)}
|
|
2619
2689
|
headRepositoryOwner {
|
|
2620
2690
|
login
|
|
2621
2691
|
}
|
|
@@ -3016,6 +3086,7 @@ var GitHubApi = class {
|
|
|
3016
3086
|
... on PullRequest {
|
|
3017
3087
|
${options?.summary ? gqlPullRequestLiteFragment : gqlPullRequestFragment}
|
|
3018
3088
|
${gqlPullRequestStackFragmentFor(options)}
|
|
3089
|
+
${gqlPullRequestMergeQueueFragmentFor(options)}
|
|
3019
3090
|
}
|
|
3020
3091
|
}
|
|
3021
3092
|
}`);
|
|
@@ -3116,6 +3187,7 @@ var GitHubApi = class {
|
|
|
3116
3187
|
...on PullRequest {
|
|
3117
3188
|
${gqlPullRequestFragment}
|
|
3118
3189
|
${gqlPullRequestStackFragmentFor(options)}
|
|
3190
|
+
${gqlPullRequestMergeQueueFragmentFor(options)}
|
|
3119
3191
|
}
|
|
3120
3192
|
}
|
|
3121
3193
|
}`;
|
|
@@ -3179,6 +3251,62 @@ var GitHubApi = class {
|
|
|
3179
3251
|
}
|
|
3180
3252
|
}
|
|
3181
3253
|
/**
|
|
3254
|
+
* The merge-queue entries of the given base branches, keyed by pull request number, in one request — each
|
|
3255
|
+
* branch's queue is an alias on the one `repository` selection. For list surfaces whose pull requests arrive
|
|
3256
|
+
* through provider-apis' repository-scoped read, which selects no `mergeQueueEntry`; callers join by number.
|
|
3257
|
+
*
|
|
3258
|
+
* INTERIM: remove once provider-apis carries the merge-queue entry on its pull requests (goals S6).
|
|
3259
|
+
*
|
|
3260
|
+
* github.com only, like the `mergeQueueEntry` selection: `undefined` on GitHub Enterprise Server, whose schema
|
|
3261
|
+
* isn't verified to have `mergeQueue`, and for a repository GitHub reports not found. A branch without a queue
|
|
3262
|
+
* contributes nothing. At most the first 100 entries of each queue are read.
|
|
3263
|
+
*/
|
|
3264
|
+
async getMergeQueueEntriesForBranches(provider, token, owner, repo, branches, options, cancellation) {
|
|
3265
|
+
const scope = getScopedLogger();
|
|
3266
|
+
if (!isGitHubDotCom(options)) return void 0;
|
|
3267
|
+
const byNumber = /* @__PURE__ */ new Map();
|
|
3268
|
+
if (!branches.length) return byNumber;
|
|
3269
|
+
const query = `query getMergeQueueEntriesForBranches(
|
|
3270
|
+
$owner: String!
|
|
3271
|
+
$repo: String!
|
|
3272
|
+
${branches.map((_, i) => `$b${i}: String!`).join("\n ")}
|
|
3273
|
+
) {
|
|
3274
|
+
repository(owner: $owner, name: $repo) {
|
|
3275
|
+
${branches.map((_, i) => `b${i}: mergeQueue(branch: $b${i}) {
|
|
3276
|
+
entries(first: 100) {
|
|
3277
|
+
nodes {
|
|
3278
|
+
${gqlMergeQueueEntryFields}
|
|
3279
|
+
pullRequest {
|
|
3280
|
+
number
|
|
3281
|
+
}
|
|
3282
|
+
}
|
|
3283
|
+
}
|
|
3284
|
+
}`).join("\n ")}
|
|
3285
|
+
}
|
|
3286
|
+
}`;
|
|
3287
|
+
const variables = {
|
|
3288
|
+
baseUrl: options?.baseUrl,
|
|
3289
|
+
owner,
|
|
3290
|
+
repo
|
|
3291
|
+
};
|
|
3292
|
+
branches.forEach((branch, i) => {
|
|
3293
|
+
variables[`b${i}`] = branch;
|
|
3294
|
+
});
|
|
3295
|
+
try {
|
|
3296
|
+
const rsp = await this.graphql(provider, token, query, variables, scope, cancellation);
|
|
3297
|
+
if (rsp?.repository == null) return void 0;
|
|
3298
|
+
for (const queue of Object.values(rsp.repository)) for (const node of queue?.entries?.nodes ?? []) {
|
|
3299
|
+
if (node?.pullRequest == null) continue;
|
|
3300
|
+
byNumber.set(node.pullRequest.number, fromGitHubMergeQueueEntry(node));
|
|
3301
|
+
}
|
|
3302
|
+
return byNumber;
|
|
3303
|
+
} catch (ex) {
|
|
3304
|
+
if (isCancellationError(ex)) throw ex;
|
|
3305
|
+
if (ex instanceof RequestNotFoundError) return void 0;
|
|
3306
|
+
throw this.handleException(ex, provider, scope, true);
|
|
3307
|
+
}
|
|
3308
|
+
}
|
|
3309
|
+
/**
|
|
3182
3310
|
* Merges a stacked pull request, and with it every layer below it.
|
|
3183
3311
|
*
|
|
3184
3312
|
* Stacks cannot go through `mergePullRequest` — GitHub rejects stacked pull requests on the legacy
|
|
@@ -3263,6 +3391,90 @@ var GitHubApi = class {
|
|
|
3263
3391
|
throw this.handleException(ex, provider, scope);
|
|
3264
3392
|
}
|
|
3265
3393
|
}
|
|
3394
|
+
/**
|
|
3395
|
+
* Adds a pull request to its base branch's merge queue, at the back (no `jump`). GitHub takes no merge method here:
|
|
3396
|
+
* the base branch's ruleset decides it. `expectedHeadSha` makes GitHub refuse a head that moved since it was read.
|
|
3397
|
+
*
|
|
3398
|
+
* GitHub's refusals come back as a `failed` result saying why (see {@link toGitHubMergeQueueActionFailure}),
|
|
3399
|
+
* without prompting to re-authenticate on a FORBIDDEN, which here means the account may not queue, not that the
|
|
3400
|
+
* token is bad. A failure to reach GitHub, a refused credential or a rate limit is thrown as from any other request,
|
|
3401
|
+
* and cancellation throws `CancellationError`. Like every mutation it is never retried. github.com only, like the
|
|
3402
|
+
* merge-queue reads: `unsupported` on GitHub Enterprise Server, whose schema isn't verified to have it.
|
|
3403
|
+
*/
|
|
3404
|
+
async enqueuePullRequest(provider, token, nodeId, expectedHeadSha, options, cancellation) {
|
|
3405
|
+
const scope = getScopedLogger();
|
|
3406
|
+
if (!isGitHubDotCom(options)) return {
|
|
3407
|
+
status: "failed",
|
|
3408
|
+
reason: "unsupported"
|
|
3409
|
+
};
|
|
3410
|
+
try {
|
|
3411
|
+
const query = `mutation enqueuePullRequest(
|
|
3412
|
+
$id: ID!
|
|
3413
|
+
$expectedHeadOid: GitObjectID!
|
|
3414
|
+
) {
|
|
3415
|
+
enqueuePullRequest(input: { pullRequestId: $id, expectedHeadOid: $expectedHeadOid }) {
|
|
3416
|
+
mergeQueueEntry {
|
|
3417
|
+
${gqlMergeQueueEntryFields}
|
|
3418
|
+
}
|
|
3419
|
+
}
|
|
3420
|
+
}`;
|
|
3421
|
+
const entry = (await this.graphql(provider, token, query, {
|
|
3422
|
+
id: nodeId,
|
|
3423
|
+
expectedHeadOid: expectedHeadSha,
|
|
3424
|
+
baseUrl: options?.baseUrl
|
|
3425
|
+
}, scope, cancellation))?.enqueuePullRequest?.mergeQueueEntry;
|
|
3426
|
+
return {
|
|
3427
|
+
status: "queued",
|
|
3428
|
+
entry: entry != null ? fromGitHubMergeQueueEntry(entry) : void 0
|
|
3429
|
+
};
|
|
3430
|
+
} catch (ex) {
|
|
3431
|
+
if (isCancellationError(ex)) throw ex;
|
|
3432
|
+
const failure = toGitHubMergeQueueActionFailure(ex);
|
|
3433
|
+
if (failure != null) {
|
|
3434
|
+
scope?.warn(`GitHub refused to enqueue: ${failure.reason} (${failure.message})`);
|
|
3435
|
+
return {
|
|
3436
|
+
status: "failed",
|
|
3437
|
+
...failure
|
|
3438
|
+
};
|
|
3439
|
+
}
|
|
3440
|
+
throw this.handleException(ex, provider, scope);
|
|
3441
|
+
}
|
|
3442
|
+
}
|
|
3443
|
+
/**
|
|
3444
|
+
* Removes a pull request from its base branch's merge queue, losing its place there. Fails and throws as
|
|
3445
|
+
* {@link enqueuePullRequest} does, and is github.com only like it.
|
|
3446
|
+
*/
|
|
3447
|
+
async dequeuePullRequest(provider, token, nodeId, options, cancellation) {
|
|
3448
|
+
const scope = getScopedLogger();
|
|
3449
|
+
if (!isGitHubDotCom(options)) return {
|
|
3450
|
+
status: "failed",
|
|
3451
|
+
reason: "unsupported"
|
|
3452
|
+
};
|
|
3453
|
+
try {
|
|
3454
|
+
await this.graphql(provider, token, `mutation dequeuePullRequest($id: ID!) {
|
|
3455
|
+
dequeuePullRequest(input: { id: $id }) {
|
|
3456
|
+
mergeQueueEntry {
|
|
3457
|
+
id
|
|
3458
|
+
}
|
|
3459
|
+
}
|
|
3460
|
+
}`, {
|
|
3461
|
+
id: nodeId,
|
|
3462
|
+
baseUrl: options?.baseUrl
|
|
3463
|
+
}, scope, cancellation);
|
|
3464
|
+
return { status: "dequeued" };
|
|
3465
|
+
} catch (ex) {
|
|
3466
|
+
if (isCancellationError(ex)) throw ex;
|
|
3467
|
+
const failure = toGitHubMergeQueueActionFailure(ex);
|
|
3468
|
+
if (failure != null) {
|
|
3469
|
+
scope?.warn(`GitHub refused to dequeue: ${failure.reason} (${failure.message})`);
|
|
3470
|
+
return {
|
|
3471
|
+
status: "failed",
|
|
3472
|
+
...failure
|
|
3473
|
+
};
|
|
3474
|
+
}
|
|
3475
|
+
throw this.handleException(ex, provider, scope);
|
|
3476
|
+
}
|
|
3477
|
+
}
|
|
3266
3478
|
};
|
|
3267
3479
|
__decorate([trace({ args: (provider, token, owner, repo, rev) => ({
|
|
3268
3480
|
provider: provider.name,
|
|
@@ -3547,6 +3759,13 @@ __decorate([trace({ args: (provider, token, owner, repo) => ({
|
|
|
3547
3759
|
owner,
|
|
3548
3760
|
repo
|
|
3549
3761
|
}) })], GitHubApi.prototype, "getRepositoryStacks", null);
|
|
3762
|
+
__decorate([trace({ args: (provider, token, owner, repo, branches) => ({
|
|
3763
|
+
provider: provider.name,
|
|
3764
|
+
token: `<token:${token.microHash}>`,
|
|
3765
|
+
owner,
|
|
3766
|
+
repo,
|
|
3767
|
+
branches: branches.join(",")
|
|
3768
|
+
}) })], GitHubApi.prototype, "getMergeQueueEntriesForBranches", null);
|
|
3550
3769
|
__decorate([trace({ args: (provider, token, owner, repo, pullNumber, expectedSourceSha) => ({
|
|
3551
3770
|
provider: provider.name,
|
|
3552
3771
|
token: `<token:${token.microHash}>`,
|
|
@@ -3561,6 +3780,60 @@ __decorate([trace({ args: (provider, token, nodeId, expectedSourceSha) => ({
|
|
|
3561
3780
|
nodeId,
|
|
3562
3781
|
expectedSourceSha
|
|
3563
3782
|
}) })], GitHubApi.prototype, "mergePullRequest", null);
|
|
3783
|
+
__decorate([trace({ args: (provider, token, nodeId, expectedHeadSha) => ({
|
|
3784
|
+
provider: provider.name,
|
|
3785
|
+
token: `<token:${token.microHash}>`,
|
|
3786
|
+
nodeId,
|
|
3787
|
+
expectedHeadSha
|
|
3788
|
+
}) })], GitHubApi.prototype, "enqueuePullRequest", null);
|
|
3789
|
+
__decorate([trace({ args: (provider, token, nodeId) => ({
|
|
3790
|
+
provider: provider.name,
|
|
3791
|
+
token: `<token:${token.microHash}>`,
|
|
3792
|
+
nodeId
|
|
3793
|
+
}) })], GitHubApi.prototype, "dequeuePullRequest", null);
|
|
3794
|
+
/**
|
|
3795
|
+
* The wordings {@link toGitHubMergeQueueActionFailure} recognizes, tried in order against the lowercased message.
|
|
3796
|
+
* Each was observed live (2026-11-06) as a GraphQL `UNPROCESSABLE` error, and is matched tightly to GitHub's fixed
|
|
3797
|
+
* phrasing: "Pull request is already in the queue" (enqueue of a queued pull request), "Failed to add PR #N: expected
|
|
3798
|
+
* head oid does not match the current head oid" (enqueue at a stale head), "Pull request is closed" (enqueue of a
|
|
3799
|
+
* merged or closed pull request) and "Pull request is in draft" (enqueue of a draft). Dequeue of a pull request that isn't queued is refused with only the generic
|
|
3800
|
+
* `Failed to remove PR #N "<title>"`, which embeds the pull request's title, so it matches nothing here (a title like
|
|
3801
|
+
* "Fix merge conflict" must not read as a conflict) and falls through to `unknown`.
|
|
3802
|
+
*/
|
|
3803
|
+
const mergeQueueActionFailurePatterns = [
|
|
3804
|
+
["already-queued", /\bis already in the queue\b/],
|
|
3805
|
+
["head-changed", /\bexpected head oid does not match\b/],
|
|
3806
|
+
["not-allowed", /^pull request is (?:closed|in draft)\b/]
|
|
3807
|
+
];
|
|
3808
|
+
/**
|
|
3809
|
+
* Why GitHub refused to add a pull request to its merge queue or remove it, from the error its GraphQL answer carried
|
|
3810
|
+
* (`errors[]`, which `graphql` throws as a `GraphqlResponseError`, or wraps in an `AuthenticationError` for FORBIDDEN
|
|
3811
|
+
* and a `RequestNotFoundError` for NOT_FOUND). `undefined` for anything that isn't GitHub's answer about the action
|
|
3812
|
+
* — a failure to reach it, a refused credential (HTTP 401/403), a rate limit — which the caller handles like any
|
|
3813
|
+
* other request's failure.
|
|
3814
|
+
*
|
|
3815
|
+
* Only the wordings observed live (2026-11-06; see {@link mergeQueueActionFailurePatterns}) are recognized. Dequeue's
|
|
3816
|
+
* refusal is generic and embeds the pull request's title, so it is never matched by wording and maps to `unknown`.
|
|
3817
|
+
* When no message matches, the error's `type` decides (FORBIDDEN is `permission`), and anything else is `unknown`.
|
|
3818
|
+
* The message is GitHub's own, for logs, never for display.
|
|
3819
|
+
*/
|
|
3820
|
+
function toGitHubMergeQueueActionFailure(ex) {
|
|
3821
|
+
const original = ex instanceof AuthenticationError || ex instanceof RequestNotFoundError ? ex.original : ex;
|
|
3822
|
+
if (!(original instanceof GraphqlResponseError)) return void 0;
|
|
3823
|
+
const error = original.errors?.[0];
|
|
3824
|
+
if (error == null) return void 0;
|
|
3825
|
+
const message = error.message ?? "";
|
|
3826
|
+
const text = message.toLowerCase();
|
|
3827
|
+
const matched = mergeQueueActionFailurePatterns.find(([, pattern]) => pattern.test(text));
|
|
3828
|
+
if (matched != null) return {
|
|
3829
|
+
reason: matched[0],
|
|
3830
|
+
message
|
|
3831
|
+
};
|
|
3832
|
+
return {
|
|
3833
|
+
reason: error.type === "FORBIDDEN" ? "permission" : "unknown",
|
|
3834
|
+
message
|
|
3835
|
+
};
|
|
3836
|
+
}
|
|
3564
3837
|
/**
|
|
3565
3838
|
* Every issue read's presence table assumes the body was selected, so a read without `includeBody` is left
|
|
3566
3839
|
* untagged (unknown) rather than claiming a description it never fetched.
|
|
@@ -3597,6 +3870,6 @@ function requiresGitHubPullRequestStateFacets(include) {
|
|
|
3597
3870
|
return uniqueStates.size === 2 && uniqueStates.has("opened") && uniqueStates.has("merged");
|
|
3598
3871
|
}
|
|
3599
3872
|
//#endregion
|
|
3600
|
-
export { GitHubApi, filterPullRequestsBySearchState, toGitHubSearchStateQualifier };
|
|
3873
|
+
export { GitHubApi, filterPullRequestsBySearchState, toGitHubMergeQueueActionFailure, toGitHubSearchStateQualifier };
|
|
3601
3874
|
|
|
3602
3875
|
//# sourceMappingURL=github.js.map
|