@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
|
@@ -57,6 +57,24 @@ export interface PullRequestShape extends IssueOrPullRequest {
|
|
|
57
57
|
readonly assignees?: PullRequestMember[];
|
|
58
58
|
readonly project?: IssueProject;
|
|
59
59
|
readonly stack?: PullRequestStackInfo;
|
|
60
|
+
/**
|
|
61
|
+
* The pull request's place in its base branch's merge queue. Absent means either not queued or not fetched — ask
|
|
62
|
+
* `getPullRequestFieldPresence` (`@gitkraken/core-gitlens/plus/integrations`) for the row's `mergeQueue` group to tell them apart.
|
|
63
|
+
* Only GitHub.com reports one.
|
|
64
|
+
*/
|
|
65
|
+
readonly mergeQueue?: PullRequestMergeQueueEntry;
|
|
66
|
+
/**
|
|
67
|
+
* Whether the base branch accepts this pull request only through a merge queue, so merging it means adding it to
|
|
68
|
+
* the queue. `undefined` means not read; read wherever `mergeQueue` is (the same `mergeQueue` field group).
|
|
69
|
+
*/
|
|
70
|
+
readonly mergeQueueRequired?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* The pull request's latest removal from its merge queue, set only while that removal is its latest merge-queue
|
|
73
|
+
* event (it hasn't rejoined since) and the removal didn't merge it. It stays set however much later the pull
|
|
74
|
+
* request changes, so ask `isPullRequestMergeQueueRemovalCurrent` whether it still describes the pull request.
|
|
75
|
+
* Read wherever `mergeQueue` is (the same `mergeQueue` field group); absent there means no such removal.
|
|
76
|
+
*/
|
|
77
|
+
readonly mergeQueueRemoval?: PullRequestMergeQueueRemoval;
|
|
60
78
|
readonly number?: number;
|
|
61
79
|
readonly authoredByMe?: boolean;
|
|
62
80
|
/**
|
|
@@ -129,6 +147,9 @@ export declare class PullRequest implements PullRequestShape {
|
|
|
129
147
|
} | undefined;
|
|
130
148
|
readonly viewerUnresolved?: true | undefined;
|
|
131
149
|
readonly milestone?: IssueMilestone | null | undefined;
|
|
150
|
+
readonly mergeQueue?: PullRequestMergeQueueEntry | undefined;
|
|
151
|
+
readonly mergeQueueRequired?: boolean | undefined;
|
|
152
|
+
readonly mergeQueueRemoval?: PullRequestMergeQueueRemoval | undefined;
|
|
132
153
|
readonly type = "pullrequest";
|
|
133
154
|
constructor(provider: ProviderReference, author: PullRequestMember, id: string, nodeId: string | undefined, title: string, url: string, repository: IssueRepository, state: IssueOrPullRequestState, createdDate: Date, updatedDate: Date, closedDate?: Date | undefined, mergedDate?: Date | undefined, mergeableState?: PullRequestMergeableState | undefined, viewerCanUpdate?: boolean | undefined, refs?: PullRequestRefs | undefined, isDraft?: boolean | undefined, additions?: number | undefined, deletions?: number | undefined, commentsCount?: number | undefined, thumbsUpCount?: number | undefined, reviewDecision?: PullRequestReviewDecision | undefined, reviewRequests?: PullRequestReviewer[] | undefined, latestReviews?: PullRequestReviewer[] | undefined, assignees?: PullRequestMember[] | undefined, statusCheckRollupState?: PullRequestStatusCheckRollupState | undefined, project?: IssueProject | undefined, version?: number | undefined,
|
|
134
155
|
/** Commits on the head that aren't on the base. Appended rather than slotted with the other counts:
|
|
@@ -138,7 +159,7 @@ export declare class PullRequest implements PullRequestShape {
|
|
|
138
159
|
body?: string | undefined, number?: number | undefined, authoredByMe?: boolean | undefined, projection?: PullRequestProjection | undefined, viewer?: {
|
|
139
160
|
readonly id: string;
|
|
140
161
|
readonly username?: string;
|
|
141
|
-
} | undefined, viewerUnresolved?: true | undefined, milestone?: IssueMilestone | null | undefined);
|
|
162
|
+
} | undefined, viewerUnresolved?: true | undefined, milestone?: IssueMilestone | null | undefined, mergeQueue?: PullRequestMergeQueueEntry | undefined, mergeQueueRequired?: boolean | undefined, mergeQueueRemoval?: PullRequestMergeQueueRemoval | undefined);
|
|
142
163
|
get closed(): boolean;
|
|
143
164
|
static is(pr: unknown): pr is PullRequest;
|
|
144
165
|
static formatDate(pr: PullRequestShape, format?: string | null): string;
|
|
@@ -160,6 +181,15 @@ export declare const enum PullRequestMergeableState {
|
|
|
160
181
|
FailingChecks = "FailingChecks",
|
|
161
182
|
BlockedByPolicy = "BlockedByPolicy"
|
|
162
183
|
}
|
|
184
|
+
/** Where a queued pull request stands in its merge queue. Mirrors GitHub's `MergeQueueEntryState`. */
|
|
185
|
+
export declare const enum PullRequestMergeQueueState {
|
|
186
|
+
Queued = "Queued",
|
|
187
|
+
/** Waiting for its required checks to pass. */
|
|
188
|
+
AwaitingChecks = "AwaitingChecks",
|
|
189
|
+
Mergeable = "Mergeable",
|
|
190
|
+
Unmergeable = "Unmergeable",
|
|
191
|
+
Locked = "Locked"
|
|
192
|
+
}
|
|
163
193
|
export declare const enum PullRequestStatusCheckRollupState {
|
|
164
194
|
Success = "success",
|
|
165
195
|
Pending = "pending",
|
|
@@ -406,6 +436,65 @@ export interface PullRequestStackLayers {
|
|
|
406
436
|
/** The stack's layers, ordered bottom (closest to {@link baseRef}) to top. */
|
|
407
437
|
layers: PullRequestStackLayer[];
|
|
408
438
|
}
|
|
439
|
+
/** A pull request's entry in its base branch's merge queue. */
|
|
440
|
+
export interface PullRequestMergeQueueEntry {
|
|
441
|
+
state: PullRequestMergeQueueState;
|
|
442
|
+
/** When the pull request joined the queue. */
|
|
443
|
+
enqueuedAt: Date;
|
|
444
|
+
/**
|
|
445
|
+
* When the provider expects it to merge: its estimate of the time remaining, fixed to a date when the entry was
|
|
446
|
+
* read, so it counts down while the entry is held rather than restarting at each render. Absent when the provider
|
|
447
|
+
* gives none; may already be past on an entry held a while.
|
|
448
|
+
*/
|
|
449
|
+
estimatedMergeAt?: Date;
|
|
450
|
+
/** The merge queue's web URL. */
|
|
451
|
+
url?: string;
|
|
452
|
+
/**
|
|
453
|
+
* The entry's 1-based place in the queue, in enqueue order. Absent when the provider gives none. It moves as the
|
|
454
|
+
* entries ahead of it merge or leave, so it is never an etag input: an `unchanged` row's position can be stale.
|
|
455
|
+
*/
|
|
456
|
+
position?: number;
|
|
457
|
+
}
|
|
458
|
+
/** A pull request's removal from its base branch's merge queue, other than by merging. */
|
|
459
|
+
export interface PullRequestMergeQueueRemoval {
|
|
460
|
+
/**
|
|
461
|
+
* The provider's own reason, passed through as given — GitHub's include `failed_checks` and `manual`, and others
|
|
462
|
+
* are undocumented. Empty when the provider gives none. Classify it with `getPullRequestMergeQueueRemovalKind`.
|
|
463
|
+
*/
|
|
464
|
+
reason: string;
|
|
465
|
+
/** When the pull request was removed. */
|
|
466
|
+
removedAt: Date;
|
|
467
|
+
}
|
|
468
|
+
/** Why adding a pull request to its merge queue, or removing it, failed. */
|
|
469
|
+
export type PullRequestMergeQueueActionFailureReason =
|
|
470
|
+
/** Adding a pull request that is already queued. */
|
|
471
|
+
'already-queued' |
|
|
472
|
+
/** The pull request's head moved since it was read, so the head it was asked to queue is stale. */
|
|
473
|
+
'head-changed' |
|
|
474
|
+
/** The host refused the action for the pull request's own state: its base branch has no merge queue, it is a
|
|
475
|
+
* draft or closed, or it doesn't meet the queue's requirements. */
|
|
476
|
+
'not-allowed' |
|
|
477
|
+
/** The account may not add to or remove from this queue. */
|
|
478
|
+
'permission' |
|
|
479
|
+
/** The host (or this integration) has no merge queue to act on. */
|
|
480
|
+
'unsupported' |
|
|
481
|
+
/** Anything else, including a failure to reach the host. */
|
|
482
|
+
'unknown';
|
|
483
|
+
/**
|
|
484
|
+
* What adding a pull request to its merge queue, or removing it, did. A failure says why, with the host's own message
|
|
485
|
+
* when it gave one — for logs and diagnostics, not for display.
|
|
486
|
+
*/
|
|
487
|
+
export type PullRequestMergeQueueActionResult = {
|
|
488
|
+
readonly status: 'queued';
|
|
489
|
+
/** The new entry, when the host returned one. */
|
|
490
|
+
readonly entry?: PullRequestMergeQueueEntry;
|
|
491
|
+
} | {
|
|
492
|
+
readonly status: 'dequeued';
|
|
493
|
+
} | {
|
|
494
|
+
readonly status: 'failed';
|
|
495
|
+
readonly reason: PullRequestMergeQueueActionFailureReason;
|
|
496
|
+
readonly message?: string;
|
|
497
|
+
};
|
|
409
498
|
export interface PullRequestReviewer {
|
|
410
499
|
isCodeOwner?: boolean;
|
|
411
500
|
reviewer: PullRequestMember;
|
|
@@ -42,8 +42,11 @@ let PullRequest = _PullRequest = class PullRequest {
|
|
|
42
42
|
viewer;
|
|
43
43
|
viewerUnresolved;
|
|
44
44
|
milestone;
|
|
45
|
+
mergeQueue;
|
|
46
|
+
mergeQueueRequired;
|
|
47
|
+
mergeQueueRemoval;
|
|
45
48
|
type = "pullrequest";
|
|
46
|
-
constructor(provider, author, id, nodeId, title, url, repository, state, createdDate, updatedDate, closedDate, mergedDate, mergeableState, viewerCanUpdate, refs, isDraft, additions, deletions, commentsCount, thumbsUpCount, reviewDecision, reviewRequests, latestReviews, assignees, statusCheckRollupState, project, version, commitCount, stack, filesChanged, body, number, authoredByMe, projection, viewer, viewerUnresolved, milestone) {
|
|
49
|
+
constructor(provider, author, id, nodeId, title, url, repository, state, createdDate, updatedDate, closedDate, mergedDate, mergeableState, viewerCanUpdate, refs, isDraft, additions, deletions, commentsCount, thumbsUpCount, reviewDecision, reviewRequests, latestReviews, assignees, statusCheckRollupState, project, version, commitCount, stack, filesChanged, body, number, authoredByMe, projection, viewer, viewerUnresolved, milestone, mergeQueue, mergeQueueRequired, mergeQueueRemoval) {
|
|
47
50
|
this.provider = provider;
|
|
48
51
|
this.author = author;
|
|
49
52
|
this.id = id;
|
|
@@ -81,6 +84,9 @@ let PullRequest = _PullRequest = class PullRequest {
|
|
|
81
84
|
this.viewer = viewer;
|
|
82
85
|
this.viewerUnresolved = viewerUnresolved;
|
|
83
86
|
this.milestone = milestone;
|
|
87
|
+
this.mergeQueue = mergeQueue;
|
|
88
|
+
this.mergeQueueRequired = mergeQueueRequired;
|
|
89
|
+
this.mergeQueueRemoval = mergeQueueRemoval;
|
|
84
90
|
}
|
|
85
91
|
get closed() {
|
|
86
92
|
return this.state === "closed";
|
|
@@ -113,6 +119,16 @@ let PullRequestMergeableState = /* @__PURE__ */ function(PullRequestMergeableSta
|
|
|
113
119
|
PullRequestMergeableState["BlockedByPolicy"] = "BlockedByPolicy";
|
|
114
120
|
return PullRequestMergeableState;
|
|
115
121
|
}({});
|
|
122
|
+
/** Where a queued pull request stands in its merge queue. Mirrors GitHub's `MergeQueueEntryState`. */
|
|
123
|
+
let PullRequestMergeQueueState = /* @__PURE__ */ function(PullRequestMergeQueueState) {
|
|
124
|
+
PullRequestMergeQueueState["Queued"] = "Queued";
|
|
125
|
+
/** Waiting for its required checks to pass. */
|
|
126
|
+
PullRequestMergeQueueState["AwaitingChecks"] = "AwaitingChecks";
|
|
127
|
+
PullRequestMergeQueueState["Mergeable"] = "Mergeable";
|
|
128
|
+
PullRequestMergeQueueState["Unmergeable"] = "Unmergeable";
|
|
129
|
+
PullRequestMergeQueueState["Locked"] = "Locked";
|
|
130
|
+
return PullRequestMergeQueueState;
|
|
131
|
+
}({});
|
|
116
132
|
let PullRequestStatusCheckRollupState = /* @__PURE__ */ function(PullRequestStatusCheckRollupState) {
|
|
117
133
|
PullRequestStatusCheckRollupState["Success"] = "success";
|
|
118
134
|
PullRequestStatusCheckRollupState["Pending"] = "pending";
|
|
@@ -158,6 +174,6 @@ let PullRequestFilter = /* @__PURE__ */ function(PullRequestFilter) {
|
|
|
158
174
|
*/
|
|
159
175
|
const defaultPullRequestSort = "updated:desc";
|
|
160
176
|
//#endregion
|
|
161
|
-
export { PullRequest, PullRequestFilter, PullRequestMergeMethod, PullRequestMergeableState, PullRequestReviewDecision, PullRequestReviewState, PullRequestStatusCheckRollupState, defaultPullRequestSort };
|
|
177
|
+
export { PullRequest, PullRequestFilter, PullRequestMergeMethod, PullRequestMergeQueueState, PullRequestMergeableState, PullRequestReviewDecision, PullRequestReviewState, PullRequestStatusCheckRollupState, defaultPullRequestSort };
|
|
162
178
|
|
|
163
179
|
//# sourceMappingURL=pullRequest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pullRequest.js","names":[],"sources":["../../../../git/src/models/pullRequest.ts"],"sourcesContent":["import { formatDate, fromNow } from '@gitlens/utils/date.js';\nimport { loggable } from '@gitlens/utils/decorators/log.js';\nimport { serializable } from '@gitlens/utils/decorators/serializable.js';\nimport type { RequireSome, RequireSomeWithProps } from '@gitlens/utils/types.js';\nimport type { IssueProject, IssueRepository } from './issue.js';\nimport type {\n\tIssueMilestone,\n\tIssueOrPullRequest,\n\tIssueOrPullRequestState as PullRequestState,\n} from './issueOrPullRequest.js';\nimport type { ProviderReference } from './remoteProvider.js';\nimport type { RepositoryIdentityDescriptor } from './repositoryIdentities.js';\n\nexport type { PullRequestState };\n\n/**\n * The read that produced a pull request row, as a key for `getPullRequestFieldPresence` (`@gitlens/integrations`). It\n * names a READ, not a field set: the same tag can carry different fields on different providers.\n */\nexport type PullRequestProjection =\n\t/** A single-item read: by number, for a branch, or for a commit. */\n\t| 'point'\n\t/** The filtered search with the full projection, and the host's \"my pull requests\" search. */\n\t| 'search'\n\t/** The filtered search with `summary`. */\n\t| 'search-summary'\n\t/** The free-text search (`searchPullRequests`). */\n\t| 'text-search'\n\t/** An account-wide sweep with the full projection (`includeReviews`). */\n\t| 'account'\n\t/** An account-wide list or sweep with the lightweight projection. */\n\t| 'account-summary'\n\t/** A repository-scoped list or sweep. */\n\t| 'repos'\n\t/** A repository-scoped list with `summary`. */\n\t| 'repos-summary'\n\t/** The coordinate and branch batch reads. */\n\t| 'batch';\n\nexport interface PullRequestShape extends IssueOrPullRequest {\n\treadonly state: PullRequestState;\n\treadonly author: PullRequestMember;\n\t/**\n\t * Canonical base-repository identity returned by the provider. Some providers\n\t * scope pull-request ids to a repository, so consumers must not have to infer\n\t * identity from optional refs or URLs.\n\t */\n\treadonly repository?: IssueRepository;\n\treadonly mergedDate?: Date;\n\treadonly refs?: PullRequestRefs;\n\treadonly isDraft?: boolean;\n\treadonly additions?: number;\n\treadonly deletions?: number;\n\treadonly filesChanged?: number;\n\treadonly body?: string;\n\treadonly mergeableState?: PullRequestMergeableState;\n\treadonly reviewDecision?: PullRequestReviewDecision;\n\treadonly reviewRequests?: PullRequestReviewer[];\n\t/**\n\t * Reviews already submitted, as opposed to the still-pending {@link reviewRequests}. Absent means the read\n\t * didn't fetch reviews; empty means nobody has reviewed — but only where the read actually fetched them, which\n\t * is provider- and read-dependent: ask `getPullRequestFieldPresence` (`@gitlens/integrations`) for the row's\n\t * `reviews` group rather than trusting an empty array.\n\t * {@link PullRequestReviewer.commitOid} is the narrower promise: only the full GitHub/GHE projection has it.\n\t */\n\treadonly latestReviews?: PullRequestReviewer[];\n\treadonly assignees?: PullRequestMember[];\n\treadonly project?: IssueProject;\n\treadonly stack?: PullRequestStackInfo;\n\treadonly number?: number;\n\treadonly authoredByMe?: boolean;\n\t/**\n\t * The current account as this pull request's members identify it: the identity its people were matched against,\n\t * present whenever it was resolved (see {@link viewerUnresolved} for an Azure DevOps row it couldn't be for). {@link authoredByMe} is matched against it too, and stays `undefined` when the\n\t * row has no author, though its reviewers or assignees still get this. A consumer matching {@link reviewRequests}\n\t * or {@link latestReviews} entries to the current user compares against this, not the account `getCurrentAccount`\n\t * returns: Azure DevOps can know one person by another id in each organization (Azure DevOps Server: collection)\n\t * than the account's, and the members carry the organization's. Core matches `username` too only on GitHub and\n\t * GitHub Enterprise, whose rows key people by login.\n\t */\n\treadonly viewer?: { readonly id: string; readonly username?: string };\n\t/**\n\t * Set, and only ever `true`, on an Azure DevOps row that names someone (its author, a reviewer or an assignee)\n\t * whose organization's (Azure DevOps Server: collection's) identity the read tried and failed to resolve: its\n\t * `ConnectionData` failed, answered without an identity, or didn't answer within 10 seconds. Such a row has neither\n\t * {@link viewer} nor {@link authoredByMe}, and neither the account `getCurrentAccount` returns nor anyone else can\n\t * be matched against its people: whether it is the current user's, or asks for their review, is unknown, not \"no\".\n\t * Absent everywhere else, so a row with neither field is still one whose identity wasn't resolved for another\n\t * reason (a read that doesn't resolve it, or a failed account read), as before.\n\t */\n\treadonly viewerUnresolved?: true;\n\t/** The read that produced this row. Absent means unknown: a legacy row, or a provider or read not yet tagged. */\n\treadonly projection?: PullRequestProjection;\n}\n\n@loggable(i => i.id)\n@serializable\nexport class PullRequest implements PullRequestShape {\n\treadonly type = 'pullrequest';\n\n\tconstructor(\n\t\tpublic readonly provider: ProviderReference,\n\t\tpublic readonly author: PullRequestMember,\n\t\tpublic readonly id: string,\n\t\tpublic readonly nodeId: string | undefined,\n\t\tpublic readonly title: string,\n\t\tpublic readonly url: string,\n\t\tpublic readonly repository: IssueRepository,\n\t\tpublic readonly state: PullRequestState,\n\t\tpublic readonly createdDate: Date,\n\t\tpublic readonly updatedDate: Date,\n\t\tpublic readonly closedDate?: Date,\n\t\tpublic readonly mergedDate?: Date,\n\t\tpublic readonly mergeableState?: PullRequestMergeableState,\n\t\tpublic readonly viewerCanUpdate?: boolean,\n\t\tpublic readonly refs?: PullRequestRefs,\n\t\tpublic readonly isDraft?: boolean,\n\t\tpublic readonly additions?: number,\n\t\tpublic readonly deletions?: number,\n\t\tpublic readonly commentsCount?: number,\n\t\tpublic readonly thumbsUpCount?: number,\n\t\tpublic readonly reviewDecision?: PullRequestReviewDecision,\n\t\tpublic readonly reviewRequests?: PullRequestReviewer[],\n\t\tpublic readonly latestReviews?: PullRequestReviewer[],\n\t\tpublic readonly assignees?: PullRequestMember[],\n\t\tpublic readonly statusCheckRollupState?: PullRequestStatusCheckRollupState,\n\t\tpublic readonly project?: IssueProject,\n\t\tpublic readonly version?: number,\n\t\t/** Commits on the head that aren't on the base. Appended rather than slotted with the other counts:\n\t\t * this constructor is positional and every mapper passes through it. */\n\t\tpublic readonly commitCount?: number,\n\t\tpublic readonly stack?: PullRequestStackInfo,\n\t\tpublic readonly filesChanged?: number,\n\t\t/** The pull request's description, as markdown. */\n\t\tpublic readonly body?: string,\n\t\tpublic readonly number?: number,\n\t\tpublic readonly authoredByMe?: boolean,\n\t\tpublic readonly projection?: PullRequestProjection,\n\t\tpublic readonly viewer?: { readonly id: string; readonly username?: string },\n\t\tpublic readonly viewerUnresolved?: true,\n\t\tpublic readonly milestone?: IssueMilestone | null,\n\t) {}\n\n\tget closed(): boolean {\n\t\treturn this.state === 'closed';\n\t}\n\n\tstatic is(pr: unknown): pr is PullRequest {\n\t\treturn pr instanceof PullRequest;\n\t}\n\n\tstatic formatDate(pr: PullRequestShape, format?: string | null): string {\n\t\treturn formatDate(pr.mergedDate ?? pr.closedDate ?? pr.updatedDate, format ?? 'MMMM Do, YYYY h:mma');\n\t}\n\n\tstatic formatDateFromNow(pr: PullRequestShape): string {\n\t\treturn fromNow(pr.mergedDate ?? pr.closedDate ?? pr.updatedDate);\n\t}\n\n\tstatic formatDateWithStyle(\n\t\tpr: PullRequestShape,\n\t\tformatting: { dateStyle: string; dateFormat: string | null },\n\t): string {\n\t\treturn formatting.dateStyle === 'absolute'\n\t\t\t? PullRequest.formatDate(pr, formatting.dateFormat)\n\t\t\t: PullRequest.formatDateFromNow(pr);\n\t}\n}\n\nexport const enum PullRequestReviewDecision {\n\tApproved = 'Approved',\n\tChangesRequested = 'ChangesRequested',\n\tReviewRequired = 'ReviewRequired',\n}\n\nexport const enum PullRequestMergeableState {\n\tUnknown = 'Unknown',\n\tMergeable = 'Mergeable',\n\tConflicting = 'Conflicting',\n\tFailingChecks = 'FailingChecks',\n\tBlockedByPolicy = 'BlockedByPolicy',\n}\n\nexport const enum PullRequestStatusCheckRollupState {\n\tSuccess = 'success',\n\tPending = 'pending',\n\tFailed = 'failed',\n}\n\nexport const enum PullRequestMergeMethod {\n\tMerge = 'merge',\n\tSquash = 'squash',\n\tRebase = 'rebase',\n}\n\nexport const enum PullRequestReviewState {\n\tApproved = 'APPROVED',\n\tChangesRequested = 'CHANGES_REQUESTED',\n\tCommented = 'COMMENTED',\n\tDismissed = 'DISMISSED',\n\tPending = 'PENDING',\n\tReviewRequested = 'REVIEW_REQUESTED',\n}\n\nexport interface PullRequestComparisonRefs {\n\trepoPath: string;\n\tbase: { ref: string; label: string };\n\thead: { ref: string; label: string };\n}\n\nexport interface PullRequestMember {\n\tid: string;\n\t/**\n\t * Absent when the provider exposes no display name for the member — same contract as `IssueMember.name`: a\n\t * fallback invented here can't be told apart from a real name downstream, so each consumer picks its own\n\t * presentation.\n\t */\n\tname?: string;\n\t/** The provider's handle for this person, when it has one — GitHub's login, Azure's `uniqueName` (a UPN,\n\t * so an email), Bitbucket's mutable `nickname`. Display/labelling only: it is neither guaranteed present\n\t * (GitLab's native mapper has none) nor a stable identity, so never key a match off it. */\n\tusername?: string;\n\tavatarUrl?: string;\n\turl?: string;\n}\n\n/** Provider-neutral relationship facets shared by PR listings and filtered PR search. */\nexport enum PullRequestFilter {\n\tAuthor = 'author',\n\tAssignee = 'assignee',\n\tReviewRequested = 'review-requested',\n\t/**\n\t * PRs the user has already reviewed (GitHub `reviewed-by:@me`), as opposed to `ReviewRequested` (a\n\t * still-pending request). Distinguishes \"waiting on the author after my review\" from \"waiting for my\n\t * review\". Not expressible on the repo-scoped listing — no provider SDK exposes a reviewed-by axis there —\n\t * so it is advertised for the account-wide read and for the filtered search (which can still bound itself\n\t * to repositories or an org), never under `supportedPullRequestFilters`.\n\t */\n\tReviewed = 'reviewed-by',\n\tMention = 'mention',\n}\n\n/** Selects which pull request states a read should include. `all` covers open + closed + merged. */\nexport type PullRequestStateFilter = 'open' | 'closed' | 'merged' | 'all';\n\n/**\n * A field a pull-request read can be ordered by, provider-neutral.\n *\n * Only two, and deliberately so — unlike {@link IssueSortField} this is the INTERSECTION of what GitHub's PR\n * search can order by server-side and what a {@link PullRequestShape} carries, because the filtered PR search\n * always merges its relationship × state facets in the facade and so must re-order the union itself (see\n * `getPullRequestComparator`). `created` and `updated` are both. A field GitHub cannot order PRs by, or one a\n * merged page can't reproduce, is left out rather than advertised and then approximated: relevance is unstable\n * and has no comparable value on a merge, and priority is not a pull-request concept on any provider that has PRs.\n */\nexport type PullRequestSortField =\n\t/** Creation date. */\n\t| 'created'\n\t/** Last activity. */\n\t| 'updated';\n\n/**\n * How a pull-request read is ordered, as `field:direction` — the same serializable shape {@link IssueSorting}\n * and `BranchSorting` use, so a consumer can persist it, compare it, or bind it straight to a setting or dropdown.\n */\nexport type PullRequestSorting = `${PullRequestSortField}:asc` | `${PullRequestSortField}:desc`;\n\n/**\n * The order the filtered pull-request search applies when the caller asks for none: most recently updated first,\n * which is what it served before ordering was an option. Named once rather than per layer — the criteria model\n * documents it, the GitHub query emits it, and the result-ceiling warning quotes it — so the three cannot\n * disagree about what \"the default\" is.\n */\nexport const defaultPullRequestSort: PullRequestSorting = 'updated:desc';\n\n/**\n * What the filtered pull-request search narrows on.\n *\n * Structured rather than a provider query string so callers can send free text without giving it a qualifier\n * channel, and can check {@link PullRequestSearchCapabilities} before issuing a read. Every requested criterion\n * is validated all-or-nothing before the provider runs; unsupported criteria never fall through to a wider\n * result set whose paging would no longer describe the returned items.\n *\n * Relationships are OR-ed, as are states. Omitting `relationships` removes the current-user constraint, which is\n * only safe when the manager call supplies a repository or organization scope. Omitting `states` reads open PRs.\n */\nexport interface PullRequestSearchCriteria {\n\t/**\n\t * Free text matched by the provider's own relevance rules. Tokens that look like provider qualifiers are\n\t * removed before the query is built, so text cannot change the search's scope or state.\n\t */\n\ttext?: string;\n\t/** Current-user relationship facets to union. Empty/omitted means no relationship constraint. */\n\trelationships?: PullRequestFilter[];\n\t/** Pull request states to union. Empty/omitted reads open PRs; `all` subsumes every other member. */\n\tstates?: PullRequestStateFilter[];\n\t/** ISO date (`YYYY-MM-DD`). The most effective narrowing criterion by far on a large scope. */\n\tupdatedAfter?: string;\n\t/** ISO date (`YYYY-MM-DD`). */\n\tcreatedAfter?: string;\n\t/** Includes PRs from archived repositories. They are excluded by default. */\n\tincludeArchived?: boolean;\n\t/**\n\t * Narrows on draft state: `true` returns only drafts, `false` only ready-for-review PRs. Omitted places no\n\t * constraint. A boolean rather than a truthy flag because `false` is a distinct request, not the absence of one.\n\t */\n\tdraft?: boolean;\n\t/**\n\t * How to order the results. Omitted means `updated:desc`, which is what this search has always served.\n\t *\n\t * Validated all-or-nothing against {@link PullRequestSearchCapabilities.sorts} like every other criterion: a\n\t * key the provider can't express server-side refuses the WHOLE read rather than falling back to the default,\n\t * because combined with the provider's result ceiling another order returns a different subset than was asked\n\t * for and the paging that comes with it describes that other subset. Do not change it mid-pagination — a\n\t * cursor carries the sort it was produced under; drop the cursor instead of threading it under a new key.\n\t */\n\tsort?: PullRequestSorting;\n}\n\n/**\n * Which {@link PullRequestSearchCriteria} fields and manager-level scopes a provider can express server-side.\n * An empty `relationships` means the provider has no filtered PR search at all.\n */\nexport interface PullRequestSearchCapabilities {\n\t/** Current-user relationship facets the provider can union. Empty means the search itself is unsupported. */\n\trelationships: PullRequestFilter[];\n\t/** Individual state values the provider can union in one logical search. */\n\tstates: PullRequestStateFilter[];\n\ttext: boolean;\n\tupdatedAfter: boolean;\n\tcreatedAfter: boolean;\n\tincludeArchived: boolean;\n\t/** Whether the provider can constrain the search by draft state server-side. */\n\tdraft: boolean;\n\t/** Whether the manager's repository-descriptor scope is supported. */\n\trepositoryScope: boolean;\n\t/** Whether the manager's organization scope is supported. */\n\torganizationScope: boolean;\n\t/**\n\t * Sort keys the search can express server-side. Always contains at least `updated:desc` — the historical\n\t * default — when the search exists at all, so it is never empty for a usable surface; a provider without a\n\t * filtered PR search reports an empty `relationships`, which is already the signal there is no surface to order.\n\t */\n\tsorts: PullRequestSorting[];\n}\n\nexport interface PullRequestRef {\n\t/**\n\t * `undefined` when the ref's repository was deleted (a removed fork): GitHub's rows say so, with `exists` false.\n\t * provider-apis' converters fill `''` instead, so test for a value rather than for `undefined`.\n\t */\n\towner: string | undefined;\n\t/**\n\t * The repository's name, never a path: a GitLab nested group is all {@link owner}. `undefined` (or `''`) when the\n\t * ref's repository was deleted, as {@link owner}.\n\t */\n\trepo: string | undefined;\n\tbranch: string;\n\tsha: string;\n\texists: boolean;\n\t/**\n\t * Web URL of the ref's repository. `undefined` when the provider cannot resolve it — Azure DevOps embeds an\n\t * abbreviated repository reference in a pull request, so a fork's URL may need a lookup that can fail.\n\t */\n\turl: string | undefined;\n\t/** HTTPS clone URL of the ref's repository, when the provider exposes it. */\n\tcloneHttps?: string;\n\t/** SSH clone URL of the ref's repository, when the provider exposes it. */\n\tcloneSsh?: string;\n\t/** Best-effort flag: whether the ref's repository is a fork. `undefined` when the provider can't tell. */\n\tisFork?: boolean;\n}\n\nexport interface PullRequestRefs {\n\tbase: PullRequestRef & { url: string };\n\thead: PullRequestRef;\n\tisCrossRepository: boolean;\n}\n\n/**\n * A pull request's membership in a stack — an ordered chain of dependent pull requests where each\n * targets the branch of the one below it.\n *\n * `baseRef` is the stack's ultimate target (its trunk) and is NOT the same as `refs.base`, which for\n * anything above the bottom layer names the layer below. Use `refs.base` to diff a single layer; use\n * `baseRef` to answer where the work ultimately lands.\n */\nexport interface PullRequestStackInfo {\n\t/**\n\t * Opaque, and NOT comparable across read paths: GitHub's GraphQL selection returns a node id\n\t * (`PRS_kwDO…`) while its REST stacks endpoint returns a numeric id (`1347135`) that we stringify —\n\t * both verified against the same live stack. Use {@link number} to identify a stack; two views of one\n\t * stack agree there and will not agree here.\n\t */\n\tid: string;\n\t/** Identifies the stack within its repository. */\n\tnumber: number;\n\t/** Total pull requests in the stack. */\n\tsize: number;\n\t/** This pull request's layer, 1-based, where 1 is closest to `baseRef`. */\n\tposition: number;\n\t/** The branch the bottom of the stack targets. */\n\tbaseRef: string;\n}\n\n/**\n * One layer of a stack — the pull request occupying it, and the head ref a rebase or push needs to act\n * on. Unlike {@link PullRequestStackInfo}, which locates a single pull request within a stack, this is\n * the per-layer detail a caller walking the whole stack needs, e.g. to cascade a rebase bottom to top.\n */\nexport interface PullRequestStackLayer {\n\t/** The pull request's number. */\n\tnumber: number;\n\t/** The pull request's head branch name, without a remote prefix. */\n\theadRef: string;\n\t/** The head branch's tip when the stack was read. */\n\theadSha: string;\n\t/** `true` once this layer has landed. */\n\tmerged: boolean;\n\t/** `true` while this layer is still a draft. */\n\tdraft: boolean;\n}\n\n/**\n * A stack's layers, ordered bottom to top. `baseRef` is the stack's ultimate target (its trunk), the\n * same distinction drawn on {@link PullRequestStackInfo} — it is NOT the base of any individual layer\n * above the bottom, which targets the layer below it instead.\n */\nexport interface PullRequestStackLayers {\n\t/** Opaque and not comparable across read paths — see {@link PullRequestStackInfo.id}. */\n\tid: string;\n\tnumber: number;\n\t/** The branch the bottom of the stack targets. */\n\tbaseRef: string;\n\t/** The stack's layers, ordered bottom (closest to {@link baseRef}) to top. */\n\tlayers: PullRequestStackLayer[];\n}\n\nexport interface PullRequestReviewer {\n\tisCodeOwner?: boolean;\n\treviewer: PullRequestMember;\n\tstate: PullRequestReviewState;\n\t/**\n\t * The head commit oid this review was submitted against (GitHub). Lets a consumer tell \"the PR moved past\n\t * my review\" (oid !== the PR's current head) from a review still at the tip — without a per-review\n\t * timestamp. Only populated where the full GitHub/GHE projection is selected: the filtered search read, and\n\t * an account-wide sweep that opts in with `includeReviews`. Undefined elsewhere, including reviews the\n\t * repo-scoped read carries natively.\n\t */\n\tcommitOid?: string;\n\t/**\n\t * The reviewer is a group the current user is a member of (a team or another group, directly or through a group\n\t * nested in it) rather than a person: a request to it is one the user can answer as a member, not one addressed to\n\t * them by name. Only the Azure DevOps reads that resolve the user's groups set it; absent elsewhere, including for\n\t * groups a read could not tell the user belongs to.\n\t */\n\tisMyGroup?: boolean;\n}\n\nexport type PullRequestRepositoryIdentityDescriptor = RequireSomeWithProps<\n\tRequireSome<RepositoryIdentityDescriptor<string>, 'provider'>,\n\t'provider',\n\t'id' | 'domain' | 'repoDomain' | 'repoName'\n> &\n\tRequireSomeWithProps<RequireSome<RepositoryIdentityDescriptor<string>, 'remote'>, 'remote', 'domain'>;\n"],"mappings":";;;;;;AAiGO,IAAM,cAAA,eAAN,MAAM,YAAwC;CAInC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAGA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CA1CjB,OAAgB;CAEhB,YACC,UACA,QACA,IACA,QACA,OACA,KACA,YACA,OACA,aACA,aACA,YACA,YACA,gBACA,iBACA,MACA,SACA,WACA,WACA,eACA,eACA,gBACA,gBACA,eACA,WACA,wBACA,SACA,SAGA,aACA,OACA,cAEA,MACA,QACA,cACA,YACA,QACA,kBACA,WACC;EAxCe,KAAA,WAAA;EACA,KAAA,SAAA;EACA,KAAA,KAAA;EACA,KAAA,SAAA;EACA,KAAA,QAAA;EACA,KAAA,MAAA;EACA,KAAA,aAAA;EACA,KAAA,QAAA;EACA,KAAA,cAAA;EACA,KAAA,cAAA;EACA,KAAA,aAAA;EACA,KAAA,aAAA;EACA,KAAA,iBAAA;EACA,KAAA,kBAAA;EACA,KAAA,OAAA;EACA,KAAA,UAAA;EACA,KAAA,YAAA;EACA,KAAA,YAAA;EACA,KAAA,gBAAA;EACA,KAAA,gBAAA;EACA,KAAA,iBAAA;EACA,KAAA,iBAAA;EACA,KAAA,gBAAA;EACA,KAAA,YAAA;EACA,KAAA,yBAAA;EACA,KAAA,UAAA;EACA,KAAA,UAAA;EAGA,KAAA,cAAA;EACA,KAAA,QAAA;EACA,KAAA,eAAA;EAEA,KAAA,OAAA;EACA,KAAA,SAAA;EACA,KAAA,eAAA;EACA,KAAA,aAAA;EACA,KAAA,SAAA;EACA,KAAA,mBAAA;EACA,KAAA,YAAA;CACd;CAEH,IAAI,SAAkB;EACrB,OAAO,KAAK,UAAU;CACvB;CAEA,OAAO,GAAG,IAAgC;EACzC,OAAO,cAAA;CACR;CAEA,OAAO,WAAW,IAAsB,QAAgC;EACvE,OAAO,WAAW,GAAG,cAAc,GAAG,cAAc,GAAG,aAAa,UAAU,qBAAqB;CACpG;CAEA,OAAO,kBAAkB,IAA8B;EACtD,OAAO,QAAQ,GAAG,cAAc,GAAG,cAAc,GAAG,WAAW;CAChE;CAEA,OAAO,oBACN,IACA,YACS;EACT,OAAO,WAAW,cAAc,aAAA,aACjB,WAAW,IAAI,WAAW,UAAU,IAAA,aACpC,kBAAkB,EAAE;CACpC;AACD;AAxEC,cAAA,eAAA,WAAA,CAAA,UAAS,MAAK,EAAE,EAAE,GAClB,YAAA,GAAA,WAAA;AAyED,IAAkB,4BAAX,yBAAA,2BAAA;CACN,0BAAA,cAAA;CACA,0BAAA,sBAAA;CACA,0BAAA,oBAAA;;AACD,EAAA,CAAA,CAAA;AAEA,IAAkB,4BAAX,yBAAA,2BAAA;CACN,0BAAA,aAAA;CACA,0BAAA,eAAA;CACA,0BAAA,iBAAA;CACA,0BAAA,mBAAA;CACA,0BAAA,qBAAA;;AACD,EAAA,CAAA,CAAA;AAEA,IAAkB,oCAAX,yBAAA,mCAAA;CACN,kCAAA,aAAA;CACA,kCAAA,aAAA;CACA,kCAAA,YAAA;;AACD,EAAA,CAAA,CAAA;AAEA,IAAkB,yBAAX,yBAAA,wBAAA;CACN,uBAAA,WAAA;CACA,uBAAA,YAAA;CACA,uBAAA,YAAA;;AACD,EAAA,CAAA,CAAA;AAEA,IAAkB,yBAAX,yBAAA,wBAAA;CACN,uBAAA,cAAA;CACA,uBAAA,sBAAA;CACA,uBAAA,eAAA;CACA,uBAAA,eAAA;CACA,uBAAA,aAAA;CACA,uBAAA,qBAAA;;AACD,EAAA,CAAA,CAAA;;AAyBA,IAAY,oBAAL,yBAAA,mBAAA;CACN,kBAAA,YAAA;CACA,kBAAA,cAAA;CACA,kBAAA,qBAAA;;;;;;;;CAQA,kBAAA,cAAA;CACA,kBAAA,aAAA;;AACD,EAAA,CAAA,CAAA;;;;;;;AAiCA,MAAa,yBAA6C"}
|
|
1
|
+
{"version":3,"file":"pullRequest.js","names":[],"sources":["../../../../git/src/models/pullRequest.ts"],"sourcesContent":["import { formatDate, fromNow } from '@gitlens/utils/date.js';\nimport { loggable } from '@gitlens/utils/decorators/log.js';\nimport { serializable } from '@gitlens/utils/decorators/serializable.js';\nimport type { RequireSome, RequireSomeWithProps } from '@gitlens/utils/types.js';\nimport type { IssueProject, IssueRepository } from './issue.js';\nimport type {\n\tIssueMilestone,\n\tIssueOrPullRequest,\n\tIssueOrPullRequestState as PullRequestState,\n} from './issueOrPullRequest.js';\nimport type { ProviderReference } from './remoteProvider.js';\nimport type { RepositoryIdentityDescriptor } from './repositoryIdentities.js';\n\nexport type { PullRequestState };\n\n/**\n * The read that produced a pull request row, as a key for `getPullRequestFieldPresence` (`@gitlens/integrations`). It\n * names a READ, not a field set: the same tag can carry different fields on different providers.\n */\nexport type PullRequestProjection =\n\t/** A single-item read: by number, for a branch, or for a commit. */\n\t| 'point'\n\t/** The filtered search with the full projection, and the host's \"my pull requests\" search. */\n\t| 'search'\n\t/** The filtered search with `summary`. */\n\t| 'search-summary'\n\t/** The free-text search (`searchPullRequests`). */\n\t| 'text-search'\n\t/** An account-wide sweep with the full projection (`includeReviews`). */\n\t| 'account'\n\t/** An account-wide list or sweep with the lightweight projection. */\n\t| 'account-summary'\n\t/** A repository-scoped list or sweep. */\n\t| 'repos'\n\t/** A repository-scoped list with `summary`. */\n\t| 'repos-summary'\n\t/** The coordinate and branch batch reads. */\n\t| 'batch';\n\nexport interface PullRequestShape extends IssueOrPullRequest {\n\treadonly state: PullRequestState;\n\treadonly author: PullRequestMember;\n\t/**\n\t * Canonical base-repository identity returned by the provider. Some providers\n\t * scope pull-request ids to a repository, so consumers must not have to infer\n\t * identity from optional refs or URLs.\n\t */\n\treadonly repository?: IssueRepository;\n\treadonly mergedDate?: Date;\n\treadonly refs?: PullRequestRefs;\n\treadonly isDraft?: boolean;\n\treadonly additions?: number;\n\treadonly deletions?: number;\n\treadonly filesChanged?: number;\n\treadonly body?: string;\n\treadonly mergeableState?: PullRequestMergeableState;\n\treadonly reviewDecision?: PullRequestReviewDecision;\n\treadonly reviewRequests?: PullRequestReviewer[];\n\t/**\n\t * Reviews already submitted, as opposed to the still-pending {@link reviewRequests}. Absent means the read\n\t * didn't fetch reviews; empty means nobody has reviewed — but only where the read actually fetched them, which\n\t * is provider- and read-dependent: ask `getPullRequestFieldPresence` (`@gitlens/integrations`) for the row's\n\t * `reviews` group rather than trusting an empty array.\n\t * {@link PullRequestReviewer.commitOid} is the narrower promise: only the full GitHub/GHE projection has it.\n\t */\n\treadonly latestReviews?: PullRequestReviewer[];\n\treadonly assignees?: PullRequestMember[];\n\treadonly project?: IssueProject;\n\treadonly stack?: PullRequestStackInfo;\n\t/**\n\t * The pull request's place in its base branch's merge queue. Absent means either not queued or not fetched — ask\n\t * `getPullRequestFieldPresence` (`@gitlens/integrations`) for the row's `mergeQueue` group to tell them apart.\n\t * Only GitHub.com reports one.\n\t */\n\treadonly mergeQueue?: PullRequestMergeQueueEntry;\n\t/**\n\t * Whether the base branch accepts this pull request only through a merge queue, so merging it means adding it to\n\t * the queue. `undefined` means not read; read wherever `mergeQueue` is (the same `mergeQueue` field group).\n\t */\n\treadonly mergeQueueRequired?: boolean;\n\t/**\n\t * The pull request's latest removal from its merge queue, set only while that removal is its latest merge-queue\n\t * event (it hasn't rejoined since) and the removal didn't merge it. It stays set however much later the pull\n\t * request changes, so ask `isPullRequestMergeQueueRemovalCurrent` whether it still describes the pull request.\n\t * Read wherever `mergeQueue` is (the same `mergeQueue` field group); absent there means no such removal.\n\t */\n\treadonly mergeQueueRemoval?: PullRequestMergeQueueRemoval;\n\treadonly number?: number;\n\treadonly authoredByMe?: boolean;\n\t/**\n\t * The current account as this pull request's members identify it: the identity its people were matched against,\n\t * present whenever it was resolved (see {@link viewerUnresolved} for an Azure DevOps row it couldn't be for). {@link authoredByMe} is matched against it too, and stays `undefined` when the\n\t * row has no author, though its reviewers or assignees still get this. A consumer matching {@link reviewRequests}\n\t * or {@link latestReviews} entries to the current user compares against this, not the account `getCurrentAccount`\n\t * returns: Azure DevOps can know one person by another id in each organization (Azure DevOps Server: collection)\n\t * than the account's, and the members carry the organization's. Core matches `username` too only on GitHub and\n\t * GitHub Enterprise, whose rows key people by login.\n\t */\n\treadonly viewer?: { readonly id: string; readonly username?: string };\n\t/**\n\t * Set, and only ever `true`, on an Azure DevOps row that names someone (its author, a reviewer or an assignee)\n\t * whose organization's (Azure DevOps Server: collection's) identity the read tried and failed to resolve: its\n\t * `ConnectionData` failed, answered without an identity, or didn't answer within 10 seconds. Such a row has neither\n\t * {@link viewer} nor {@link authoredByMe}, and neither the account `getCurrentAccount` returns nor anyone else can\n\t * be matched against its people: whether it is the current user's, or asks for their review, is unknown, not \"no\".\n\t * Absent everywhere else, so a row with neither field is still one whose identity wasn't resolved for another\n\t * reason (a read that doesn't resolve it, or a failed account read), as before.\n\t */\n\treadonly viewerUnresolved?: true;\n\t/** The read that produced this row. Absent means unknown: a legacy row, or a provider or read not yet tagged. */\n\treadonly projection?: PullRequestProjection;\n}\n\n@loggable(i => i.id)\n@serializable\nexport class PullRequest implements PullRequestShape {\n\treadonly type = 'pullrequest';\n\n\tconstructor(\n\t\tpublic readonly provider: ProviderReference,\n\t\tpublic readonly author: PullRequestMember,\n\t\tpublic readonly id: string,\n\t\tpublic readonly nodeId: string | undefined,\n\t\tpublic readonly title: string,\n\t\tpublic readonly url: string,\n\t\tpublic readonly repository: IssueRepository,\n\t\tpublic readonly state: PullRequestState,\n\t\tpublic readonly createdDate: Date,\n\t\tpublic readonly updatedDate: Date,\n\t\tpublic readonly closedDate?: Date,\n\t\tpublic readonly mergedDate?: Date,\n\t\tpublic readonly mergeableState?: PullRequestMergeableState,\n\t\tpublic readonly viewerCanUpdate?: boolean,\n\t\tpublic readonly refs?: PullRequestRefs,\n\t\tpublic readonly isDraft?: boolean,\n\t\tpublic readonly additions?: number,\n\t\tpublic readonly deletions?: number,\n\t\tpublic readonly commentsCount?: number,\n\t\tpublic readonly thumbsUpCount?: number,\n\t\tpublic readonly reviewDecision?: PullRequestReviewDecision,\n\t\tpublic readonly reviewRequests?: PullRequestReviewer[],\n\t\tpublic readonly latestReviews?: PullRequestReviewer[],\n\t\tpublic readonly assignees?: PullRequestMember[],\n\t\tpublic readonly statusCheckRollupState?: PullRequestStatusCheckRollupState,\n\t\tpublic readonly project?: IssueProject,\n\t\tpublic readonly version?: number,\n\t\t/** Commits on the head that aren't on the base. Appended rather than slotted with the other counts:\n\t\t * this constructor is positional and every mapper passes through it. */\n\t\tpublic readonly commitCount?: number,\n\t\tpublic readonly stack?: PullRequestStackInfo,\n\t\tpublic readonly filesChanged?: number,\n\t\t/** The pull request's description, as markdown. */\n\t\tpublic readonly body?: string,\n\t\tpublic readonly number?: number,\n\t\tpublic readonly authoredByMe?: boolean,\n\t\tpublic readonly projection?: PullRequestProjection,\n\t\tpublic readonly viewer?: { readonly id: string; readonly username?: string },\n\t\tpublic readonly viewerUnresolved?: true,\n\t\tpublic readonly milestone?: IssueMilestone | null,\n\t\tpublic readonly mergeQueue?: PullRequestMergeQueueEntry,\n\t\tpublic readonly mergeQueueRequired?: boolean,\n\t\tpublic readonly mergeQueueRemoval?: PullRequestMergeQueueRemoval,\n\t) {}\n\n\tget closed(): boolean {\n\t\treturn this.state === 'closed';\n\t}\n\n\tstatic is(pr: unknown): pr is PullRequest {\n\t\treturn pr instanceof PullRequest;\n\t}\n\n\tstatic formatDate(pr: PullRequestShape, format?: string | null): string {\n\t\treturn formatDate(pr.mergedDate ?? pr.closedDate ?? pr.updatedDate, format ?? 'MMMM Do, YYYY h:mma');\n\t}\n\n\tstatic formatDateFromNow(pr: PullRequestShape): string {\n\t\treturn fromNow(pr.mergedDate ?? pr.closedDate ?? pr.updatedDate);\n\t}\n\n\tstatic formatDateWithStyle(\n\t\tpr: PullRequestShape,\n\t\tformatting: { dateStyle: string; dateFormat: string | null },\n\t): string {\n\t\treturn formatting.dateStyle === 'absolute'\n\t\t\t? PullRequest.formatDate(pr, formatting.dateFormat)\n\t\t\t: PullRequest.formatDateFromNow(pr);\n\t}\n}\n\nexport const enum PullRequestReviewDecision {\n\tApproved = 'Approved',\n\tChangesRequested = 'ChangesRequested',\n\tReviewRequired = 'ReviewRequired',\n}\n\nexport const enum PullRequestMergeableState {\n\tUnknown = 'Unknown',\n\tMergeable = 'Mergeable',\n\tConflicting = 'Conflicting',\n\tFailingChecks = 'FailingChecks',\n\tBlockedByPolicy = 'BlockedByPolicy',\n}\n\n/** Where a queued pull request stands in its merge queue. Mirrors GitHub's `MergeQueueEntryState`. */\nexport const enum PullRequestMergeQueueState {\n\tQueued = 'Queued',\n\t/** Waiting for its required checks to pass. */\n\tAwaitingChecks = 'AwaitingChecks',\n\tMergeable = 'Mergeable',\n\tUnmergeable = 'Unmergeable',\n\tLocked = 'Locked',\n}\n\nexport const enum PullRequestStatusCheckRollupState {\n\tSuccess = 'success',\n\tPending = 'pending',\n\tFailed = 'failed',\n}\n\nexport const enum PullRequestMergeMethod {\n\tMerge = 'merge',\n\tSquash = 'squash',\n\tRebase = 'rebase',\n}\n\nexport const enum PullRequestReviewState {\n\tApproved = 'APPROVED',\n\tChangesRequested = 'CHANGES_REQUESTED',\n\tCommented = 'COMMENTED',\n\tDismissed = 'DISMISSED',\n\tPending = 'PENDING',\n\tReviewRequested = 'REVIEW_REQUESTED',\n}\n\nexport interface PullRequestComparisonRefs {\n\trepoPath: string;\n\tbase: { ref: string; label: string };\n\thead: { ref: string; label: string };\n}\n\nexport interface PullRequestMember {\n\tid: string;\n\t/**\n\t * Absent when the provider exposes no display name for the member — same contract as `IssueMember.name`: a\n\t * fallback invented here can't be told apart from a real name downstream, so each consumer picks its own\n\t * presentation.\n\t */\n\tname?: string;\n\t/** The provider's handle for this person, when it has one — GitHub's login, Azure's `uniqueName` (a UPN,\n\t * so an email), Bitbucket's mutable `nickname`. Display/labelling only: it is neither guaranteed present\n\t * (GitLab's native mapper has none) nor a stable identity, so never key a match off it. */\n\tusername?: string;\n\tavatarUrl?: string;\n\turl?: string;\n}\n\n/** Provider-neutral relationship facets shared by PR listings and filtered PR search. */\nexport enum PullRequestFilter {\n\tAuthor = 'author',\n\tAssignee = 'assignee',\n\tReviewRequested = 'review-requested',\n\t/**\n\t * PRs the user has already reviewed (GitHub `reviewed-by:@me`), as opposed to `ReviewRequested` (a\n\t * still-pending request). Distinguishes \"waiting on the author after my review\" from \"waiting for my\n\t * review\". Not expressible on the repo-scoped listing — no provider SDK exposes a reviewed-by axis there —\n\t * so it is advertised for the account-wide read and for the filtered search (which can still bound itself\n\t * to repositories or an org), never under `supportedPullRequestFilters`.\n\t */\n\tReviewed = 'reviewed-by',\n\tMention = 'mention',\n}\n\n/** Selects which pull request states a read should include. `all` covers open + closed + merged. */\nexport type PullRequestStateFilter = 'open' | 'closed' | 'merged' | 'all';\n\n/**\n * A field a pull-request read can be ordered by, provider-neutral.\n *\n * Only two, and deliberately so — unlike {@link IssueSortField} this is the INTERSECTION of what GitHub's PR\n * search can order by server-side and what a {@link PullRequestShape} carries, because the filtered PR search\n * always merges its relationship × state facets in the facade and so must re-order the union itself (see\n * `getPullRequestComparator`). `created` and `updated` are both. A field GitHub cannot order PRs by, or one a\n * merged page can't reproduce, is left out rather than advertised and then approximated: relevance is unstable\n * and has no comparable value on a merge, and priority is not a pull-request concept on any provider that has PRs.\n */\nexport type PullRequestSortField =\n\t/** Creation date. */\n\t| 'created'\n\t/** Last activity. */\n\t| 'updated';\n\n/**\n * How a pull-request read is ordered, as `field:direction` — the same serializable shape {@link IssueSorting}\n * and `BranchSorting` use, so a consumer can persist it, compare it, or bind it straight to a setting or dropdown.\n */\nexport type PullRequestSorting = `${PullRequestSortField}:asc` | `${PullRequestSortField}:desc`;\n\n/**\n * The order the filtered pull-request search applies when the caller asks for none: most recently updated first,\n * which is what it served before ordering was an option. Named once rather than per layer — the criteria model\n * documents it, the GitHub query emits it, and the result-ceiling warning quotes it — so the three cannot\n * disagree about what \"the default\" is.\n */\nexport const defaultPullRequestSort: PullRequestSorting = 'updated:desc';\n\n/**\n * What the filtered pull-request search narrows on.\n *\n * Structured rather than a provider query string so callers can send free text without giving it a qualifier\n * channel, and can check {@link PullRequestSearchCapabilities} before issuing a read. Every requested criterion\n * is validated all-or-nothing before the provider runs; unsupported criteria never fall through to a wider\n * result set whose paging would no longer describe the returned items.\n *\n * Relationships are OR-ed, as are states. Omitting `relationships` removes the current-user constraint, which is\n * only safe when the manager call supplies a repository or organization scope. Omitting `states` reads open PRs.\n */\nexport interface PullRequestSearchCriteria {\n\t/**\n\t * Free text matched by the provider's own relevance rules. Tokens that look like provider qualifiers are\n\t * removed before the query is built, so text cannot change the search's scope or state.\n\t */\n\ttext?: string;\n\t/** Current-user relationship facets to union. Empty/omitted means no relationship constraint. */\n\trelationships?: PullRequestFilter[];\n\t/** Pull request states to union. Empty/omitted reads open PRs; `all` subsumes every other member. */\n\tstates?: PullRequestStateFilter[];\n\t/** ISO date (`YYYY-MM-DD`). The most effective narrowing criterion by far on a large scope. */\n\tupdatedAfter?: string;\n\t/** ISO date (`YYYY-MM-DD`). */\n\tcreatedAfter?: string;\n\t/** Includes PRs from archived repositories. They are excluded by default. */\n\tincludeArchived?: boolean;\n\t/**\n\t * Narrows on draft state: `true` returns only drafts, `false` only ready-for-review PRs. Omitted places no\n\t * constraint. A boolean rather than a truthy flag because `false` is a distinct request, not the absence of one.\n\t */\n\tdraft?: boolean;\n\t/**\n\t * How to order the results. Omitted means `updated:desc`, which is what this search has always served.\n\t *\n\t * Validated all-or-nothing against {@link PullRequestSearchCapabilities.sorts} like every other criterion: a\n\t * key the provider can't express server-side refuses the WHOLE read rather than falling back to the default,\n\t * because combined with the provider's result ceiling another order returns a different subset than was asked\n\t * for and the paging that comes with it describes that other subset. Do not change it mid-pagination — a\n\t * cursor carries the sort it was produced under; drop the cursor instead of threading it under a new key.\n\t */\n\tsort?: PullRequestSorting;\n}\n\n/**\n * Which {@link PullRequestSearchCriteria} fields and manager-level scopes a provider can express server-side.\n * An empty `relationships` means the provider has no filtered PR search at all.\n */\nexport interface PullRequestSearchCapabilities {\n\t/** Current-user relationship facets the provider can union. Empty means the search itself is unsupported. */\n\trelationships: PullRequestFilter[];\n\t/** Individual state values the provider can union in one logical search. */\n\tstates: PullRequestStateFilter[];\n\ttext: boolean;\n\tupdatedAfter: boolean;\n\tcreatedAfter: boolean;\n\tincludeArchived: boolean;\n\t/** Whether the provider can constrain the search by draft state server-side. */\n\tdraft: boolean;\n\t/** Whether the manager's repository-descriptor scope is supported. */\n\trepositoryScope: boolean;\n\t/** Whether the manager's organization scope is supported. */\n\torganizationScope: boolean;\n\t/**\n\t * Sort keys the search can express server-side. Always contains at least `updated:desc` — the historical\n\t * default — when the search exists at all, so it is never empty for a usable surface; a provider without a\n\t * filtered PR search reports an empty `relationships`, which is already the signal there is no surface to order.\n\t */\n\tsorts: PullRequestSorting[];\n}\n\nexport interface PullRequestRef {\n\t/**\n\t * `undefined` when the ref's repository was deleted (a removed fork): GitHub's rows say so, with `exists` false.\n\t * provider-apis' converters fill `''` instead, so test for a value rather than for `undefined`.\n\t */\n\towner: string | undefined;\n\t/**\n\t * The repository's name, never a path: a GitLab nested group is all {@link owner}. `undefined` (or `''`) when the\n\t * ref's repository was deleted, as {@link owner}.\n\t */\n\trepo: string | undefined;\n\tbranch: string;\n\tsha: string;\n\texists: boolean;\n\t/**\n\t * Web URL of the ref's repository. `undefined` when the provider cannot resolve it — Azure DevOps embeds an\n\t * abbreviated repository reference in a pull request, so a fork's URL may need a lookup that can fail.\n\t */\n\turl: string | undefined;\n\t/** HTTPS clone URL of the ref's repository, when the provider exposes it. */\n\tcloneHttps?: string;\n\t/** SSH clone URL of the ref's repository, when the provider exposes it. */\n\tcloneSsh?: string;\n\t/** Best-effort flag: whether the ref's repository is a fork. `undefined` when the provider can't tell. */\n\tisFork?: boolean;\n}\n\nexport interface PullRequestRefs {\n\tbase: PullRequestRef & { url: string };\n\thead: PullRequestRef;\n\tisCrossRepository: boolean;\n}\n\n/**\n * A pull request's membership in a stack — an ordered chain of dependent pull requests where each\n * targets the branch of the one below it.\n *\n * `baseRef` is the stack's ultimate target (its trunk) and is NOT the same as `refs.base`, which for\n * anything above the bottom layer names the layer below. Use `refs.base` to diff a single layer; use\n * `baseRef` to answer where the work ultimately lands.\n */\nexport interface PullRequestStackInfo {\n\t/**\n\t * Opaque, and NOT comparable across read paths: GitHub's GraphQL selection returns a node id\n\t * (`PRS_kwDO…`) while its REST stacks endpoint returns a numeric id (`1347135`) that we stringify —\n\t * both verified against the same live stack. Use {@link number} to identify a stack; two views of one\n\t * stack agree there and will not agree here.\n\t */\n\tid: string;\n\t/** Identifies the stack within its repository. */\n\tnumber: number;\n\t/** Total pull requests in the stack. */\n\tsize: number;\n\t/** This pull request's layer, 1-based, where 1 is closest to `baseRef`. */\n\tposition: number;\n\t/** The branch the bottom of the stack targets. */\n\tbaseRef: string;\n}\n\n/**\n * One layer of a stack — the pull request occupying it, and the head ref a rebase or push needs to act\n * on. Unlike {@link PullRequestStackInfo}, which locates a single pull request within a stack, this is\n * the per-layer detail a caller walking the whole stack needs, e.g. to cascade a rebase bottom to top.\n */\nexport interface PullRequestStackLayer {\n\t/** The pull request's number. */\n\tnumber: number;\n\t/** The pull request's head branch name, without a remote prefix. */\n\theadRef: string;\n\t/** The head branch's tip when the stack was read. */\n\theadSha: string;\n\t/** `true` once this layer has landed. */\n\tmerged: boolean;\n\t/** `true` while this layer is still a draft. */\n\tdraft: boolean;\n}\n\n/**\n * A stack's layers, ordered bottom to top. `baseRef` is the stack's ultimate target (its trunk), the\n * same distinction drawn on {@link PullRequestStackInfo} — it is NOT the base of any individual layer\n * above the bottom, which targets the layer below it instead.\n */\nexport interface PullRequestStackLayers {\n\t/** Opaque and not comparable across read paths — see {@link PullRequestStackInfo.id}. */\n\tid: string;\n\tnumber: number;\n\t/** The branch the bottom of the stack targets. */\n\tbaseRef: string;\n\t/** The stack's layers, ordered bottom (closest to {@link baseRef}) to top. */\n\tlayers: PullRequestStackLayer[];\n}\n\n/** A pull request's entry in its base branch's merge queue. */\nexport interface PullRequestMergeQueueEntry {\n\tstate: PullRequestMergeQueueState;\n\t/** When the pull request joined the queue. */\n\tenqueuedAt: Date;\n\t/**\n\t * When the provider expects it to merge: its estimate of the time remaining, fixed to a date when the entry was\n\t * read, so it counts down while the entry is held rather than restarting at each render. Absent when the provider\n\t * gives none; may already be past on an entry held a while.\n\t */\n\testimatedMergeAt?: Date;\n\t/** The merge queue's web URL. */\n\turl?: string;\n\t/**\n\t * The entry's 1-based place in the queue, in enqueue order. Absent when the provider gives none. It moves as the\n\t * entries ahead of it merge or leave, so it is never an etag input: an `unchanged` row's position can be stale.\n\t */\n\tposition?: number;\n}\n\n/** A pull request's removal from its base branch's merge queue, other than by merging. */\nexport interface PullRequestMergeQueueRemoval {\n\t/**\n\t * The provider's own reason, passed through as given — GitHub's include `failed_checks` and `manual`, and others\n\t * are undocumented. Empty when the provider gives none. Classify it with `getPullRequestMergeQueueRemovalKind`.\n\t */\n\treason: string;\n\t/** When the pull request was removed. */\n\tremovedAt: Date;\n}\n\n/** Why adding a pull request to its merge queue, or removing it, failed. */\nexport type PullRequestMergeQueueActionFailureReason =\n\t/** Adding a pull request that is already queued. */\n\t| 'already-queued'\n\t/** The pull request's head moved since it was read, so the head it was asked to queue is stale. */\n\t| 'head-changed'\n\t/** The host refused the action for the pull request's own state: its base branch has no merge queue, it is a\n\t * draft or closed, or it doesn't meet the queue's requirements. */\n\t| 'not-allowed'\n\t/** The account may not add to or remove from this queue. */\n\t| 'permission'\n\t/** The host (or this integration) has no merge queue to act on. */\n\t| 'unsupported'\n\t/** Anything else, including a failure to reach the host. */\n\t| 'unknown';\n\n/**\n * What adding a pull request to its merge queue, or removing it, did. A failure says why, with the host's own message\n * when it gave one — for logs and diagnostics, not for display.\n */\nexport type PullRequestMergeQueueActionResult =\n\t| {\n\t\t\treadonly status: 'queued';\n\t\t\t/** The new entry, when the host returned one. */\n\t\t\treadonly entry?: PullRequestMergeQueueEntry;\n\t }\n\t| { readonly status: 'dequeued' }\n\t| {\n\t\t\treadonly status: 'failed';\n\t\t\treadonly reason: PullRequestMergeQueueActionFailureReason;\n\t\t\treadonly message?: string;\n\t };\n\nexport interface PullRequestReviewer {\n\tisCodeOwner?: boolean;\n\treviewer: PullRequestMember;\n\tstate: PullRequestReviewState;\n\t/**\n\t * The head commit oid this review was submitted against (GitHub). Lets a consumer tell \"the PR moved past\n\t * my review\" (oid !== the PR's current head) from a review still at the tip — without a per-review\n\t * timestamp. Only populated where the full GitHub/GHE projection is selected: the filtered search read, and\n\t * an account-wide sweep that opts in with `includeReviews`. Undefined elsewhere, including reviews the\n\t * repo-scoped read carries natively.\n\t */\n\tcommitOid?: string;\n\t/**\n\t * The reviewer is a group the current user is a member of (a team or another group, directly or through a group\n\t * nested in it) rather than a person: a request to it is one the user can answer as a member, not one addressed to\n\t * them by name. Only the Azure DevOps reads that resolve the user's groups set it; absent elsewhere, including for\n\t * groups a read could not tell the user belongs to.\n\t */\n\tisMyGroup?: boolean;\n}\n\nexport type PullRequestRepositoryIdentityDescriptor = RequireSomeWithProps<\n\tRequireSome<RepositoryIdentityDescriptor<string>, 'provider'>,\n\t'provider',\n\t'id' | 'domain' | 'repoDomain' | 'repoName'\n> &\n\tRequireSomeWithProps<RequireSome<RepositoryIdentityDescriptor<string>, 'remote'>, 'remote', 'domain'>;\n"],"mappings":";;;;;;AAmHO,IAAM,cAAA,eAAN,MAAM,YAAwC;CAInC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAGA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CA7CjB,OAAgB;CAEhB,YACC,UACA,QACA,IACA,QACA,OACA,KACA,YACA,OACA,aACA,aACA,YACA,YACA,gBACA,iBACA,MACA,SACA,WACA,WACA,eACA,eACA,gBACA,gBACA,eACA,WACA,wBACA,SACA,SAGA,aACA,OACA,cAEA,MACA,QACA,cACA,YACA,QACA,kBACA,WACA,YACA,oBACA,mBACC;EA3Ce,KAAA,WAAA;EACA,KAAA,SAAA;EACA,KAAA,KAAA;EACA,KAAA,SAAA;EACA,KAAA,QAAA;EACA,KAAA,MAAA;EACA,KAAA,aAAA;EACA,KAAA,QAAA;EACA,KAAA,cAAA;EACA,KAAA,cAAA;EACA,KAAA,aAAA;EACA,KAAA,aAAA;EACA,KAAA,iBAAA;EACA,KAAA,kBAAA;EACA,KAAA,OAAA;EACA,KAAA,UAAA;EACA,KAAA,YAAA;EACA,KAAA,YAAA;EACA,KAAA,gBAAA;EACA,KAAA,gBAAA;EACA,KAAA,iBAAA;EACA,KAAA,iBAAA;EACA,KAAA,gBAAA;EACA,KAAA,YAAA;EACA,KAAA,yBAAA;EACA,KAAA,UAAA;EACA,KAAA,UAAA;EAGA,KAAA,cAAA;EACA,KAAA,QAAA;EACA,KAAA,eAAA;EAEA,KAAA,OAAA;EACA,KAAA,SAAA;EACA,KAAA,eAAA;EACA,KAAA,aAAA;EACA,KAAA,SAAA;EACA,KAAA,mBAAA;EACA,KAAA,YAAA;EACA,KAAA,aAAA;EACA,KAAA,qBAAA;EACA,KAAA,oBAAA;CACd;CAEH,IAAI,SAAkB;EACrB,OAAO,KAAK,UAAU;CACvB;CAEA,OAAO,GAAG,IAAgC;EACzC,OAAO,cAAA;CACR;CAEA,OAAO,WAAW,IAAsB,QAAgC;EACvE,OAAO,WAAW,GAAG,cAAc,GAAG,cAAc,GAAG,aAAa,UAAU,qBAAqB;CACpG;CAEA,OAAO,kBAAkB,IAA8B;EACtD,OAAO,QAAQ,GAAG,cAAc,GAAG,cAAc,GAAG,WAAW;CAChE;CAEA,OAAO,oBACN,IACA,YACS;EACT,OAAO,WAAW,cAAc,aAAA,aACjB,WAAW,IAAI,WAAW,UAAU,IAAA,aACpC,kBAAkB,EAAE;CACpC;AACD;AA3EC,cAAA,eAAA,WAAA,CAAA,UAAS,MAAK,EAAE,EAAE,GAClB,YAAA,GAAA,WAAA;AA4ED,IAAkB,4BAAX,yBAAA,2BAAA;CACN,0BAAA,cAAA;CACA,0BAAA,sBAAA;CACA,0BAAA,oBAAA;;AACD,EAAA,CAAA,CAAA;AAEA,IAAkB,4BAAX,yBAAA,2BAAA;CACN,0BAAA,aAAA;CACA,0BAAA,eAAA;CACA,0BAAA,iBAAA;CACA,0BAAA,mBAAA;CACA,0BAAA,qBAAA;;AACD,EAAA,CAAA,CAAA;;AAGA,IAAkB,6BAAX,yBAAA,4BAAA;CACN,2BAAA,YAAA;;CAEA,2BAAA,oBAAA;CACA,2BAAA,eAAA;CACA,2BAAA,iBAAA;CACA,2BAAA,YAAA;;AACD,EAAA,CAAA,CAAA;AAEA,IAAkB,oCAAX,yBAAA,mCAAA;CACN,kCAAA,aAAA;CACA,kCAAA,aAAA;CACA,kCAAA,YAAA;;AACD,EAAA,CAAA,CAAA;AAEA,IAAkB,yBAAX,yBAAA,wBAAA;CACN,uBAAA,WAAA;CACA,uBAAA,YAAA;CACA,uBAAA,YAAA;;AACD,EAAA,CAAA,CAAA;AAEA,IAAkB,yBAAX,yBAAA,wBAAA;CACN,uBAAA,cAAA;CACA,uBAAA,sBAAA;CACA,uBAAA,eAAA;CACA,uBAAA,eAAA;CACA,uBAAA,aAAA;CACA,uBAAA,qBAAA;;AACD,EAAA,CAAA,CAAA;;AAyBA,IAAY,oBAAL,yBAAA,mBAAA;CACN,kBAAA,YAAA;CACA,kBAAA,cAAA;CACA,kBAAA,qBAAA;;;;;;;;CAQA,kBAAA,cAAA;CACA,kBAAA,aAAA;;AACD,EAAA,CAAA,CAAA;;;;;;;AAiCA,MAAa,yBAA6C"}
|
|
@@ -28,6 +28,8 @@ var RemotesGitProviderBase = class {
|
|
|
28
28
|
}
|
|
29
29
|
async getBestRemotesWithProviders(repoPath, cancellation) {
|
|
30
30
|
if (!repoPath) return [];
|
|
31
|
+
const validation = this.cache.validateBeforeRead(repoPath);
|
|
32
|
+
if (validation != null) await validation;
|
|
31
33
|
return [...await this.cache.bestRemotes.getOrCreate(repoPath, async (_cacheable, aggregateSignal) => {
|
|
32
34
|
const remotes = await this.getRemotesWithProviders(repoPath, { sort: true }, aggregateSignal);
|
|
33
35
|
if (remotes.length === 0) return [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remotes.js","names":[],"sources":["../../../../../git/src/providers/shared/remotes.ts"],"sourcesContent":["import { debug } from '@gitlens/utils/decorators/log.js';\nimport { sortCompare } from '@gitlens/utils/string.js';\nimport type { Cache } from '../../cache.js';\nimport type { GitServiceContext } from '../../context.js';\nimport type { GitRemote } from '../../models/remote.js';\nimport type { RemoteProvider } from '../../models/remoteProvider.js';\nimport { getDefaultRemoteOrHighlander } from '../../utils/remote.utils.js';\nimport type { GitProvider } from '../provider.js';\nimport type { GitRemotesSubProvider } from '../remotes.js';\n\nexport abstract class RemotesGitProviderBase implements GitRemotesSubProvider {\n\tconstructor(\n\t\tprotected readonly context: GitServiceContext,\n\t\tprotected readonly cache: Cache,\n\t\tprotected readonly provider: GitProvider,\n\t) {}\n\n\tabstract getRemotes(\n\t\trepoPath: string | undefined,\n\t\toptions?: { filter?: (remote: GitRemote) => boolean; sort?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitRemote[]>;\n\n\t@debug({ quiet: true })\n\tasync getRemote(\n\t\trepoPath: string | undefined,\n\t\tname: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitRemote | undefined> {\n\t\tif (repoPath == null) return undefined;\n\n\t\tconst remotes = await this.getRemotes(repoPath, undefined, cancellation);\n\t\treturn remotes.find(r => r.name === name);\n\t}\n\n\t@debug({ quiet: true })\n\tasync getDefaultRemote(repoPath: string, cancellation?: AbortSignal): Promise<GitRemote | undefined> {\n\t\tconst remotes = await this.getRemotes(repoPath, undefined, cancellation);\n\t\treturn getDefaultRemoteOrHighlander(remotes);\n\t}\n\n\t@debug({ quiet: true })\n\tasync getRemotesWithProviders(\n\t\trepoPath: string,\n\t\toptions?: { sort?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitRemote<RemoteProvider>[]> {\n\t\tconst remotes = await this.getRemotes(repoPath, options, cancellation);\n\t\treturn remotes.filter((r): r is GitRemote<RemoteProvider> => r.provider != null);\n\t}\n\n\t@debug({ quiet: true })\n\tasync getBestRemoteWithProvider(\n\t\trepoPath: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitRemote<RemoteProvider> | undefined> {\n\t\tconst remotes = await this.getBestRemotesWithProviders(repoPath, cancellation);\n\t\treturn remotes[0];\n\t}\n\n\t@debug({ quiet: true })\n\tasync getBestRemotesWithProviders(\n\t\trepoPath: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitRemote<RemoteProvider>[]> {\n\t\tif (!repoPath) return [];\n\n\t\tconst remotes = this.cache.bestRemotes.getOrCreate(\n\t\t\trepoPath,\n\t\t\tasync (_cacheable, aggregateSignal) => {\n\t\t\t\tconst remotes = await this.getRemotesWithProviders(repoPath, { sort: true }, aggregateSignal);\n\t\t\t\tif (remotes.length === 0) return [];\n\t\t\t\tif (remotes.length === 1) return [...remotes];\n\n\t\t\t\tif (this.context.remotes?.sort != null) {\n\t\t\t\t\treturn this.context.remotes.sort(remotes, aggregateSignal);\n\t\t\t\t}\n\n\t\t\t\t// Fallback: sort by name when no host sort is provided\n\t\t\t\treturn remotes.toSorted((a, b) => sortCompare(a.name, b.name));\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\n\t\treturn [...(await remotes)];\n\t}\n\n\t@debug()\n\tasync setRemoteAsDefault(repoPath: string, name: string, value: boolean = true): Promise<void> {\n\t\t// setGkConfig is optional — providers that don't support git config (e.g. GitHub) silently skip persistence\n\t\tawait this.provider.config.setGkConfig?.(repoPath, 'gk.defaultRemote', value ? name : undefined);\n\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'remotes');\n\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['remotes', 'remoteProviders']);\n\t}\n}\n"],"mappings":";;;;;AAUA,IAAsB,yBAAtB,MAA8E;CAEzD;CACA;CACA;CAHpB,YACC,SACA,OACA,UACC;EAHkB,KAAA,UAAA;EACA,KAAA,QAAA;EACA,KAAA,WAAA;CACjB;CAQH,MACM,UACL,UACA,MACA,cACiC;EACjC,IAAI,YAAY,MAAM,OAAO,KAAA;EAG7B,QAAO,MADe,KAAK,WAAW,UAAU,KAAA,GAAW,YAAY,EAAA,CACxD,MAAK,MAAK,EAAE,SAAS,IAAI;CACzC;CAEA,MACM,iBAAiB,UAAkB,cAA4D;EACpG,MAAM,UAAU,MAAM,KAAK,WAAW,UAAU,KAAA,GAAW,YAAY;EACvE,OAAO,6BAA6B,OAAO;CAC5C;CAEA,MACM,wBACL,UACA,SACA,cACuC;EAEvC,QAAO,MADe,KAAK,WAAW,UAAU,SAAS,YAAY,EAAA,CACtD,QAAQ,MAAsC,EAAE,YAAY,IAAI;CAChF;CAEA,MACM,0BACL,UACA,cACiD;EAEjD,QAAO,MADe,KAAK,4BAA4B,UAAU,YAAY,EAAA,CAC9D;CAChB;CAEA,MACM,4BACL,UACA,cACuC;EACvC,IAAI,CAAC,UAAU,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"remotes.js","names":[],"sources":["../../../../../git/src/providers/shared/remotes.ts"],"sourcesContent":["import { debug } from '@gitlens/utils/decorators/log.js';\nimport { sortCompare } from '@gitlens/utils/string.js';\nimport type { Cache } from '../../cache.js';\nimport type { GitServiceContext } from '../../context.js';\nimport type { GitRemote } from '../../models/remote.js';\nimport type { RemoteProvider } from '../../models/remoteProvider.js';\nimport { getDefaultRemoteOrHighlander } from '../../utils/remote.utils.js';\nimport type { GitProvider } from '../provider.js';\nimport type { GitRemotesSubProvider } from '../remotes.js';\n\nexport abstract class RemotesGitProviderBase implements GitRemotesSubProvider {\n\tconstructor(\n\t\tprotected readonly context: GitServiceContext,\n\t\tprotected readonly cache: Cache,\n\t\tprotected readonly provider: GitProvider,\n\t) {}\n\n\tabstract getRemotes(\n\t\trepoPath: string | undefined,\n\t\toptions?: { filter?: (remote: GitRemote) => boolean; sort?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitRemote[]>;\n\n\t@debug({ quiet: true })\n\tasync getRemote(\n\t\trepoPath: string | undefined,\n\t\tname: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitRemote | undefined> {\n\t\tif (repoPath == null) return undefined;\n\n\t\tconst remotes = await this.getRemotes(repoPath, undefined, cancellation);\n\t\treturn remotes.find(r => r.name === name);\n\t}\n\n\t@debug({ quiet: true })\n\tasync getDefaultRemote(repoPath: string, cancellation?: AbortSignal): Promise<GitRemote | undefined> {\n\t\tconst remotes = await this.getRemotes(repoPath, undefined, cancellation);\n\t\treturn getDefaultRemoteOrHighlander(remotes);\n\t}\n\n\t@debug({ quiet: true })\n\tasync getRemotesWithProviders(\n\t\trepoPath: string,\n\t\toptions?: { sort?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitRemote<RemoteProvider>[]> {\n\t\tconst remotes = await this.getRemotes(repoPath, options, cancellation);\n\t\treturn remotes.filter((r): r is GitRemote<RemoteProvider> => r.provider != null);\n\t}\n\n\t@debug({ quiet: true })\n\tasync getBestRemoteWithProvider(\n\t\trepoPath: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitRemote<RemoteProvider> | undefined> {\n\t\tconst remotes = await this.getBestRemotesWithProviders(repoPath, cancellation);\n\t\treturn remotes[0];\n\t}\n\n\t@debug({ quiet: true })\n\tasync getBestRemotesWithProviders(\n\t\trepoPath: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitRemote<RemoteProvider>[]> {\n\t\tif (!repoPath) return [];\n\n\t\t// Derived from the remotes, so validated as their reads are (see `Cache.setReadValidator`)\n\t\tconst validation = this.cache.validateBeforeRead(repoPath);\n\t\tif (validation != null) {\n\t\t\tawait validation;\n\t\t}\n\n\t\tconst remotes = this.cache.bestRemotes.getOrCreate(\n\t\t\trepoPath,\n\t\t\tasync (_cacheable, aggregateSignal) => {\n\t\t\t\tconst remotes = await this.getRemotesWithProviders(repoPath, { sort: true }, aggregateSignal);\n\t\t\t\tif (remotes.length === 0) return [];\n\t\t\t\tif (remotes.length === 1) return [...remotes];\n\n\t\t\t\tif (this.context.remotes?.sort != null) {\n\t\t\t\t\treturn this.context.remotes.sort(remotes, aggregateSignal);\n\t\t\t\t}\n\n\t\t\t\t// Fallback: sort by name when no host sort is provided\n\t\t\t\treturn remotes.toSorted((a, b) => sortCompare(a.name, b.name));\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\n\t\treturn [...(await remotes)];\n\t}\n\n\t@debug()\n\tasync setRemoteAsDefault(repoPath: string, name: string, value: boolean = true): Promise<void> {\n\t\t// setGkConfig is optional — providers that don't support git config (e.g. GitHub) silently skip persistence\n\t\tawait this.provider.config.setGkConfig?.(repoPath, 'gk.defaultRemote', value ? name : undefined);\n\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'remotes');\n\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['remotes', 'remoteProviders']);\n\t}\n}\n"],"mappings":";;;;;AAUA,IAAsB,yBAAtB,MAA8E;CAEzD;CACA;CACA;CAHpB,YACC,SACA,OACA,UACC;EAHkB,KAAA,UAAA;EACA,KAAA,QAAA;EACA,KAAA,WAAA;CACjB;CAQH,MACM,UACL,UACA,MACA,cACiC;EACjC,IAAI,YAAY,MAAM,OAAO,KAAA;EAG7B,QAAO,MADe,KAAK,WAAW,UAAU,KAAA,GAAW,YAAY,EAAA,CACxD,MAAK,MAAK,EAAE,SAAS,IAAI;CACzC;CAEA,MACM,iBAAiB,UAAkB,cAA4D;EACpG,MAAM,UAAU,MAAM,KAAK,WAAW,UAAU,KAAA,GAAW,YAAY;EACvE,OAAO,6BAA6B,OAAO;CAC5C;CAEA,MACM,wBACL,UACA,SACA,cACuC;EAEvC,QAAO,MADe,KAAK,WAAW,UAAU,SAAS,YAAY,EAAA,CACtD,QAAQ,MAAsC,EAAE,YAAY,IAAI;CAChF;CAEA,MACM,0BACL,UACA,cACiD;EAEjD,QAAO,MADe,KAAK,4BAA4B,UAAU,YAAY,EAAA,CAC9D;CAChB;CAEA,MACM,4BACL,UACA,cACuC;EACvC,IAAI,CAAC,UAAU,OAAO,CAAC;EAGvB,MAAM,aAAa,KAAK,MAAM,mBAAmB,QAAQ;EACzD,IAAI,cAAc,MACjB,MAAM;EAoBP,OAAO,CAAC,GAAI,MAjBI,KAAK,MAAM,YAAY,YACtC,UACA,OAAO,YAAY,oBAAoB;GACtC,MAAM,UAAU,MAAM,KAAK,wBAAwB,UAAU,EAAE,MAAM,KAAK,GAAG,eAAe;GAC5F,IAAI,QAAQ,WAAW,GAAG,OAAO,CAAC;GAClC,IAAI,QAAQ,WAAW,GAAG,OAAO,CAAC,GAAG,OAAO;GAE5C,IAAI,KAAK,QAAQ,SAAS,QAAQ,MACjC,OAAO,KAAK,QAAQ,QAAQ,KAAK,SAAS,eAAe;GAI1D,OAAO,QAAQ,UAAU,GAAG,MAAM,YAAY,EAAE,MAAM,EAAE,IAAI,CAAC;EAC9D,GACA,YAGuB,CAAE;CAC3B;CAEA,MACM,mBAAmB,UAAkB,MAAc,QAAiB,MAAqB;EAE9F,MAAM,KAAK,SAAS,OAAO,cAAc,UAAU,oBAAoB,QAAQ,OAAO,KAAA,CAAS;EAC/F,KAAK,QAAQ,OAAO,OAAO,UAAU,UAAU,SAAS;EACxD,KAAK,QAAQ,OAAO,YAAY,YAAY,UAAU,CAAC,WAAW,iBAAiB,CAAC;CACrF;AACD;AA7EE,WAAA,CAAA,MAAM,EAAE,OAAO,KAAK,CAAC,CAAA,GAAA,uBAAA,WAAA,aAAA,IAAA;AAYrB,WAAA,CAAA,MAAM,EAAE,OAAO,KAAK,CAAC,CAAA,GAAA,uBAAA,WAAA,oBAAA,IAAA;AAMrB,WAAA,CAAA,MAAM,EAAE,OAAO,KAAK,CAAC,CAAA,GAAA,uBAAA,WAAA,2BAAA,IAAA;AAUrB,WAAA,CAAA,MAAM,EAAE,OAAO,KAAK,CAAC,CAAA,GAAA,uBAAA,WAAA,6BAAA,IAAA;AASrB,WAAA,CAAA,MAAM,EAAE,OAAO,KAAK,CAAC,CAAA,GAAA,uBAAA,WAAA,+BAAA,IAAA;AAiCrB,WAAA,CAAA,MAAM,CAAA,GAAA,uBAAA,WAAA,sBAAA,IAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PullRequest, PullRequestComparisonRefs, PullRequestRefs, PullRequestRepositoryIdentityDescriptor, PullRequestShape, PullRequestSorting, PullRequestStackInfo } from "../models/pullRequest.js";
|
|
1
|
+
import { PullRequest, PullRequestComparisonRefs, PullRequestMergeQueueEntry, PullRequestMergeQueueState, PullRequestRefs, PullRequestRepositoryIdentityDescriptor, PullRequestShape, PullRequestSorting, PullRequestStackInfo } from "../models/pullRequest.js";
|
|
2
2
|
//#region ../git/src/utils/pullRequest.utils.d.ts
|
|
3
3
|
/** How many pull requests a merge action affects — unstacked is always 1; a stacked merge lands either
|
|
4
4
|
* just this layer and everything below it (`position`), or the whole stack (`wholeStack`). The one
|
|
@@ -8,6 +8,77 @@ import { PullRequest, PullRequestComparisonRefs, PullRequestRefs, PullRequestRep
|
|
|
8
8
|
export declare function getStackedMergeCount(stack: Pick<PullRequestStackInfo, 'position' | 'size'> | undefined, options?: {
|
|
9
9
|
wholeStack?: boolean;
|
|
10
10
|
}): number;
|
|
11
|
+
/** Whether an open pull request is waiting in a merge queue. `false` also when the read didn't fetch the queue —
|
|
12
|
+
* check the row's `mergeQueue` field presence before treating that as "not queued". Narrows to the shape's own entry
|
|
13
|
+
* type, since webview shapes carry a serialized one, or to {@link PullRequestMergeQueueEntry} for a shape that
|
|
14
|
+
* doesn't declare one (an `IssueOrPullRequest` that is a pull request). */
|
|
15
|
+
export declare function isPullRequestInMergeQueue<T extends {
|
|
16
|
+
readonly state?: string;
|
|
17
|
+
readonly mergeQueue?: unknown;
|
|
18
|
+
}>(pr: T): pr is T & {
|
|
19
|
+
readonly mergeQueue: 'mergeQueue' extends keyof T ? NonNullable<T['mergeQueue']> : PullRequestMergeQueueEntry;
|
|
20
|
+
};
|
|
21
|
+
/** A pull request's state as shown to users: its provider state, except an open pull request waiting in a merge queue is `queued`. */
|
|
22
|
+
export declare function getPullRequestDisplayState<S extends string | undefined>(pr: {
|
|
23
|
+
readonly state: S;
|
|
24
|
+
readonly mergeQueue?: unknown;
|
|
25
|
+
}): S | 'queued';
|
|
26
|
+
/** A pull request's {@link getPullRequestDisplayState display state} paired with its
|
|
27
|
+
* {@link formatPullRequestMergeQueueStatus merge-queue status}, place in line included, which is set only while it's
|
|
28
|
+
* queued — the pair a pull request chip renders. */
|
|
29
|
+
export declare function getPullRequestDisplayStatus<S extends string | undefined>(pr: {
|
|
30
|
+
readonly state: S;
|
|
31
|
+
readonly mergeQueue?: Parameters<typeof formatPullRequestMergeQueueStatus>[0];
|
|
32
|
+
}): {
|
|
33
|
+
status: S | 'queued';
|
|
34
|
+
queueStatus: string | undefined;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Describes where a queued pull request stands in its merge queue, with its place in line when the provider gave one
|
|
38
|
+
* ("#2 in the merge queue, checks running"). Merging and failing entries read the same with or without a place, since
|
|
39
|
+
* the place no longer says anything there. Takes only the fields it reads, and the estimate as a date or a timestamp
|
|
40
|
+
* (ms), since webview shapes carry a serialized entry.
|
|
41
|
+
*/
|
|
42
|
+
export declare function formatPullRequestMergeQueueStatus(entry: {
|
|
43
|
+
readonly state: PullRequestMergeQueueState;
|
|
44
|
+
readonly estimatedMergeAt?: Date | number;
|
|
45
|
+
readonly position?: number;
|
|
46
|
+
}): string;
|
|
47
|
+
/** When a queued pull request joined its merge queue, as the clause that follows its
|
|
48
|
+
* {@link formatPullRequestMergeQueueStatus status} — "queued 3 hours ago" — so a status that ends in an estimate
|
|
49
|
+
* doesn't run straight into a bare date. */
|
|
50
|
+
export declare function formatPullRequestMergeQueueEnqueuedFromNow(entry: {
|
|
51
|
+
readonly enqueuedAt: Date | number;
|
|
52
|
+
}): string;
|
|
53
|
+
/** What a `PullRequestMergeQueueRemoval`'s reason says about the pull request: its queue run `failed`, someone
|
|
54
|
+
* removed it (`manual`), or a reason this doesn't recognize (`other`), which the removal's raw reason still names. */
|
|
55
|
+
export type PullRequestMergeQueueRemovalKind = 'failed' | 'manual' | 'other';
|
|
56
|
+
/**
|
|
57
|
+
* Classifies a merge-queue removal's provider reason. Only the reasons seen from GitHub are recognized —
|
|
58
|
+
* `failed_checks` (its queue run failed) and `manual` — matched without regard to case; every other reason is
|
|
59
|
+
* `other` rather than guessed at, so a caller that shows one can fall back to the raw reason.
|
|
60
|
+
*/
|
|
61
|
+
export declare function getPullRequestMergeQueueRemovalKind(reason: string): PullRequestMergeQueueRemovalKind;
|
|
62
|
+
/**
|
|
63
|
+
* Whether a pull request's merge-queue removal (`mergeQueueRemoval`) still describes it: it is set,
|
|
64
|
+
* the pull request is open and not queued, and nothing has touched the pull request since — its update time is no
|
|
65
|
+
* later than the removal, which GitHub's removal doesn't move. Narrows `mergeQueueRemoval` to set.
|
|
66
|
+
*
|
|
67
|
+
* The trade-off: any later update clears it, not only a push that may have fixed the failure, so a comment or a
|
|
68
|
+
* label added after a failed queue run also stops it reading as failing. A provider's timeline can't say whether a
|
|
69
|
+
* push followed the removal (GitHub orders commits by commit date, not push time), and a stale "failing" is worse
|
|
70
|
+
* than a missed one. Takes dates or timestamps (ms), since webview shapes carry serialized ones.
|
|
71
|
+
*/
|
|
72
|
+
export declare function isPullRequestMergeQueueRemovalCurrent<T extends {
|
|
73
|
+
readonly state?: string;
|
|
74
|
+
readonly updatedDate: Date | number;
|
|
75
|
+
readonly mergeQueue?: unknown;
|
|
76
|
+
readonly mergeQueueRemoval?: {
|
|
77
|
+
readonly removedAt: Date | number;
|
|
78
|
+
};
|
|
79
|
+
}>(pr: T): pr is T & {
|
|
80
|
+
readonly mergeQueueRemoval: NonNullable<T['mergeQueueRemoval']>;
|
|
81
|
+
};
|
|
11
82
|
/**
|
|
12
83
|
* A comparator for one sort key over normalized pull requests, or `undefined` when the field isn't derivable
|
|
13
84
|
* from a {@link PullRequestShape} — the signal that the key is only honorable on a SINGLE-origin read where the
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { shortenRevision } from "./revision.utils.js";
|
|
2
|
+
import { fromNow } from "../../utils/date.js";
|
|
3
|
+
import "../models/pullRequest.js";
|
|
2
4
|
import { serializeMilestone } from "./issueOrPullRequest.utils.js";
|
|
5
|
+
import * as l10n from "@vscode/l10n";
|
|
3
6
|
//#region ../git/src/utils/pullRequest.utils.ts
|
|
4
7
|
/** How many pull requests a merge action affects — unstacked is always 1; a stacked merge lands either
|
|
5
8
|
* just this layer and everything below it (`position`), or the whole stack (`wholeStack`). The one
|
|
@@ -10,6 +13,89 @@ function getStackedMergeCount(stack, options) {
|
|
|
10
13
|
if (stack == null) return 1;
|
|
11
14
|
return options?.wholeStack ? stack.size : stack.position;
|
|
12
15
|
}
|
|
16
|
+
/** Whether an open pull request is waiting in a merge queue. `false` also when the read didn't fetch the queue —
|
|
17
|
+
* check the row's `mergeQueue` field presence before treating that as "not queued". Narrows to the shape's own entry
|
|
18
|
+
* type, since webview shapes carry a serialized one, or to {@link PullRequestMergeQueueEntry} for a shape that
|
|
19
|
+
* doesn't declare one (an `IssueOrPullRequest` that is a pull request). */
|
|
20
|
+
function isPullRequestInMergeQueue(pr) {
|
|
21
|
+
return pr.state === "opened" && pr.mergeQueue != null;
|
|
22
|
+
}
|
|
23
|
+
/** A pull request's state as shown to users: its provider state, except an open pull request waiting in a merge queue is `queued`. */
|
|
24
|
+
function getPullRequestDisplayState(pr) {
|
|
25
|
+
return isPullRequestInMergeQueue(pr) ? "queued" : pr.state;
|
|
26
|
+
}
|
|
27
|
+
/** A pull request's {@link getPullRequestDisplayState display state} paired with its
|
|
28
|
+
* {@link formatPullRequestMergeQueueStatus merge-queue status}, place in line included, which is set only while it's
|
|
29
|
+
* queued — the pair a pull request chip renders. */
|
|
30
|
+
function getPullRequestDisplayStatus(pr) {
|
|
31
|
+
return isPullRequestInMergeQueue(pr) ? {
|
|
32
|
+
status: "queued",
|
|
33
|
+
queueStatus: formatPullRequestMergeQueueStatus(pr.mergeQueue)
|
|
34
|
+
} : {
|
|
35
|
+
status: pr.state,
|
|
36
|
+
queueStatus: void 0
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Describes where a queued pull request stands in its merge queue, with its place in line when the provider gave one
|
|
41
|
+
* ("#2 in the merge queue, checks running"). Merging and failing entries read the same with or without a place, since
|
|
42
|
+
* the place no longer says anything there. Takes only the fields it reads, and the estimate as a date or a timestamp
|
|
43
|
+
* (ms), since webview shapes carry a serialized entry.
|
|
44
|
+
*/
|
|
45
|
+
function formatPullRequestMergeQueueStatus(entry) {
|
|
46
|
+
const position = entry.position;
|
|
47
|
+
let status;
|
|
48
|
+
switch (entry.state) {
|
|
49
|
+
case "AwaitingChecks":
|
|
50
|
+
status = position != null ? l10n.t("#{position} in the merge queue, checks running", { position }) : l10n.t("Queued to merge, checks running");
|
|
51
|
+
break;
|
|
52
|
+
case "Mergeable":
|
|
53
|
+
status = position != null ? l10n.t("#{position} in the merge queue, next up", { position }) : l10n.t("Queued to merge, next up");
|
|
54
|
+
break;
|
|
55
|
+
case "Locked": return l10n.t("Merging");
|
|
56
|
+
case "Unmergeable": return l10n.t("Failing in the merge queue");
|
|
57
|
+
default: status = position != null ? l10n.t("#{position} in the merge queue", { position }) : l10n.t("Queued to merge");
|
|
58
|
+
}
|
|
59
|
+
if (entry.estimatedMergeAt == null) return status;
|
|
60
|
+
const estimatedMergeAt = new Date(entry.estimatedMergeAt).getTime();
|
|
61
|
+
if (Number.isNaN(estimatedMergeAt) || estimatedMergeAt <= Date.now()) return status;
|
|
62
|
+
return l10n.t("{0}, estimated to merge {1}", status, fromNow(estimatedMergeAt));
|
|
63
|
+
}
|
|
64
|
+
/** When a queued pull request joined its merge queue, as the clause that follows its
|
|
65
|
+
* {@link formatPullRequestMergeQueueStatus status} — "queued 3 hours ago" — so a status that ends in an estimate
|
|
66
|
+
* doesn't run straight into a bare date. */
|
|
67
|
+
function formatPullRequestMergeQueueEnqueuedFromNow(entry) {
|
|
68
|
+
return l10n.t("queued {0}", fromNow(entry.enqueuedAt));
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Classifies a merge-queue removal's provider reason. Only the reasons seen from GitHub are recognized —
|
|
72
|
+
* `failed_checks` (its queue run failed) and `manual` — matched without regard to case; every other reason is
|
|
73
|
+
* `other` rather than guessed at, so a caller that shows one can fall back to the raw reason.
|
|
74
|
+
*/
|
|
75
|
+
function getPullRequestMergeQueueRemovalKind(reason) {
|
|
76
|
+
switch (reason.toLowerCase()) {
|
|
77
|
+
case "failed_checks": return "failed";
|
|
78
|
+
case "manual": return "manual";
|
|
79
|
+
default: return "other";
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Whether a pull request's merge-queue removal (`mergeQueueRemoval`) still describes it: it is set,
|
|
84
|
+
* the pull request is open and not queued, and nothing has touched the pull request since — its update time is no
|
|
85
|
+
* later than the removal, which GitHub's removal doesn't move. Narrows `mergeQueueRemoval` to set.
|
|
86
|
+
*
|
|
87
|
+
* The trade-off: any later update clears it, not only a push that may have fixed the failure, so a comment or a
|
|
88
|
+
* label added after a failed queue run also stops it reading as failing. A provider's timeline can't say whether a
|
|
89
|
+
* push followed the removal (GitHub orders commits by commit date, not push time), and a stale "failing" is worse
|
|
90
|
+
* than a missed one. Takes dates or timestamps (ms), since webview shapes carry serialized ones.
|
|
91
|
+
*/
|
|
92
|
+
function isPullRequestMergeQueueRemovalCurrent(pr) {
|
|
93
|
+
if (pr.mergeQueueRemoval == null || pr.state !== "opened" || pr.mergeQueue != null) return false;
|
|
94
|
+
const removedAt = new Date(pr.mergeQueueRemoval.removedAt).getTime();
|
|
95
|
+
const updatedAt = new Date(pr.updatedDate).getTime();
|
|
96
|
+
if (Number.isNaN(removedAt) || Number.isNaN(updatedAt)) return false;
|
|
97
|
+
return removedAt >= updatedAt;
|
|
98
|
+
}
|
|
13
99
|
/**
|
|
14
100
|
* How each sort field is read off a {@link PullRequestShape}, for the filtered PR search, which MERGES its
|
|
15
101
|
* relationship × state facets in the facade and so has to order the union itself instead of trusting the
|
|
@@ -199,10 +285,22 @@ function serializePullRequest(value) {
|
|
|
199
285
|
size: value.stack.size,
|
|
200
286
|
position: value.stack.position,
|
|
201
287
|
baseRef: value.stack.baseRef
|
|
288
|
+
} : void 0,
|
|
289
|
+
mergeQueue: value.mergeQueue ? {
|
|
290
|
+
state: value.mergeQueue.state,
|
|
291
|
+
enqueuedAt: value.mergeQueue.enqueuedAt,
|
|
292
|
+
estimatedMergeAt: value.mergeQueue.estimatedMergeAt,
|
|
293
|
+
url: value.mergeQueue.url,
|
|
294
|
+
position: value.mergeQueue.position
|
|
295
|
+
} : void 0,
|
|
296
|
+
mergeQueueRequired: value.mergeQueueRequired,
|
|
297
|
+
mergeQueueRemoval: value.mergeQueueRemoval ? {
|
|
298
|
+
reason: value.mergeQueueRemoval.reason,
|
|
299
|
+
removedAt: value.mergeQueueRemoval.removedAt
|
|
202
300
|
} : void 0
|
|
203
301
|
};
|
|
204
302
|
}
|
|
205
303
|
//#endregion
|
|
206
|
-
export { getComparisonRefsForPullRequest, getPullRequestComparator, getPullRequestIdentityFromMaybeUrl, getPullRequestNumberFromUrl, getRepositoryIdentityForPullRequest, getStackedMergeCount, isMaybeNonSpecificPullRequestSearchUrl, serializePullRequest };
|
|
304
|
+
export { formatPullRequestMergeQueueEnqueuedFromNow, formatPullRequestMergeQueueStatus, getComparisonRefsForPullRequest, getPullRequestComparator, getPullRequestDisplayState, getPullRequestDisplayStatus, getPullRequestIdentityFromMaybeUrl, getPullRequestMergeQueueRemovalKind, getPullRequestNumberFromUrl, getRepositoryIdentityForPullRequest, getStackedMergeCount, isMaybeNonSpecificPullRequestSearchUrl, isPullRequestInMergeQueue, isPullRequestMergeQueueRemovalCurrent, serializePullRequest };
|
|
207
305
|
|
|
208
306
|
//# sourceMappingURL=pullRequest.utils.js.map
|