@gitkraken/core-gitlens 0.33.0 → 0.35.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 +23 -1
- package/dist/git/cache.d.ts +31 -0
- package/dist/git/cache.js +101 -30
- 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/providers/shared/remotes.js +2 -0
- package/dist/git/providers/shared/remotes.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 +6 -0
- package/dist/git/utils/repository.utils.js +14 -2
- package/dist/git/utils/repository.utils.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 +2 -0
- package/dist/git/watching/watchGroup.js +4 -8
- package/dist/git/watching/watchGroup.js.map +1 -1
- package/dist/git/watching/watchService.d.ts +23 -0
- package/dist/git/watching/watchService.js +42 -2
- package/dist/git/watching/watchService.js.map +1 -1
- package/dist/git/watching/watchSession.d.ts +2 -0
- package/dist/git/watching/watchSession.js +3 -2
- package/dist/git/watching/watchSession.js.map +1 -1
- package/dist/git-cli/cliGitProvider.js +1 -1
- 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 +80 -7
- 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 +6 -0
- package/dist/git-cli/providers/branches.js.map +1 -1
- package/dist/git-cli/providers/config.d.ts +13 -1
- package/dist/git-cli/providers/config.js +48 -14
- 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 +2 -0
- 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 +45 -0
- 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/config.d.ts +11 -0
- package/dist/plus/git-github/api/config.js.map +1 -1
- package/dist/plus/git-github/api/github.d.ts +82 -1
- package/dist/plus/git-github/api/github.js +304 -7
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/models.d.ts +61 -1
- package/dist/plus/git-github/models.js +49 -3
- package/dist/plus/git-github/models.js.map +1 -1
- package/dist/plus/integrations/context.d.ts +12 -0
- package/dist/plus/integrations/fieldPresence.d.ts +16 -1
- package/dist/plus/integrations/fieldPresence.js +37 -10
- package/dist/plus/integrations/fieldPresence.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +12 -0
- package/dist/plus/integrations/integrationService.js +4 -0
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +38 -0
- package/dist/plus/integrations/models/gitHostIntegration.d.ts +41 -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 +23 -2
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/providers/github/github.js +2 -1
- package/dist/plus/integrations/providers/github/github.js.map +1 -1
- package/dist/plus/integrations/providers/github.d.ts +21 -1
- package/dist/plus/integrations/providers/github.js +71 -6
- package/dist/plus/integrations/providers/github.js.map +1 -1
- package/dist/plus/integrations/reads/context.d.ts +7 -0
- package/dist/plus/integrations/reads/drains.d.ts +1 -1
- package/dist/plus/integrations/reads/drains.js +2 -1
- package/dist/plus/integrations/reads/drains.js.map +1 -1
- package/dist/plus/integrations/reads/etag.js +13 -0
- package/dist/plus/integrations/reads/etag.js.map +1 -1
- package/dist/plus/integrations/reads/pullRequestBatch.d.ts +6 -2
- package/dist/plus/integrations/reads/pullRequestBatch.js +9 -2
- package/dist/plus/integrations/reads/pullRequestBatch.js.map +1 -1
- package/dist/plus/integrations/reads/pullRequestBranches.d.ts +2 -0
- package/dist/plus/integrations/reads/pullRequestBranches.js +3 -1
- package/dist/plus/integrations/reads/pullRequestBranches.js.map +1 -1
- package/dist/plus/integrations/reads/pullRequests.d.ts +2 -0
- package/dist/plus/integrations/reads/pullRequests.js +2 -1
- package/dist/plus/integrations/reads/pullRequests.js.map +1 -1
- package/dist/plus/integrations/reads/searchPullRequests.d.ts +2 -0
- package/dist/plus/integrations/reads/searchPullRequests.js +2 -1
- package/dist/plus/integrations/reads/searchPullRequests.js.map +1 -1
- package/docs/integrations.md +77 -15
- 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,61 @@ 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. That
|
|
166
|
+
* cost is why the selection it belongs to is made only for a read that asks for it or a host that opts in
|
|
167
|
+
* (`getPullRequestReadOptions`).
|
|
168
|
+
*/
|
|
169
|
+
const gqlPullRequestMergeQueueEventsFragment = `
|
|
170
|
+
mergeQueueEvents: timelineItems(last: 1, itemTypes: [ADDED_TO_MERGE_QUEUE_EVENT, REMOVED_FROM_MERGE_QUEUE_EVENT]) {
|
|
171
|
+
nodes {
|
|
172
|
+
__typename
|
|
173
|
+
... on RemovedFromMergeQueueEvent {
|
|
174
|
+
createdAt
|
|
175
|
+
reason
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
`;
|
|
180
|
+
/**
|
|
181
|
+
* Merge-queue selection, appended alongside the stack one and for the same reason: GitHub Enterprise Server's schema
|
|
182
|
+
* isn't verified to have `mergeQueueEntry`, and an unknown field fails the whole query rather than the field. It is
|
|
183
|
+
* also selected only when the read asks for it (`mergeQueue`) or, when it doesn't say, the host opts in with
|
|
184
|
+
* `GitHubApiConfig.getPullRequestReadOptions`, as it costs a rate-limit request per pull request read. Always add it
|
|
185
|
+
* via `gqlPullRequestMergeQueueFragmentFor`, at every site that adds the stack selection.
|
|
186
|
+
*/
|
|
187
|
+
const gqlPullRequestMergeQueueFragment = `
|
|
188
|
+
mergeQueueEntry {
|
|
189
|
+
${gqlMergeQueueEntryFields}
|
|
190
|
+
}
|
|
191
|
+
isMergeQueueEnabled
|
|
192
|
+
${gqlPullRequestMergeQueueEventsFragment}
|
|
193
|
+
`;
|
|
194
|
+
function gqlPullRequestMergeQueueFragmentFor(options, config) {
|
|
195
|
+
return readsMergeQueue(options, config) ? gqlPullRequestMergeQueueFragment : "";
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Whether a pull request read selects merge-queue data: github.com only, and only when the read asks for it
|
|
199
|
+
* (`options.mergeQueue`) or, when it doesn't say, the host opts in (`GitHubApiConfig.getPullRequestReadOptions`).
|
|
200
|
+
*/
|
|
201
|
+
function readsMergeQueue(options, config) {
|
|
202
|
+
return isGitHubDotCom(options) && (options?.mergeQueue ?? config.getPullRequestReadOptions?.()?.mergeQueue) === true;
|
|
203
|
+
}
|
|
149
204
|
/**
|
|
150
205
|
* A 409 means a merge request is already in flight and carries its ticket, so it resumes rather than fails.
|
|
151
206
|
*
|
|
@@ -322,7 +377,9 @@ repository {
|
|
|
322
377
|
* The change state a pull request's etag reads (see {@link GitHubPullRequestEtagNode}). Every selection is copied
|
|
323
378
|
* from {@link gqlPullRequestFragment} — same arguments, same nesting — so the cheap read sees exactly the values
|
|
324
379
|
* 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`.
|
|
380
|
+
* `merged` is not needed: `state` already reads `MERGED`. The merge-queue entry's state is added by
|
|
381
|
+
* {@link gqlPullRequestEtagMergeQueueFragmentFor} exactly when the full read adds its entry: against github.com,
|
|
382
|
+
* for a read that selects merge-queue data.
|
|
326
383
|
*/
|
|
327
384
|
const gqlPullRequestEtagFragment = `
|
|
328
385
|
id
|
|
@@ -333,6 +390,27 @@ updatedAt
|
|
|
333
390
|
headRefOid
|
|
334
391
|
`;
|
|
335
392
|
/**
|
|
393
|
+
* The slice of {@link gqlPullRequestMergeQueueFragment} a pull request's etag reads: whether it's queued, in which
|
|
394
|
+
* state, and since when (so leaving and rejoining the queue between checks still reads as a change), and its latest
|
|
395
|
+
* merge-queue event, so a pull request that joined and was removed between two checks (neither of which moves the
|
|
396
|
+
* update time) still reads as a change. Not the estimate, which GitHub recomputes as the queue moves and would fail
|
|
397
|
+
* every check of a queued pull request, nor the position, which moves as the entries ahead of it merge. It also
|
|
398
|
+
* selects `isMergeQueueEnabled`, which only a change to the base branch's rules moves and so is never an etag input:
|
|
399
|
+
* its presence on the node is what tells the etag the read selected merge-queue data (see
|
|
400
|
+
* `PullRequestEtagFields.mergeQueueRead`).
|
|
401
|
+
*/
|
|
402
|
+
const gqlPullRequestEtagMergeQueueFragment = `
|
|
403
|
+
mergeQueueEntry {
|
|
404
|
+
state
|
|
405
|
+
enqueuedAt
|
|
406
|
+
}
|
|
407
|
+
isMergeQueueEnabled
|
|
408
|
+
${gqlPullRequestMergeQueueEventsFragment}
|
|
409
|
+
`;
|
|
410
|
+
function gqlPullRequestEtagMergeQueueFragmentFor(options, config) {
|
|
411
|
+
return readsMergeQueue(options, config) ? gqlPullRequestEtagMergeQueueFragment : "";
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
336
414
|
* The selection each {@link GitHubPullRequestEtagInclude} adds to {@link gqlPullRequestEtagFragment}, copied from
|
|
337
415
|
* {@link gqlPullRequestFragment} like it.
|
|
338
416
|
*/
|
|
@@ -659,6 +737,7 @@ var GitHubApi = class {
|
|
|
659
737
|
pullRequest(number: $number) {
|
|
660
738
|
${gqlPullRequestLiteFragment}
|
|
661
739
|
${gqlPullRequestStackFragmentFor(options)}
|
|
740
|
+
${gqlPullRequestMergeQueueFragmentFor(options, this.config)}
|
|
662
741
|
}
|
|
663
742
|
}
|
|
664
743
|
}`;
|
|
@@ -692,6 +771,7 @@ var GitHubApi = class {
|
|
|
692
771
|
nodes {
|
|
693
772
|
${gqlPullRequestLiteFragment}
|
|
694
773
|
${gqlPullRequestStackFragmentFor(options)}
|
|
774
|
+
${gqlPullRequestMergeQueueFragmentFor(options, this.config)}
|
|
695
775
|
}
|
|
696
776
|
}
|
|
697
777
|
}
|
|
@@ -729,6 +809,7 @@ var GitHubApi = class {
|
|
|
729
809
|
nodes {
|
|
730
810
|
${gqlPullRequestLiteFragment}
|
|
731
811
|
${gqlPullRequestStackFragmentFor(options)}
|
|
812
|
+
${gqlPullRequestMergeQueueFragmentFor(options, this.config)}
|
|
732
813
|
}
|
|
733
814
|
}
|
|
734
815
|
}
|
|
@@ -2095,6 +2176,7 @@ var GitHubApi = class {
|
|
|
2095
2176
|
...on PullRequest {
|
|
2096
2177
|
${options?.summary ? gqlPullRequestLiteFragment : gqlPullRequestFragment}
|
|
2097
2178
|
${gqlPullRequestStackFragmentFor(options)}
|
|
2179
|
+
${gqlPullRequestMergeQueueFragmentFor(options, this.config)}
|
|
2098
2180
|
}
|
|
2099
2181
|
}
|
|
2100
2182
|
}
|
|
@@ -2421,6 +2503,8 @@ var GitHubApi = class {
|
|
|
2421
2503
|
async getPullRequestsBatch(provider, token, coordinates, options, cancellation) {
|
|
2422
2504
|
const scope = getScopedLogger();
|
|
2423
2505
|
if (coordinates.length === 0) return [];
|
|
2506
|
+
const stackFragment = gqlPullRequestStackFragmentFor(options);
|
|
2507
|
+
const mergeQueueFragment = gqlPullRequestMergeQueueFragmentFor(options, this.config);
|
|
2424
2508
|
const query = `query getPullRequestsBatch(
|
|
2425
2509
|
${coordinates.map((_, i) => `$o${i}: String!\n\t\t\t\t$n${i}: String!\n\t\t\t\t$k${i}: Int!`).join("\n ")}
|
|
2426
2510
|
$avatarSize: Int
|
|
@@ -2428,7 +2512,8 @@ var GitHubApi = class {
|
|
|
2428
2512
|
${coordinates.map((_, i) => `p${i}: repository(owner: $o${i}, name: $n${i}) {
|
|
2429
2513
|
pullRequest(number: $k${i}) {
|
|
2430
2514
|
${gqlPullRequestFragment}
|
|
2431
|
-
${
|
|
2515
|
+
${stackFragment}
|
|
2516
|
+
${mergeQueueFragment}
|
|
2432
2517
|
}
|
|
2433
2518
|
}`).join("\n ")}
|
|
2434
2519
|
}`;
|
|
@@ -2487,12 +2572,14 @@ var GitHubApi = class {
|
|
|
2487
2572
|
const scope = getScopedLogger();
|
|
2488
2573
|
if (coordinates.length === 0) return [];
|
|
2489
2574
|
const includeFragments = Array.from(new Set(options?.etagIncludes), (include) => gqlPullRequestEtagIncludeFragments[include]);
|
|
2575
|
+
const mergeQueueFragment = gqlPullRequestEtagMergeQueueFragmentFor(options, this.config);
|
|
2490
2576
|
const query = `query getPullRequestsEtagFieldsBatch(
|
|
2491
2577
|
${coordinates.map((_, i) => `$o${i}: String!\n\t\t\t\t$n${i}: String!\n\t\t\t\t$k${i}: Int!`).join("\n ")}
|
|
2492
2578
|
) {
|
|
2493
2579
|
${coordinates.map((_, i) => `p${i}: repository(owner: $o${i}, name: $n${i}) {
|
|
2494
2580
|
pullRequest(number: $k${i}) {
|
|
2495
2581
|
${gqlPullRequestEtagFragment}
|
|
2582
|
+
${mergeQueueFragment}
|
|
2496
2583
|
${includeFragments.join("")}
|
|
2497
2584
|
}
|
|
2498
2585
|
}`).join("\n ")}
|
|
@@ -2605,6 +2692,8 @@ var GitHubApi = class {
|
|
|
2605
2692
|
async getPullRequestsForBranches(provider, token, queries, options, cancellation) {
|
|
2606
2693
|
const scope = getScopedLogger();
|
|
2607
2694
|
if (queries.length === 0) return [];
|
|
2695
|
+
const stackFragment = gqlPullRequestStackFragmentFor(options);
|
|
2696
|
+
const mergeQueueFragment = gqlPullRequestMergeQueueFragmentFor(options, this.config);
|
|
2608
2697
|
const query = `query getPullRequestsForBranches(
|
|
2609
2698
|
${queries.map((_, i) => `$o${i}: String!\n\t\t\t\t$n${i}: String!\n\t\t\t\t$h${i}: String!`).join("\n ")}
|
|
2610
2699
|
$limit: Int!
|
|
@@ -2615,7 +2704,8 @@ var GitHubApi = class {
|
|
|
2615
2704
|
totalCount
|
|
2616
2705
|
nodes {
|
|
2617
2706
|
${gqlPullRequestFragment}
|
|
2618
|
-
${
|
|
2707
|
+
${stackFragment}
|
|
2708
|
+
${mergeQueueFragment}
|
|
2619
2709
|
headRepositoryOwner {
|
|
2620
2710
|
login
|
|
2621
2711
|
}
|
|
@@ -3000,6 +3090,8 @@ var GitHubApi = class {
|
|
|
3000
3090
|
const defaultSize = options?.summary === true ? Math.max(1, Math.floor(maxPullRequestSearchPageSize / activeFacets.length)) : defaultPullRequestSearchPageSize;
|
|
3001
3091
|
const pageSize = Math.min(maxPullRequestSearchPageSize, Math.max(1, Math.trunc(options?.pageSize ?? defaultSize)));
|
|
3002
3092
|
const includeVar = (alias) => `include${alias.charAt(0).toUpperCase()}${alias.slice(1)}`;
|
|
3093
|
+
const stackFragment = gqlPullRequestStackFragmentFor(options);
|
|
3094
|
+
const mergeQueueFragment = gqlPullRequestMergeQueueFragmentFor(options, this.config);
|
|
3003
3095
|
const params = facets.flatMap((f) => [
|
|
3004
3096
|
`$${f.alias}Search: String!`,
|
|
3005
3097
|
`$${f.alias}Cursor: String`,
|
|
@@ -3015,7 +3107,8 @@ var GitHubApi = class {
|
|
|
3015
3107
|
nodes {
|
|
3016
3108
|
... on PullRequest {
|
|
3017
3109
|
${options?.summary ? gqlPullRequestLiteFragment : gqlPullRequestFragment}
|
|
3018
|
-
${
|
|
3110
|
+
${stackFragment}
|
|
3111
|
+
${mergeQueueFragment}
|
|
3019
3112
|
}
|
|
3020
3113
|
}
|
|
3021
3114
|
}`);
|
|
@@ -3107,6 +3200,8 @@ var GitHubApi = class {
|
|
|
3107
3200
|
qualifier: toGitHubSearchStateQualifier(include)
|
|
3108
3201
|
}];
|
|
3109
3202
|
try {
|
|
3203
|
+
const stackFragment = gqlPullRequestStackFragmentFor(options);
|
|
3204
|
+
const mergeQueueFragment = gqlPullRequestMergeQueueFragmentFor(options, this.config);
|
|
3110
3205
|
const params = stateSearches.map(({ alias }) => alias === "search" ? "$searchQuery: String!" : `$${alias}SearchQuery: String!`);
|
|
3111
3206
|
const fields = stateSearches.map(({ alias }) => {
|
|
3112
3207
|
const fieldAlias = alias === "search" ? "" : `${alias}: `;
|
|
@@ -3115,7 +3210,8 @@ var GitHubApi = class {
|
|
|
3115
3210
|
nodes {
|
|
3116
3211
|
...on PullRequest {
|
|
3117
3212
|
${gqlPullRequestFragment}
|
|
3118
|
-
${
|
|
3213
|
+
${stackFragment}
|
|
3214
|
+
${mergeQueueFragment}
|
|
3119
3215
|
}
|
|
3120
3216
|
}
|
|
3121
3217
|
}`;
|
|
@@ -3179,6 +3275,62 @@ var GitHubApi = class {
|
|
|
3179
3275
|
}
|
|
3180
3276
|
}
|
|
3181
3277
|
/**
|
|
3278
|
+
* The merge-queue entries of the given base branches, keyed by pull request number, in one request — each
|
|
3279
|
+
* branch's queue is an alias on the one `repository` selection. For list surfaces whose pull requests arrive
|
|
3280
|
+
* through provider-apis' repository-scoped read, which selects no `mergeQueueEntry`; callers join by number.
|
|
3281
|
+
*
|
|
3282
|
+
* INTERIM: remove once provider-apis carries the merge-queue entry on its pull requests (goals S6).
|
|
3283
|
+
*
|
|
3284
|
+
* github.com only, like the `mergeQueueEntry` selection: `undefined` on GitHub Enterprise Server, whose schema
|
|
3285
|
+
* isn't verified to have `mergeQueue`, and for a repository GitHub reports not found. A branch without a queue
|
|
3286
|
+
* contributes nothing. At most the first 100 entries of each queue are read.
|
|
3287
|
+
*/
|
|
3288
|
+
async getMergeQueueEntriesForBranches(provider, token, owner, repo, branches, options, cancellation) {
|
|
3289
|
+
const scope = getScopedLogger();
|
|
3290
|
+
if (!isGitHubDotCom(options)) return void 0;
|
|
3291
|
+
const byNumber = /* @__PURE__ */ new Map();
|
|
3292
|
+
if (!branches.length) return byNumber;
|
|
3293
|
+
const query = `query getMergeQueueEntriesForBranches(
|
|
3294
|
+
$owner: String!
|
|
3295
|
+
$repo: String!
|
|
3296
|
+
${branches.map((_, i) => `$b${i}: String!`).join("\n ")}
|
|
3297
|
+
) {
|
|
3298
|
+
repository(owner: $owner, name: $repo) {
|
|
3299
|
+
${branches.map((_, i) => `b${i}: mergeQueue(branch: $b${i}) {
|
|
3300
|
+
entries(first: 100) {
|
|
3301
|
+
nodes {
|
|
3302
|
+
${gqlMergeQueueEntryFields}
|
|
3303
|
+
pullRequest {
|
|
3304
|
+
number
|
|
3305
|
+
}
|
|
3306
|
+
}
|
|
3307
|
+
}
|
|
3308
|
+
}`).join("\n ")}
|
|
3309
|
+
}
|
|
3310
|
+
}`;
|
|
3311
|
+
const variables = {
|
|
3312
|
+
baseUrl: options?.baseUrl,
|
|
3313
|
+
owner,
|
|
3314
|
+
repo
|
|
3315
|
+
};
|
|
3316
|
+
branches.forEach((branch, i) => {
|
|
3317
|
+
variables[`b${i}`] = branch;
|
|
3318
|
+
});
|
|
3319
|
+
try {
|
|
3320
|
+
const rsp = await this.graphql(provider, token, query, variables, scope, cancellation);
|
|
3321
|
+
if (rsp?.repository == null) return void 0;
|
|
3322
|
+
for (const queue of Object.values(rsp.repository)) for (const node of queue?.entries?.nodes ?? []) {
|
|
3323
|
+
if (node?.pullRequest == null) continue;
|
|
3324
|
+
byNumber.set(node.pullRequest.number, fromGitHubMergeQueueEntry(node));
|
|
3325
|
+
}
|
|
3326
|
+
return byNumber;
|
|
3327
|
+
} catch (ex) {
|
|
3328
|
+
if (isCancellationError(ex)) throw ex;
|
|
3329
|
+
if (ex instanceof RequestNotFoundError) return void 0;
|
|
3330
|
+
throw this.handleException(ex, provider, scope, true);
|
|
3331
|
+
}
|
|
3332
|
+
}
|
|
3333
|
+
/**
|
|
3182
3334
|
* Merges a stacked pull request, and with it every layer below it.
|
|
3183
3335
|
*
|
|
3184
3336
|
* Stacks cannot go through `mergePullRequest` — GitHub rejects stacked pull requests on the legacy
|
|
@@ -3263,6 +3415,90 @@ var GitHubApi = class {
|
|
|
3263
3415
|
throw this.handleException(ex, provider, scope);
|
|
3264
3416
|
}
|
|
3265
3417
|
}
|
|
3418
|
+
/**
|
|
3419
|
+
* Adds a pull request to its base branch's merge queue, at the back (no `jump`). GitHub takes no merge method here:
|
|
3420
|
+
* the base branch's ruleset decides it. `expectedHeadSha` makes GitHub refuse a head that moved since it was read.
|
|
3421
|
+
*
|
|
3422
|
+
* GitHub's refusals come back as a `failed` result saying why (see {@link toGitHubMergeQueueActionFailure}),
|
|
3423
|
+
* without prompting to re-authenticate on a FORBIDDEN, which here means the account may not queue, not that the
|
|
3424
|
+
* token is bad. A failure to reach GitHub, a refused credential or a rate limit is thrown as from any other request,
|
|
3425
|
+
* and cancellation throws `CancellationError`. Like every mutation it is never retried. github.com only, like the
|
|
3426
|
+
* merge-queue reads: `unsupported` on GitHub Enterprise Server, whose schema isn't verified to have it.
|
|
3427
|
+
*/
|
|
3428
|
+
async enqueuePullRequest(provider, token, nodeId, expectedHeadSha, options, cancellation) {
|
|
3429
|
+
const scope = getScopedLogger();
|
|
3430
|
+
if (!isGitHubDotCom(options)) return {
|
|
3431
|
+
status: "failed",
|
|
3432
|
+
reason: "unsupported"
|
|
3433
|
+
};
|
|
3434
|
+
try {
|
|
3435
|
+
const query = `mutation enqueuePullRequest(
|
|
3436
|
+
$id: ID!
|
|
3437
|
+
$expectedHeadOid: GitObjectID!
|
|
3438
|
+
) {
|
|
3439
|
+
enqueuePullRequest(input: { pullRequestId: $id, expectedHeadOid: $expectedHeadOid }) {
|
|
3440
|
+
mergeQueueEntry {
|
|
3441
|
+
${gqlMergeQueueEntryFields}
|
|
3442
|
+
}
|
|
3443
|
+
}
|
|
3444
|
+
}`;
|
|
3445
|
+
const entry = (await this.graphql(provider, token, query, {
|
|
3446
|
+
id: nodeId,
|
|
3447
|
+
expectedHeadOid: expectedHeadSha,
|
|
3448
|
+
baseUrl: options?.baseUrl
|
|
3449
|
+
}, scope, cancellation))?.enqueuePullRequest?.mergeQueueEntry;
|
|
3450
|
+
return {
|
|
3451
|
+
status: "queued",
|
|
3452
|
+
entry: entry != null ? fromGitHubMergeQueueEntry(entry) : void 0
|
|
3453
|
+
};
|
|
3454
|
+
} catch (ex) {
|
|
3455
|
+
if (isCancellationError(ex)) throw ex;
|
|
3456
|
+
const failure = toGitHubMergeQueueActionFailure(ex);
|
|
3457
|
+
if (failure != null) {
|
|
3458
|
+
scope?.warn(`GitHub refused to enqueue: ${failure.reason} (${failure.message})`);
|
|
3459
|
+
return {
|
|
3460
|
+
status: "failed",
|
|
3461
|
+
...failure
|
|
3462
|
+
};
|
|
3463
|
+
}
|
|
3464
|
+
throw this.handleException(ex, provider, scope);
|
|
3465
|
+
}
|
|
3466
|
+
}
|
|
3467
|
+
/**
|
|
3468
|
+
* Removes a pull request from its base branch's merge queue, losing its place there. Fails and throws as
|
|
3469
|
+
* {@link enqueuePullRequest} does, and is github.com only like it.
|
|
3470
|
+
*/
|
|
3471
|
+
async dequeuePullRequest(provider, token, nodeId, options, cancellation) {
|
|
3472
|
+
const scope = getScopedLogger();
|
|
3473
|
+
if (!isGitHubDotCom(options)) return {
|
|
3474
|
+
status: "failed",
|
|
3475
|
+
reason: "unsupported"
|
|
3476
|
+
};
|
|
3477
|
+
try {
|
|
3478
|
+
await this.graphql(provider, token, `mutation dequeuePullRequest($id: ID!) {
|
|
3479
|
+
dequeuePullRequest(input: { id: $id }) {
|
|
3480
|
+
mergeQueueEntry {
|
|
3481
|
+
id
|
|
3482
|
+
}
|
|
3483
|
+
}
|
|
3484
|
+
}`, {
|
|
3485
|
+
id: nodeId,
|
|
3486
|
+
baseUrl: options?.baseUrl
|
|
3487
|
+
}, scope, cancellation);
|
|
3488
|
+
return { status: "dequeued" };
|
|
3489
|
+
} catch (ex) {
|
|
3490
|
+
if (isCancellationError(ex)) throw ex;
|
|
3491
|
+
const failure = toGitHubMergeQueueActionFailure(ex);
|
|
3492
|
+
if (failure != null) {
|
|
3493
|
+
scope?.warn(`GitHub refused to dequeue: ${failure.reason} (${failure.message})`);
|
|
3494
|
+
return {
|
|
3495
|
+
status: "failed",
|
|
3496
|
+
...failure
|
|
3497
|
+
};
|
|
3498
|
+
}
|
|
3499
|
+
throw this.handleException(ex, provider, scope);
|
|
3500
|
+
}
|
|
3501
|
+
}
|
|
3266
3502
|
};
|
|
3267
3503
|
__decorate([trace({ args: (provider, token, owner, repo, rev) => ({
|
|
3268
3504
|
provider: provider.name,
|
|
@@ -3547,6 +3783,13 @@ __decorate([trace({ args: (provider, token, owner, repo) => ({
|
|
|
3547
3783
|
owner,
|
|
3548
3784
|
repo
|
|
3549
3785
|
}) })], GitHubApi.prototype, "getRepositoryStacks", null);
|
|
3786
|
+
__decorate([trace({ args: (provider, token, owner, repo, branches) => ({
|
|
3787
|
+
provider: provider.name,
|
|
3788
|
+
token: `<token:${token.microHash}>`,
|
|
3789
|
+
owner,
|
|
3790
|
+
repo,
|
|
3791
|
+
branches: branches.join(",")
|
|
3792
|
+
}) })], GitHubApi.prototype, "getMergeQueueEntriesForBranches", null);
|
|
3550
3793
|
__decorate([trace({ args: (provider, token, owner, repo, pullNumber, expectedSourceSha) => ({
|
|
3551
3794
|
provider: provider.name,
|
|
3552
3795
|
token: `<token:${token.microHash}>`,
|
|
@@ -3561,6 +3804,60 @@ __decorate([trace({ args: (provider, token, nodeId, expectedSourceSha) => ({
|
|
|
3561
3804
|
nodeId,
|
|
3562
3805
|
expectedSourceSha
|
|
3563
3806
|
}) })], GitHubApi.prototype, "mergePullRequest", null);
|
|
3807
|
+
__decorate([trace({ args: (provider, token, nodeId, expectedHeadSha) => ({
|
|
3808
|
+
provider: provider.name,
|
|
3809
|
+
token: `<token:${token.microHash}>`,
|
|
3810
|
+
nodeId,
|
|
3811
|
+
expectedHeadSha
|
|
3812
|
+
}) })], GitHubApi.prototype, "enqueuePullRequest", null);
|
|
3813
|
+
__decorate([trace({ args: (provider, token, nodeId) => ({
|
|
3814
|
+
provider: provider.name,
|
|
3815
|
+
token: `<token:${token.microHash}>`,
|
|
3816
|
+
nodeId
|
|
3817
|
+
}) })], GitHubApi.prototype, "dequeuePullRequest", null);
|
|
3818
|
+
/**
|
|
3819
|
+
* The wordings {@link toGitHubMergeQueueActionFailure} recognizes, tried in order against the lowercased message.
|
|
3820
|
+
* Each was observed live (2026-11-06) as a GraphQL `UNPROCESSABLE` error, and is matched tightly to GitHub's fixed
|
|
3821
|
+
* phrasing: "Pull request is already in the queue" (enqueue of a queued pull request), "Failed to add PR #N: expected
|
|
3822
|
+
* head oid does not match the current head oid" (enqueue at a stale head), "Pull request is closed" (enqueue of a
|
|
3823
|
+
* 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
|
|
3824
|
+
* `Failed to remove PR #N "<title>"`, which embeds the pull request's title, so it matches nothing here (a title like
|
|
3825
|
+
* "Fix merge conflict" must not read as a conflict) and falls through to `unknown`.
|
|
3826
|
+
*/
|
|
3827
|
+
const mergeQueueActionFailurePatterns = [
|
|
3828
|
+
["already-queued", /\bis already in the queue\b/],
|
|
3829
|
+
["head-changed", /\bexpected head oid does not match\b/],
|
|
3830
|
+
["not-allowed", /^pull request is (?:closed|in draft)\b/]
|
|
3831
|
+
];
|
|
3832
|
+
/**
|
|
3833
|
+
* Why GitHub refused to add a pull request to its merge queue or remove it, from the error its GraphQL answer carried
|
|
3834
|
+
* (`errors[]`, which `graphql` throws as a `GraphqlResponseError`, or wraps in an `AuthenticationError` for FORBIDDEN
|
|
3835
|
+
* and a `RequestNotFoundError` for NOT_FOUND). `undefined` for anything that isn't GitHub's answer about the action
|
|
3836
|
+
* — a failure to reach it, a refused credential (HTTP 401/403), a rate limit — which the caller handles like any
|
|
3837
|
+
* other request's failure.
|
|
3838
|
+
*
|
|
3839
|
+
* Only the wordings observed live (2026-11-06; see {@link mergeQueueActionFailurePatterns}) are recognized. Dequeue's
|
|
3840
|
+
* refusal is generic and embeds the pull request's title, so it is never matched by wording and maps to `unknown`.
|
|
3841
|
+
* When no message matches, the error's `type` decides (FORBIDDEN is `permission`), and anything else is `unknown`.
|
|
3842
|
+
* The message is GitHub's own, for logs, never for display.
|
|
3843
|
+
*/
|
|
3844
|
+
function toGitHubMergeQueueActionFailure(ex) {
|
|
3845
|
+
const original = ex instanceof AuthenticationError || ex instanceof RequestNotFoundError ? ex.original : ex;
|
|
3846
|
+
if (!(original instanceof GraphqlResponseError)) return void 0;
|
|
3847
|
+
const error = original.errors?.[0];
|
|
3848
|
+
if (error == null) return void 0;
|
|
3849
|
+
const message = error.message ?? "";
|
|
3850
|
+
const text = message.toLowerCase();
|
|
3851
|
+
const matched = mergeQueueActionFailurePatterns.find(([, pattern]) => pattern.test(text));
|
|
3852
|
+
if (matched != null) return {
|
|
3853
|
+
reason: matched[0],
|
|
3854
|
+
message
|
|
3855
|
+
};
|
|
3856
|
+
return {
|
|
3857
|
+
reason: error.type === "FORBIDDEN" ? "permission" : "unknown",
|
|
3858
|
+
message
|
|
3859
|
+
};
|
|
3860
|
+
}
|
|
3564
3861
|
/**
|
|
3565
3862
|
* Every issue read's presence table assumes the body was selected, so a read without `includeBody` is left
|
|
3566
3863
|
* untagged (unknown) rather than claiming a description it never fetched.
|
|
@@ -3597,6 +3894,6 @@ function requiresGitHubPullRequestStateFacets(include) {
|
|
|
3597
3894
|
return uniqueStates.size === 2 && uniqueStates.has("opened") && uniqueStates.has("merged");
|
|
3598
3895
|
}
|
|
3599
3896
|
//#endregion
|
|
3600
|
-
export { GitHubApi, filterPullRequestsBySearchState, toGitHubSearchStateQualifier };
|
|
3897
|
+
export { GitHubApi, filterPullRequestsBySearchState, toGitHubMergeQueueActionFailure, toGitHubSearchStateQualifier };
|
|
3601
3898
|
|
|
3602
3899
|
//# sourceMappingURL=github.js.map
|