@gitkraken/core-gitlens 0.40.0 → 0.43.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 +25 -1
- package/dist/git/models/issue.d.ts +2 -0
- package/dist/git/models/issue.js.map +1 -1
- package/dist/git/models/issueOrPullRequest.d.ts +4 -0
- package/dist/git/models/pullRequest.d.ts +57 -1
- package/dist/git/models/pullRequest.js +5 -1
- package/dist/git/models/pullRequest.js.map +1 -1
- package/dist/git/models/pullRequestActivity.d.ts +55 -0
- package/dist/git/models/pullRequestActivity.js +0 -0
- package/dist/git/utils/pullRequest.utils.js +3 -1
- package/dist/git/utils/pullRequest.utils.js.map +1 -1
- package/dist/git/watching/worktreeSummary.d.ts +1 -0
- package/dist/git/watching/worktreeSummary.js +34 -2
- package/dist/git/watching/worktreeSummary.js.map +1 -1
- package/dist/plus/git-github/api/aliasedQuery.d.ts +19 -0
- package/dist/plus/git-github/api/aliasedQuery.js +21 -0
- package/dist/plus/git-github/api/aliasedQuery.js.map +1 -0
- package/dist/plus/git-github/api/cancellation.d.ts +4 -0
- package/dist/plus/git-github/api/cancellation.js +9 -0
- package/dist/plus/git-github/api/cancellation.js.map +1 -0
- package/dist/plus/git-github/api/checkRunLogs.d.ts +31 -0
- package/dist/plus/git-github/api/checkRunLogs.js +252 -0
- package/dist/plus/git-github/api/checkRunLogs.js.map +1 -0
- package/dist/plus/git-github/api/checkRuns.d.ts +26 -0
- package/dist/plus/git-github/api/checkRuns.js +191 -0
- package/dist/plus/git-github/api/checkRuns.js.map +1 -0
- package/dist/plus/git-github/api/github.d.ts +23 -6
- package/dist/plus/git-github/api/github.js +174 -39
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/api/issueWrites.d.ts +3 -2
- package/dist/plus/git-github/api/issueWrites.js +10 -5
- package/dist/plus/git-github/api/issueWrites.js.map +1 -1
- package/dist/plus/git-github/api/pullRequestActivity.d.ts +19 -0
- package/dist/plus/git-github/api/pullRequestActivity.js +355 -0
- package/dist/plus/git-github/api/pullRequestActivity.js.map +1 -0
- package/dist/plus/git-github/models.d.ts +100 -4
- package/dist/plus/git-github/models.js +142 -6
- package/dist/plus/git-github/models.js.map +1 -1
- package/dist/plus/integrations/fieldPresence.d.ts +10 -5
- package/dist/plus/integrations/fieldPresence.js +46 -25
- package/dist/plus/integrations/fieldPresence.js.map +1 -1
- package/dist/plus/integrations/index.d.ts +5 -2
- package/dist/plus/integrations/index.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +26 -1
- package/dist/plus/integrations/integrationService.js +22 -0
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +86 -1
- package/dist/plus/integrations/models/gitHostIntegration.d.ts +31 -1
- package/dist/plus/integrations/models/gitHostIntegration.js +68 -0
- package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
- package/dist/plus/integrations/models/integration.d.ts +21 -2
- package/dist/plus/integrations/models/integration.js +20 -1
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/providers/azure/azure.js +20 -14
- package/dist/plus/integrations/providers/azure/azure.js.map +1 -1
- package/dist/plus/integrations/providers/azure/models.js +7 -3
- package/dist/plus/integrations/providers/azure/models.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket/bitbucket.js +18 -13
- package/dist/plus/integrations/providers/bitbucket/bitbucket.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket/models.js +5 -2
- package/dist/plus/integrations/providers/bitbucket/models.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket-server/models.js +3 -1
- package/dist/plus/integrations/providers/bitbucket-server/models.js.map +1 -1
- package/dist/plus/integrations/providers/github.d.ts +15 -6
- package/dist/plus/integrations/providers/github.js +65 -5
- package/dist/plus/integrations/providers/github.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/gitlab.js +12 -6
- package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/models.js +5 -2
- package/dist/plus/integrations/providers/gitlab/models.js.map +1 -1
- package/dist/plus/integrations/providers/jiraIssueByKey.js +3 -1
- package/dist/plus/integrations/providers/jiraIssueByKey.js.map +1 -1
- package/dist/plus/integrations/providers/models.js +9 -4
- package/dist/plus/integrations/providers/models.js.map +1 -1
- package/dist/plus/integrations/providers/providerApiClient.js +10 -7
- package/dist/plus/integrations/providers/providerApiClient.js.map +1 -1
- package/dist/plus/integrations/providers/providersApi.js +3 -1
- package/dist/plus/integrations/providers/providersApi.js.map +1 -1
- package/dist/plus/integrations/reads/etag.js +20 -5
- package/dist/plus/integrations/reads/etag.js.map +1 -1
- package/dist/plus/integrations/reads/pullRequestActivity.d.ts +36 -0
- package/dist/plus/integrations/reads/pullRequestActivity.js +103 -0
- package/dist/plus/integrations/reads/pullRequestActivity.js.map +1 -0
- package/dist/plus/integrations/reads/pullRequestBatch.d.ts +4 -1
- package/dist/plus/integrations/reads/pullRequestBatch.js +5 -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 +2 -1
- package/dist/plus/integrations/reads/pullRequestBranches.js.map +1 -1
- package/dist/plus/integrations/reads/pullRequestCheckLogs.d.ts +27 -0
- package/dist/plus/integrations/reads/pullRequestCheckLogs.js +92 -0
- package/dist/plus/integrations/reads/pullRequestCheckLogs.js.map +1 -0
- package/docs/integrations.md +111 -14
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pullRequest.utils.js","names":[],"sources":["../../../../git/src/utils/pullRequest.utils.ts"],"sourcesContent":["import * as l10n from '@vscode/l10n';\nimport { fromNow } from '@gitlens/utils/date.js';\nimport type {\n\tPullRequest,\n\tPullRequestComparisonRefs,\n\tPullRequestMergeQueueEntry,\n\tPullRequestRefs,\n\tPullRequestRepositoryIdentityDescriptor,\n\tPullRequestShape,\n\tPullRequestSortField,\n\tPullRequestSorting,\n\tPullRequestStackInfo,\n} from '../models/pullRequest.js';\nimport { PullRequestMergeQueueState } from '../models/pullRequest.js';\nimport { serializeMilestone } from './issueOrPullRequest.utils.js';\nimport { shortenRevision } from './revision.utils.js';\n\n/** How many pull requests a merge action affects — unstacked is always 1; a stacked merge lands either\n * just this layer and everything below it (`position`), or the whole stack (`wholeStack`). The one\n * source every merge-confirmation and merge-action label counts from, so they can't drift apart.\n * Takes only the two fields it needs (not the full {@link PullRequestStackInfo}) since callers on the\n * webview side carry narrower serialized stack shapes. */\nexport function getStackedMergeCount(\n\tstack: Pick<PullRequestStackInfo, 'position' | 'size'> | undefined,\n\toptions?: { wholeStack?: boolean },\n): number {\n\tif (stack == null) return 1;\n\treturn options?.wholeStack ? stack.size : stack.position;\n}\n\n/** Whether an open pull request is waiting in a merge queue. `false` also when the read didn't fetch the queue —\n * check the row's `mergeQueue` field presence before treating that as \"not queued\". Narrows to the shape's own entry\n * type, since webview shapes carry a serialized one, or to {@link PullRequestMergeQueueEntry} for a shape that\n * doesn't declare one (an `IssueOrPullRequest` that is a pull request). */\nexport function isPullRequestInMergeQueue<T extends { readonly state?: string; readonly mergeQueue?: unknown }>(\n\tpr: T,\n): pr is T & {\n\treadonly mergeQueue: 'mergeQueue' extends keyof T ? NonNullable<T['mergeQueue']> : PullRequestMergeQueueEntry;\n} {\n\treturn pr.state === 'opened' && pr.mergeQueue != null;\n}\n\n/** A pull request's state as shown to users: its provider state, except an open pull request waiting in a merge queue is `queued`. */\nexport function getPullRequestDisplayState<S extends string | undefined>(pr: {\n\treadonly state: S;\n\treadonly mergeQueue?: unknown;\n}): S | 'queued' {\n\treturn isPullRequestInMergeQueue(pr) ? 'queued' : pr.state;\n}\n\n/** A pull request's {@link getPullRequestDisplayState display state} paired with its\n * {@link formatPullRequestMergeQueueStatus merge-queue status}, place in line included, which is set only while it's\n * queued — the pair a pull request chip renders. */\nexport function getPullRequestDisplayStatus<S extends string | undefined>(pr: {\n\treadonly state: S;\n\treadonly mergeQueue?: Parameters<typeof formatPullRequestMergeQueueStatus>[0];\n}): { status: S | 'queued'; queueStatus: string | undefined } {\n\treturn isPullRequestInMergeQueue(pr)\n\t\t? { status: 'queued', queueStatus: formatPullRequestMergeQueueStatus(pr.mergeQueue) }\n\t\t: { status: pr.state, queueStatus: undefined };\n}\n\n/**\n * Describes where a queued pull request stands in its merge queue, with its place in line when the provider gave one\n * (\"#2 in the merge queue, checks running\"). Merging and failing entries read the same with or without a place, since\n * the place no longer says anything there. Takes only the fields it reads, and the estimate as a date or a timestamp\n * (ms), since webview shapes carry a serialized entry.\n */\nexport function formatPullRequestMergeQueueStatus(entry: {\n\treadonly state: PullRequestMergeQueueState;\n\treadonly estimatedMergeAt?: Date | number;\n\treadonly position?: number;\n}): string {\n\tconst position = entry.position;\n\n\tlet status: string;\n\tswitch (entry.state) {\n\t\tcase PullRequestMergeQueueState.AwaitingChecks:\n\t\t\tstatus =\n\t\t\t\tposition != null\n\t\t\t\t\t? l10n.t('#{position} in the merge queue, checks running', { position: position })\n\t\t\t\t\t: l10n.t('Queued to merge, checks running');\n\t\t\tbreak;\n\t\tcase PullRequestMergeQueueState.Mergeable:\n\t\t\tstatus =\n\t\t\t\tposition != null\n\t\t\t\t\t? l10n.t('#{position} in the merge queue, next up', { position: position })\n\t\t\t\t\t: l10n.t('Queued to merge, next up');\n\t\t\tbreak;\n\t\tcase PullRequestMergeQueueState.Locked:\n\t\t\t// The merge is already in flight, so an estimate adds nothing\n\t\t\treturn l10n.t('Merging');\n\t\tcase PullRequestMergeQueueState.Unmergeable:\n\t\t\treturn l10n.t('Failing in the merge queue');\n\t\tdefault:\n\t\t\tstatus =\n\t\t\t\tposition != null\n\t\t\t\t\t? l10n.t('#{position} in the merge queue', { position: position })\n\t\t\t\t\t: l10n.t('Queued to merge');\n\t\t\tbreak;\n\t}\n\n\tif (entry.estimatedMergeAt == null) return status;\n\n\t// An estimate already past is wrong, not late news: \"estimated to merge 2 minutes ago\" would only mislead\n\tconst estimatedMergeAt = new Date(entry.estimatedMergeAt).getTime();\n\tif (Number.isNaN(estimatedMergeAt) || estimatedMergeAt <= Date.now()) return status;\n\n\treturn l10n.t('{0}, estimated to merge {1}', status, fromNow(estimatedMergeAt));\n}\n\n/** When a queued pull request joined its merge queue, as the clause that follows its\n * {@link formatPullRequestMergeQueueStatus status} — \"queued 3 hours ago\" — so a status that ends in an estimate\n * doesn't run straight into a bare date. */\nexport function formatPullRequestMergeQueueEnqueuedFromNow(entry: { readonly enqueuedAt: Date | number }): string {\n\treturn l10n.t('queued {0}', fromNow(entry.enqueuedAt));\n}\n\n/** What a `PullRequestMergeQueueRemoval`'s reason says about the pull request: its queue run `failed`, someone\n * removed it (`manual`), or a reason this doesn't recognize (`other`), which the removal's raw reason still names. */\nexport type PullRequestMergeQueueRemovalKind = 'failed' | 'manual' | 'other';\n\n/**\n * Classifies a merge-queue removal's provider reason. Only the reasons seen from GitHub are recognized —\n * `failed_checks` (its queue run failed) and `manual` — matched without regard to case; every other reason is\n * `other` rather than guessed at, so a caller that shows one can fall back to the raw reason.\n */\nexport function getPullRequestMergeQueueRemovalKind(reason: string): PullRequestMergeQueueRemovalKind {\n\tswitch (reason.toLowerCase()) {\n\t\tcase 'failed_checks':\n\t\t\treturn 'failed';\n\t\tcase 'manual':\n\t\t\treturn 'manual';\n\t\tdefault:\n\t\t\treturn 'other';\n\t}\n}\n\n/**\n * Whether a pull request's merge-queue removal (`mergeQueueRemoval`) still describes it: it is set,\n * the pull request is open and not queued, and nothing has touched the pull request since — its update time is no\n * later than the removal, which GitHub's removal doesn't move. Narrows `mergeQueueRemoval` to set.\n *\n * The trade-off: any later update clears it, not only a push that may have fixed the failure, so a comment or a\n * label added after a failed queue run also stops it reading as failing. A provider's timeline can't say whether a\n * push followed the removal (GitHub orders commits by commit date, not push time), and a stale \"failing\" is worse\n * than a missed one. Takes dates or timestamps (ms), since webview shapes carry serialized ones.\n */\nexport function isPullRequestMergeQueueRemovalCurrent<\n\tT extends {\n\t\treadonly state?: string;\n\t\treadonly updatedDate: Date | number;\n\t\treadonly mergeQueue?: unknown;\n\t\treadonly mergeQueueRemoval?: { readonly removedAt: Date | number };\n\t},\n>(pr: T): pr is T & { readonly mergeQueueRemoval: NonNullable<T['mergeQueueRemoval']> } {\n\tif (pr.mergeQueueRemoval == null || pr.state !== 'opened' || pr.mergeQueue != null) return false;\n\n\tconst removedAt = new Date(pr.mergeQueueRemoval.removedAt).getTime();\n\tconst updatedAt = new Date(pr.updatedDate).getTime();\n\tif (Number.isNaN(removedAt) || Number.isNaN(updatedAt)) return false;\n\n\treturn removedAt >= updatedAt;\n}\n\n/**\n * How each sort field is read off a {@link PullRequestShape}, for the filtered PR search, which MERGES its\n * relationship × state facets in the facade and so has to order the union itself instead of trusting the\n * per-facet server order. Only the fields the shape carries appear — the same rule as `getIssueComparator`, and\n * the reason {@link PullRequestSortField} is just these two.\n */\nconst pullRequestSortValues: Partial<\n\tRecord<PullRequestSortField, (pr: PullRequestShape) => number | Date | string | undefined>\n> = {\n\tcreated: pr => pr.createdDate,\n\tupdated: pr => pr.updatedDate,\n};\n\n/**\n * A comparator for one sort key over normalized pull requests, or `undefined` when the field isn't derivable\n * from a {@link PullRequestShape} — the signal that the key is only honorable on a SINGLE-origin read where the\n * provider already ordered the page. Missing values sort LAST in both directions (partitioned before any\n * arithmetic so two missing values compare equal, exactly as `getIssueComparator` does).\n *\n * Note it orders whatever it is handed. Sorting a page already capped at the result ceiling does not make it the\n * top N.\n */\nexport function getPullRequestComparator(\n\tsort: PullRequestSorting,\n): ((a: PullRequestShape, b: PullRequestShape) => number) | undefined {\n\tconst [field, direction] = sort.split(':') as [PullRequestSortField, 'asc' | 'desc'];\n\tconst getValue = pullRequestSortValues[field];\n\tif (getValue == null) return undefined;\n\n\treturn (a, b) => {\n\t\tconst left = toComparable(getValue(a));\n\t\tconst right = toComparable(getValue(b));\n\t\tif (left == null || right == null) {\n\t\t\tif (left == null && right == null) return 0;\n\n\t\t\treturn left == null ? 1 : -1;\n\t\t}\n\n\t\tconst ordered = left < right ? -1 : left > right ? 1 : 0;\n\t\treturn direction === 'asc' ? ordered : -ordered;\n\t};\n}\n\nfunction toComparable(value: number | Date | string | undefined): number | string | undefined {\n\treturn value instanceof Date ? value.getTime() : value;\n}\n\nexport interface PullRequestUrlIdentity<TProvider extends string = string> {\n\tprovider?: TProvider;\n\n\townerAndRepo?: string;\n\tprNumber: string;\n}\n\nexport function getComparisonRefsForPullRequest(repoPath: string, prRefs: PullRequestRefs): PullRequestComparisonRefs {\n\tconst refs: PullRequestComparisonRefs = {\n\t\trepoPath: repoPath,\n\t\tbase: { ref: prRefs.base.sha, label: `${prRefs.base.branch} (${shortenRevision(prRefs.base.sha)})` },\n\t\thead: { ref: prRefs.head.sha, label: prRefs.head.branch },\n\t};\n\treturn refs;\n}\n\nexport function getPullRequestIdentityFromMaybeUrl(search: string): PullRequestUrlIdentity | undefined {\n\tlet prNumber: string | undefined = undefined;\n\n\tlet match = search.match(/(?:\\/)(\\d+)/); // any number starting with \"/\"\n\tif (match != null) {\n\t\tprNumber = match[1];\n\t}\n\n\tif (prNumber == null) {\n\t\tmatch = search.match(/^#?(\\d+)$/); // just a number or with a leading \"#\"\n\t\tif (match != null) {\n\t\t\tprNumber = match[1];\n\t\t}\n\t}\n\n\treturn prNumber == null ? undefined : { ownerAndRepo: undefined, prNumber: prNumber, provider: undefined };\n}\n\n/** A pull request's display number from its url, or `undefined` for a url naming no pull request. Anchors\n * on the provider's pull request path segment (GitHub `pull`, Bitbucket `pull-requests`, GitLab\n * `merge_requests`, Azure `pullrequest`) so a digit-leading owner (`github.com/1Password/x/pull/123`)\n * can't win. */\nexport function getPullRequestNumberFromUrl(url: string): string | undefined {\n\t// No loose fallback: `getPullRequestIdentityFromMaybeUrl` scans for any `/<digits>`, which reads a bare\n\t// repository url like `github.com/1Password/sdk` as pull request #1. Callers that hold a real pull\n\t// request fall back to its id instead, and the one that asks whether a pasted url names a pull request\n\t// needs \"no\" for an answer.\n\treturn url.match(/(?:pull|pull-requests|merge_requests|pullrequest)\\/(\\d+)(?:\\b|\\/|$)/)?.[1];\n}\n\nexport function getRepositoryIdentityForPullRequest(\n\tpr: PullRequest,\n\theadRepo: boolean = true,\n): PullRequestRepositoryIdentityDescriptor {\n\tif (headRepo) {\n\t\treturn {\n\t\t\tremote: {\n\t\t\t\turl: pr.refs?.head?.url,\n\t\t\t\tdomain: pr.provider.domain,\n\t\t\t},\n\t\t\tname: `${pr.refs?.head?.owner ?? pr.repository.owner}/${pr.refs?.head?.repo ?? pr.repository.repo}`,\n\t\t\tprovider: {\n\t\t\t\tid: pr.provider.id,\n\t\t\t\tdomain: pr.provider.domain,\n\t\t\t\trepoDomain: pr.refs?.head?.owner ?? pr.repository.owner,\n\t\t\t\trepoName: pr.refs?.head?.repo ?? pr.repository.repo,\n\t\t\t},\n\t\t};\n\t}\n\n\treturn {\n\t\tremote: {\n\t\t\turl: pr.refs?.base?.url ?? pr.url,\n\t\t\tdomain: pr.provider.domain,\n\t\t},\n\t\tname: `${pr.refs?.base?.owner ?? pr.repository.owner}/${pr.refs?.base?.repo ?? pr.repository.repo}`,\n\t\tprovider: {\n\t\t\tid: pr.provider.id,\n\t\t\tdomain: pr.provider.domain,\n\t\t\trepoDomain: pr.refs?.base?.owner ?? pr.repository.owner,\n\t\t\trepoName: pr.refs?.base?.repo ?? pr.repository.repo,\n\t\t\trepoOwnerDomain: pr.refs?.base?.owner ?? pr.repository.owner,\n\t\t},\n\t};\n}\n\nexport function isMaybeNonSpecificPullRequestSearchUrl(search: string): boolean {\n\treturn getPullRequestIdentityFromMaybeUrl(search) != null;\n}\n\n/**\n * Deliberately leaves `projection` out: this copy drops `filesChanged`, `repository` and the class-only check rollup,\n * commit count and `viewerCanUpdate`, so a tag would have field presence report as fetched what the copy no longer has.\n */\nexport function serializePullRequest(value: PullRequest): PullRequestShape {\n\tconst serialized: PullRequestShape = {\n\t\ttype: value.type,\n\t\tprovider: {\n\t\t\tid: value.provider.id,\n\t\t\tname: value.provider.name,\n\t\t\tdomain: value.provider.domain,\n\t\t\ticon: value.provider.icon,\n\t\t},\n\t\tid: value.id,\n\t\tnodeId: value.nodeId,\n\t\tnumber: value.number,\n\t\ttitle: value.title,\n\t\tbody: value.body,\n\t\turl: value.url,\n\t\tcreatedDate: value.createdDate,\n\t\tupdatedDate: value.updatedDate,\n\t\tclosedDate: value.closedDate,\n\t\tclosed: value.closed,\n\t\tauthor: {\n\t\t\tid: value.author.id,\n\t\t\tname: value.author.name,\n\t\t\tusername: value.author.username,\n\t\t\tavatarUrl: value.author.avatarUrl,\n\t\t\turl: value.author.url,\n\t\t},\n\t\tstate: value.state,\n\t\tmergedDate: value.mergedDate,\n\t\tmergeableState: value.mergeableState,\n\t\trefs: value.refs\n\t\t\t? {\n\t\t\t\t\thead: {\n\t\t\t\t\t\texists: value.refs.head.exists,\n\t\t\t\t\t\towner: value.refs.head.owner,\n\t\t\t\t\t\trepo: value.refs.head.repo,\n\t\t\t\t\t\tsha: value.refs.head.sha,\n\t\t\t\t\t\tbranch: value.refs.head.branch,\n\t\t\t\t\t\turl: value.refs.head.url,\n\t\t\t\t\t\tcloneHttps: value.refs.head.cloneHttps,\n\t\t\t\t\t\tcloneSsh: value.refs.head.cloneSsh,\n\t\t\t\t\t\tisFork: value.refs.head.isFork,\n\t\t\t\t\t},\n\t\t\t\t\tbase: {\n\t\t\t\t\t\texists: value.refs.base.exists,\n\t\t\t\t\t\towner: value.refs.base.owner,\n\t\t\t\t\t\trepo: value.refs.base.repo,\n\t\t\t\t\t\tsha: value.refs.base.sha,\n\t\t\t\t\t\tbranch: value.refs.base.branch,\n\t\t\t\t\t\turl: value.refs.base.url,\n\t\t\t\t\t\tcloneHttps: value.refs.base.cloneHttps,\n\t\t\t\t\t\tcloneSsh: value.refs.base.cloneSsh,\n\t\t\t\t\t\tisFork: value.refs.base.isFork,\n\t\t\t\t\t},\n\t\t\t\t\tisCrossRepository: value.refs.isCrossRepository,\n\t\t\t\t}\n\t\t\t: undefined,\n\t\tisDraft: value.isDraft,\n\t\tadditions: value.additions,\n\t\tdeletions: value.deletions,\n\t\tcommentsCount: value.commentsCount,\n\t\tthumbsUpCount: value.thumbsUpCount,\n\t\treviewDecision: value.reviewDecision,\n\t\treviewRequests: value.reviewRequests,\n\t\tlatestReviews: value.latestReviews,\n\t\tassignees: value.assignees,\n\t\tauthoredByMe: value.authoredByMe,\n\t\tviewer: value.viewer != null ? { id: value.viewer.id, username: value.viewer.username } : undefined,\n\t\tviewerUnresolved: value.viewerUnresolved,\n\t\tmilestone: serializeMilestone(value.milestone),\n\t\tproject: value.project\n\t\t\t? {\n\t\t\t\t\tid: value.project.id,\n\t\t\t\t\tname: value.project.name,\n\t\t\t\t\tresourceId: value.project.resourceId,\n\t\t\t\t\tresourceName: value.project.resourceName,\n\t\t\t\t}\n\t\t\t: undefined,\n\t\tstack: value.stack\n\t\t\t? {\n\t\t\t\t\tid: value.stack.id,\n\t\t\t\t\tnumber: value.stack.number,\n\t\t\t\t\tsize: value.stack.size,\n\t\t\t\t\tposition: value.stack.position,\n\t\t\t\t\tbaseRef: value.stack.baseRef,\n\t\t\t\t}\n\t\t\t: undefined,\n\t\tmergeQueue: value.mergeQueue\n\t\t\t? {\n\t\t\t\t\tstate: value.mergeQueue.state,\n\t\t\t\t\tenqueuedAt: value.mergeQueue.enqueuedAt,\n\t\t\t\t\testimatedMergeAt: value.mergeQueue.estimatedMergeAt,\n\t\t\t\t\turl: value.mergeQueue.url,\n\t\t\t\t\tposition: value.mergeQueue.position,\n\t\t\t\t}\n\t\t\t: undefined,\n\t\tmergeQueueRequired: value.mergeQueueRequired,\n\t\tmergeQueueRemoval: value.mergeQueueRemoval\n\t\t\t? { reason: value.mergeQueueRemoval.reason, removedAt: value.mergeQueueRemoval.removedAt }\n\t\t\t: undefined,\n\t};\n\treturn serialized;\n}\n"],"mappings":";;;;;;;;;;;AAsBA,SAAgB,qBACf,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B,QAAQ,MAAM,KAAK,KAAK;IACxB,KAAK,MAAM,KAAK,KAAK;IACrB,YAAY,MAAM,KAAK,KAAK;IAC5B,UAAU,MAAM,KAAK,KAAK;IAC1B,QAAQ,MAAM,KAAK,KAAK;GACzB;GACA,mBAAmB,MAAM,KAAK;EAC/B,IACC,KAAA;EACH,SAAS,MAAM;EACf,WAAW,MAAM;EACjB,WAAW,MAAM;EACjB,eAAe,MAAM;EACrB,eAAe,MAAM;EACrB,gBAAgB,MAAM;EACtB,gBAAgB,MAAM;EACtB,eAAe,MAAM;EACrB,WAAW,MAAM;EACjB,cAAc,MAAM;EACpB,QAAQ,MAAM,UAAU,OAAO;GAAE,IAAI,MAAM,OAAO;GAAI,UAAU,MAAM,OAAO;EAAS,IAAI,KAAA;EAC1F,kBAAkB,MAAM;EACxB,WAAW,mBAAmB,MAAM,SAAS;EAC7C,SAAS,MAAM,UACZ;GACA,IAAI,MAAM,QAAQ;GAClB,MAAM,MAAM,QAAQ;GACpB,YAAY,MAAM,QAAQ;GAC1B,cAAc,MAAM,QAAQ;EAC7B,IACC,KAAA;EACH,OAAO,MAAM,QACV;GACA,IAAI,MAAM,MAAM;GAChB,QAAQ,MAAM,MAAM;GACpB,MAAM,MAAM,MAAM;GAClB,UAAU,MAAM,MAAM;GACtB,SAAS,MAAM,MAAM;EACtB,IACC,KAAA;EACH,YAAY,MAAM,aACf;GACA,OAAO,MAAM,WAAW;GACxB,YAAY,MAAM,WAAW;GAC7B,kBAAkB,MAAM,WAAW;GACnC,KAAK,MAAM,WAAW;GACtB,UAAU,MAAM,WAAW;EAC5B,IACC,KAAA;EACH,oBAAoB,MAAM;EAC1B,mBAAmB,MAAM,oBACtB;GAAE,QAAQ,MAAM,kBAAkB;GAAQ,WAAW,MAAM,kBAAkB;EAAU,IACvF,KAAA;CAEY;AACjB"}
|
|
1
|
+
{"version":3,"file":"pullRequest.utils.js","names":[],"sources":["../../../../git/src/utils/pullRequest.utils.ts"],"sourcesContent":["import * as l10n from '@vscode/l10n';\nimport { fromNow } from '@gitlens/utils/date.js';\nimport type {\n\tPullRequest,\n\tPullRequestComparisonRefs,\n\tPullRequestMergeQueueEntry,\n\tPullRequestRefs,\n\tPullRequestRepositoryIdentityDescriptor,\n\tPullRequestShape,\n\tPullRequestSortField,\n\tPullRequestSorting,\n\tPullRequestStackInfo,\n} from '../models/pullRequest.js';\nimport { PullRequestMergeQueueState } from '../models/pullRequest.js';\nimport { serializeMilestone } from './issueOrPullRequest.utils.js';\nimport { shortenRevision } from './revision.utils.js';\n\n/** How many pull requests a merge action affects — unstacked is always 1; a stacked merge lands either\n * just this layer and everything below it (`position`), or the whole stack (`wholeStack`). The one\n * source every merge-confirmation and merge-action label counts from, so they can't drift apart.\n * Takes only the two fields it needs (not the full {@link PullRequestStackInfo}) since callers on the\n * webview side carry narrower serialized stack shapes. */\nexport function getStackedMergeCount(\n\tstack: Pick<PullRequestStackInfo, 'position' | 'size'> | undefined,\n\toptions?: { wholeStack?: boolean },\n): number {\n\tif (stack == null) return 1;\n\treturn options?.wholeStack ? stack.size : stack.position;\n}\n\n/** Whether an open pull request is waiting in a merge queue. `false` also when the read didn't fetch the queue —\n * check the row's `mergeQueue` field presence before treating that as \"not queued\". Narrows to the shape's own entry\n * type, since webview shapes carry a serialized one, or to {@link PullRequestMergeQueueEntry} for a shape that\n * doesn't declare one (an `IssueOrPullRequest` that is a pull request). */\nexport function isPullRequestInMergeQueue<T extends { readonly state?: string; readonly mergeQueue?: unknown }>(\n\tpr: T,\n): pr is T & {\n\treadonly mergeQueue: 'mergeQueue' extends keyof T ? NonNullable<T['mergeQueue']> : PullRequestMergeQueueEntry;\n} {\n\treturn pr.state === 'opened' && pr.mergeQueue != null;\n}\n\n/** A pull request's state as shown to users: its provider state, except an open pull request waiting in a merge queue is `queued`. */\nexport function getPullRequestDisplayState<S extends string | undefined>(pr: {\n\treadonly state: S;\n\treadonly mergeQueue?: unknown;\n}): S | 'queued' {\n\treturn isPullRequestInMergeQueue(pr) ? 'queued' : pr.state;\n}\n\n/** A pull request's {@link getPullRequestDisplayState display state} paired with its\n * {@link formatPullRequestMergeQueueStatus merge-queue status}, place in line included, which is set only while it's\n * queued — the pair a pull request chip renders. */\nexport function getPullRequestDisplayStatus<S extends string | undefined>(pr: {\n\treadonly state: S;\n\treadonly mergeQueue?: Parameters<typeof formatPullRequestMergeQueueStatus>[0];\n}): { status: S | 'queued'; queueStatus: string | undefined } {\n\treturn isPullRequestInMergeQueue(pr)\n\t\t? { status: 'queued', queueStatus: formatPullRequestMergeQueueStatus(pr.mergeQueue) }\n\t\t: { status: pr.state, queueStatus: undefined };\n}\n\n/**\n * Describes where a queued pull request stands in its merge queue, with its place in line when the provider gave one\n * (\"#2 in the merge queue, checks running\"). Merging and failing entries read the same with or without a place, since\n * the place no longer says anything there. Takes only the fields it reads, and the estimate as a date or a timestamp\n * (ms), since webview shapes carry a serialized entry.\n */\nexport function formatPullRequestMergeQueueStatus(entry: {\n\treadonly state: PullRequestMergeQueueState;\n\treadonly estimatedMergeAt?: Date | number;\n\treadonly position?: number;\n}): string {\n\tconst position = entry.position;\n\n\tlet status: string;\n\tswitch (entry.state) {\n\t\tcase PullRequestMergeQueueState.AwaitingChecks:\n\t\t\tstatus =\n\t\t\t\tposition != null\n\t\t\t\t\t? l10n.t('#{position} in the merge queue, checks running', { position: position })\n\t\t\t\t\t: l10n.t('Queued to merge, checks running');\n\t\t\tbreak;\n\t\tcase PullRequestMergeQueueState.Mergeable:\n\t\t\tstatus =\n\t\t\t\tposition != null\n\t\t\t\t\t? l10n.t('#{position} in the merge queue, next up', { position: position })\n\t\t\t\t\t: l10n.t('Queued to merge, next up');\n\t\t\tbreak;\n\t\tcase PullRequestMergeQueueState.Locked:\n\t\t\t// The merge is already in flight, so an estimate adds nothing\n\t\t\treturn l10n.t('Merging');\n\t\tcase PullRequestMergeQueueState.Unmergeable:\n\t\t\treturn l10n.t('Failing in the merge queue');\n\t\tdefault:\n\t\t\tstatus =\n\t\t\t\tposition != null\n\t\t\t\t\t? l10n.t('#{position} in the merge queue', { position: position })\n\t\t\t\t\t: l10n.t('Queued to merge');\n\t\t\tbreak;\n\t}\n\n\tif (entry.estimatedMergeAt == null) return status;\n\n\t// An estimate already past is wrong, not late news: \"estimated to merge 2 minutes ago\" would only mislead\n\tconst estimatedMergeAt = new Date(entry.estimatedMergeAt).getTime();\n\tif (Number.isNaN(estimatedMergeAt) || estimatedMergeAt <= Date.now()) return status;\n\n\treturn l10n.t('{0}, estimated to merge {1}', status, fromNow(estimatedMergeAt));\n}\n\n/** When a queued pull request joined its merge queue, as the clause that follows its\n * {@link formatPullRequestMergeQueueStatus status} — \"queued 3 hours ago\" — so a status that ends in an estimate\n * doesn't run straight into a bare date. */\nexport function formatPullRequestMergeQueueEnqueuedFromNow(entry: { readonly enqueuedAt: Date | number }): string {\n\treturn l10n.t('queued {0}', fromNow(entry.enqueuedAt));\n}\n\n/** What a `PullRequestMergeQueueRemoval`'s reason says about the pull request: its queue run `failed`, someone\n * removed it (`manual`), or a reason this doesn't recognize (`other`), which the removal's raw reason still names. */\nexport type PullRequestMergeQueueRemovalKind = 'failed' | 'manual' | 'other';\n\n/**\n * Classifies a merge-queue removal's provider reason. Only the reasons seen from GitHub are recognized —\n * `failed_checks` (its queue run failed) and `manual` — matched without regard to case; every other reason is\n * `other` rather than guessed at, so a caller that shows one can fall back to the raw reason.\n */\nexport function getPullRequestMergeQueueRemovalKind(reason: string): PullRequestMergeQueueRemovalKind {\n\tswitch (reason.toLowerCase()) {\n\t\tcase 'failed_checks':\n\t\t\treturn 'failed';\n\t\tcase 'manual':\n\t\t\treturn 'manual';\n\t\tdefault:\n\t\t\treturn 'other';\n\t}\n}\n\n/**\n * Whether a pull request's merge-queue removal (`mergeQueueRemoval`) still describes it: it is set,\n * the pull request is open and not queued, and nothing has touched the pull request since — its update time is no\n * later than the removal, which GitHub's removal doesn't move. Narrows `mergeQueueRemoval` to set.\n *\n * The trade-off: any later update clears it, not only a push that may have fixed the failure, so a comment or a\n * label added after a failed queue run also stops it reading as failing. A provider's timeline can't say whether a\n * push followed the removal (GitHub orders commits by commit date, not push time), and a stale \"failing\" is worse\n * than a missed one. Takes dates or timestamps (ms), since webview shapes carry serialized ones.\n */\nexport function isPullRequestMergeQueueRemovalCurrent<\n\tT extends {\n\t\treadonly state?: string;\n\t\treadonly updatedDate: Date | number;\n\t\treadonly mergeQueue?: unknown;\n\t\treadonly mergeQueueRemoval?: { readonly removedAt: Date | number };\n\t},\n>(pr: T): pr is T & { readonly mergeQueueRemoval: NonNullable<T['mergeQueueRemoval']> } {\n\tif (pr.mergeQueueRemoval == null || pr.state !== 'opened' || pr.mergeQueue != null) return false;\n\n\tconst removedAt = new Date(pr.mergeQueueRemoval.removedAt).getTime();\n\tconst updatedAt = new Date(pr.updatedDate).getTime();\n\tif (Number.isNaN(removedAt) || Number.isNaN(updatedAt)) return false;\n\n\treturn removedAt >= updatedAt;\n}\n\n/**\n * How each sort field is read off a {@link PullRequestShape}, for the filtered PR search, which MERGES its\n * relationship × state facets in the facade and so has to order the union itself instead of trusting the\n * per-facet server order. Only the fields the shape carries appear — the same rule as `getIssueComparator`, and\n * the reason {@link PullRequestSortField} is just these two.\n */\nconst pullRequestSortValues: Partial<\n\tRecord<PullRequestSortField, (pr: PullRequestShape) => number | Date | string | undefined>\n> = {\n\tcreated: pr => pr.createdDate,\n\tupdated: pr => pr.updatedDate,\n};\n\n/**\n * A comparator for one sort key over normalized pull requests, or `undefined` when the field isn't derivable\n * from a {@link PullRequestShape} — the signal that the key is only honorable on a SINGLE-origin read where the\n * provider already ordered the page. Missing values sort LAST in both directions (partitioned before any\n * arithmetic so two missing values compare equal, exactly as `getIssueComparator` does).\n *\n * Note it orders whatever it is handed. Sorting a page already capped at the result ceiling does not make it the\n * top N.\n */\nexport function getPullRequestComparator(\n\tsort: PullRequestSorting,\n): ((a: PullRequestShape, b: PullRequestShape) => number) | undefined {\n\tconst [field, direction] = sort.split(':') as [PullRequestSortField, 'asc' | 'desc'];\n\tconst getValue = pullRequestSortValues[field];\n\tif (getValue == null) return undefined;\n\n\treturn (a, b) => {\n\t\tconst left = toComparable(getValue(a));\n\t\tconst right = toComparable(getValue(b));\n\t\tif (left == null || right == null) {\n\t\t\tif (left == null && right == null) return 0;\n\n\t\t\treturn left == null ? 1 : -1;\n\t\t}\n\n\t\tconst ordered = left < right ? -1 : left > right ? 1 : 0;\n\t\treturn direction === 'asc' ? ordered : -ordered;\n\t};\n}\n\nfunction toComparable(value: number | Date | string | undefined): number | string | undefined {\n\treturn value instanceof Date ? value.getTime() : value;\n}\n\nexport interface PullRequestUrlIdentity<TProvider extends string = string> {\n\tprovider?: TProvider;\n\n\townerAndRepo?: string;\n\tprNumber: string;\n}\n\nexport function getComparisonRefsForPullRequest(repoPath: string, prRefs: PullRequestRefs): PullRequestComparisonRefs {\n\tconst refs: PullRequestComparisonRefs = {\n\t\trepoPath: repoPath,\n\t\tbase: { ref: prRefs.base.sha, label: `${prRefs.base.branch} (${shortenRevision(prRefs.base.sha)})` },\n\t\thead: { ref: prRefs.head.sha, label: prRefs.head.branch },\n\t};\n\treturn refs;\n}\n\nexport function getPullRequestIdentityFromMaybeUrl(search: string): PullRequestUrlIdentity | undefined {\n\tlet prNumber: string | undefined = undefined;\n\n\tlet match = search.match(/(?:\\/)(\\d+)/); // any number starting with \"/\"\n\tif (match != null) {\n\t\tprNumber = match[1];\n\t}\n\n\tif (prNumber == null) {\n\t\tmatch = search.match(/^#?(\\d+)$/); // just a number or with a leading \"#\"\n\t\tif (match != null) {\n\t\t\tprNumber = match[1];\n\t\t}\n\t}\n\n\treturn prNumber == null ? undefined : { ownerAndRepo: undefined, prNumber: prNumber, provider: undefined };\n}\n\n/** A pull request's display number from its url, or `undefined` for a url naming no pull request. Anchors\n * on the provider's pull request path segment (GitHub `pull`, Bitbucket `pull-requests`, GitLab\n * `merge_requests`, Azure `pullrequest`) so a digit-leading owner (`github.com/1Password/x/pull/123`)\n * can't win. */\nexport function getPullRequestNumberFromUrl(url: string): string | undefined {\n\t// No loose fallback: `getPullRequestIdentityFromMaybeUrl` scans for any `/<digits>`, which reads a bare\n\t// repository url like `github.com/1Password/sdk` as pull request #1. Callers that hold a real pull\n\t// request fall back to its id instead, and the one that asks whether a pasted url names a pull request\n\t// needs \"no\" for an answer.\n\treturn url.match(/(?:pull|pull-requests|merge_requests|pullrequest)\\/(\\d+)(?:\\b|\\/|$)/)?.[1];\n}\n\nexport function getRepositoryIdentityForPullRequest(\n\tpr: PullRequest,\n\theadRepo: boolean = true,\n): PullRequestRepositoryIdentityDescriptor {\n\tif (headRepo) {\n\t\treturn {\n\t\t\tremote: {\n\t\t\t\turl: pr.refs?.head?.url,\n\t\t\t\tdomain: pr.provider.domain,\n\t\t\t},\n\t\t\tname: `${pr.refs?.head?.owner ?? pr.repository.owner}/${pr.refs?.head?.repo ?? pr.repository.repo}`,\n\t\t\tprovider: {\n\t\t\t\tid: pr.provider.id,\n\t\t\t\tdomain: pr.provider.domain,\n\t\t\t\trepoDomain: pr.refs?.head?.owner ?? pr.repository.owner,\n\t\t\t\trepoName: pr.refs?.head?.repo ?? pr.repository.repo,\n\t\t\t},\n\t\t};\n\t}\n\n\treturn {\n\t\tremote: {\n\t\t\turl: pr.refs?.base?.url ?? pr.url,\n\t\t\tdomain: pr.provider.domain,\n\t\t},\n\t\tname: `${pr.refs?.base?.owner ?? pr.repository.owner}/${pr.refs?.base?.repo ?? pr.repository.repo}`,\n\t\tprovider: {\n\t\t\tid: pr.provider.id,\n\t\t\tdomain: pr.provider.domain,\n\t\t\trepoDomain: pr.refs?.base?.owner ?? pr.repository.owner,\n\t\t\trepoName: pr.refs?.base?.repo ?? pr.repository.repo,\n\t\t\trepoOwnerDomain: pr.refs?.base?.owner ?? pr.repository.owner,\n\t\t},\n\t};\n}\n\nexport function isMaybeNonSpecificPullRequestSearchUrl(search: string): boolean {\n\treturn getPullRequestIdentityFromMaybeUrl(search) != null;\n}\n\n/**\n * Deliberately leaves `projection` out: this copy drops `filesChanged`, `repository` and the class-only check rollup,\n * commit count and `viewerCanUpdate`, so a tag would have field presence report as fetched what the copy no longer has.\n */\nexport function serializePullRequest(value: PullRequest): PullRequestShape {\n\tconst serialized: PullRequestShape = {\n\t\ttype: value.type,\n\t\tprovider: {\n\t\t\tid: value.provider.id,\n\t\t\tname: value.provider.name,\n\t\t\tdomain: value.provider.domain,\n\t\t\ticon: value.provider.icon,\n\t\t},\n\t\tid: value.id,\n\t\tnodeId: value.nodeId,\n\t\tnumber: value.number,\n\t\ttitle: value.title,\n\t\tbody: value.body,\n\t\turl: value.url,\n\t\tcreatedDate: value.createdDate,\n\t\tupdatedDate: value.updatedDate,\n\t\tclosedDate: value.closedDate,\n\t\tclosed: value.closed,\n\t\tauthor: {\n\t\t\tid: value.author.id,\n\t\t\tname: value.author.name,\n\t\t\tusername: value.author.username,\n\t\t\tavatarUrl: value.author.avatarUrl,\n\t\t\turl: value.author.url,\n\t\t},\n\t\tstate: value.state,\n\t\tmergedDate: value.mergedDate,\n\t\tmergeableState: value.mergeableState,\n\t\trefs: value.refs\n\t\t\t? {\n\t\t\t\t\thead: {\n\t\t\t\t\t\texists: value.refs.head.exists,\n\t\t\t\t\t\towner: value.refs.head.owner,\n\t\t\t\t\t\trepo: value.refs.head.repo,\n\t\t\t\t\t\tsha: value.refs.head.sha,\n\t\t\t\t\t\tbranch: value.refs.head.branch,\n\t\t\t\t\t\turl: value.refs.head.url,\n\t\t\t\t\t\tcloneHttps: value.refs.head.cloneHttps,\n\t\t\t\t\t\tcloneSsh: value.refs.head.cloneSsh,\n\t\t\t\t\t\tisFork: value.refs.head.isFork,\n\t\t\t\t\t},\n\t\t\t\t\tbase: {\n\t\t\t\t\t\texists: value.refs.base.exists,\n\t\t\t\t\t\towner: value.refs.base.owner,\n\t\t\t\t\t\trepo: value.refs.base.repo,\n\t\t\t\t\t\tsha: value.refs.base.sha,\n\t\t\t\t\t\tbranch: value.refs.base.branch,\n\t\t\t\t\t\turl: value.refs.base.url,\n\t\t\t\t\t\tcloneHttps: value.refs.base.cloneHttps,\n\t\t\t\t\t\tcloneSsh: value.refs.base.cloneSsh,\n\t\t\t\t\t\tisFork: value.refs.base.isFork,\n\t\t\t\t\t},\n\t\t\t\t\tisCrossRepository: value.refs.isCrossRepository,\n\t\t\t\t}\n\t\t\t: undefined,\n\t\tisDraft: value.isDraft,\n\t\tadditions: value.additions,\n\t\tdeletions: value.deletions,\n\t\tcommentsCount: value.commentsCount,\n\t\tthumbsUpCount: value.thumbsUpCount,\n\t\treviewDecision: value.reviewDecision,\n\t\treviewRequests: value.reviewRequests,\n\t\tlatestReviews: value.latestReviews,\n\t\tassignees: value.assignees,\n\t\tauthoredByMe: value.authoredByMe,\n\t\tviewer: value.viewer != null ? { id: value.viewer.id, username: value.viewer.username } : undefined,\n\t\tviewerUnresolved: value.viewerUnresolved,\n\t\tmilestone: serializeMilestone(value.milestone),\n\t\tproject: value.project\n\t\t\t? {\n\t\t\t\t\tid: value.project.id,\n\t\t\t\t\tname: value.project.name,\n\t\t\t\t\tresourceId: value.project.resourceId,\n\t\t\t\t\tresourceName: value.project.resourceName,\n\t\t\t\t}\n\t\t\t: undefined,\n\t\tstack: value.stack\n\t\t\t? {\n\t\t\t\t\tid: value.stack.id,\n\t\t\t\t\tnumber: value.stack.number,\n\t\t\t\t\tsize: value.stack.size,\n\t\t\t\t\tposition: value.stack.position,\n\t\t\t\t\tbaseRef: value.stack.baseRef,\n\t\t\t\t}\n\t\t\t: undefined,\n\t\tmergeQueue: value.mergeQueue\n\t\t\t? {\n\t\t\t\t\tstate: value.mergeQueue.state,\n\t\t\t\t\tenqueuedAt: value.mergeQueue.enqueuedAt,\n\t\t\t\t\testimatedMergeAt: value.mergeQueue.estimatedMergeAt,\n\t\t\t\t\turl: value.mergeQueue.url,\n\t\t\t\t\tposition: value.mergeQueue.position,\n\t\t\t\t}\n\t\t\t: undefined,\n\t\tmergeQueueRequired: value.mergeQueueRequired,\n\t\tmergeQueueRemoval: value.mergeQueueRemoval\n\t\t\t? { reason: value.mergeQueueRemoval.reason, removedAt: value.mergeQueueRemoval.removedAt }\n\t\t\t: undefined,\n\t\tcheckRuns: value.checkRuns?.map(run => ({ ...run })),\n\t\tcheckRunsTruncated: value.checkRunsTruncated,\n\t};\n\treturn serialized;\n}\n"],"mappings":";;;;;;;;;;;AAsBA,SAAgB,qBACf,OACA,SACS;CACT,IAAI,SAAS,MAAM,OAAO;CAC1B,OAAO,SAAS,aAAa,MAAM,OAAO,MAAM;AACjD;;;;;AAMA,SAAgB,0BACf,IAGC;CACD,OAAO,GAAG,UAAU,YAAY,GAAG,cAAc;AAClD;;AAGA,SAAgB,2BAAyD,IAGxD;CAChB,OAAO,0BAA0B,EAAE,IAAI,WAAW,GAAG;AACtD;;;;AAKA,SAAgB,4BAA0D,IAGZ;CAC7D,OAAO,0BAA0B,EAAE,IAChC;EAAE,QAAQ;EAAU,aAAa,kCAAkC,GAAG,UAAU;CAAE,IAClF;EAAE,QAAQ,GAAG;EAAO,aAAa,KAAA;CAAU;AAC/C;;;;;;;AAQA,SAAgB,kCAAkC,OAIvC;CACV,MAAM,WAAW,MAAM;CAEvB,IAAI;CACJ,QAAQ,MAAM,OAAd;EACC,KAAA;GACC,SACC,YAAY,OACT,KAAK,EAAE,kDAAkD,EAAY,SAAS,CAAC,IAC/E,KAAK,EAAE,iCAAiC;GAC5C;EACD,KAAA;GACC,SACC,YAAY,OACT,KAAK,EAAE,2CAA2C,EAAY,SAAS,CAAC,IACxE,KAAK,EAAE,0BAA0B;GACrC;EACD,KAAA,UAEC,OAAO,KAAK,EAAE,SAAS;EACxB,KAAA,eACC,OAAO,KAAK,EAAE,4BAA4B;EAC3C,SACC,SACC,YAAY,OACT,KAAK,EAAE,kCAAkC,EAAY,SAAS,CAAC,IAC/D,KAAK,EAAE,iBAAiB;CAE9B;CAEA,IAAI,MAAM,oBAAoB,MAAM,OAAO;CAG3C,MAAM,mBAAmB,IAAI,KAAK,MAAM,gBAAgB,C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A;EACH,oBAAoB,MAAM;EAC1B,mBAAmB,MAAM,oBACtB;GAAE,QAAQ,MAAM,kBAAkB;GAAQ,WAAW,MAAM,kBAAkB;EAAU,IACvF,KAAA;EACH,WAAW,MAAM,WAAW,KAAI,SAAQ,EAAE,GAAG,IAAI,EAAE;EACnD,oBAAoB,MAAM;CAEX;AACjB"}
|
|
@@ -34,6 +34,7 @@ const maxConcurrentReadsPerRepository = 4;
|
|
|
34
34
|
const maxConcurrentReads = 8;
|
|
35
35
|
const maxUnwatchedReads = 256;
|
|
36
36
|
const maxDeferredDirtyMs = 1e4;
|
|
37
|
+
const untrackedDirtyRecheckMs = 1e3;
|
|
37
38
|
const minBaseRetryDelayMs = 5e3;
|
|
38
39
|
const maxBaseRetryDelayMs = 3e5;
|
|
39
40
|
const maxCarriedBaseAgeMs = 3e5;
|
|
@@ -747,6 +748,7 @@ var WorktreeSummaryService = class {
|
|
|
747
748
|
entry.baseRetry = getBaseRetry(entry.baseRetry, result);
|
|
748
749
|
const dirtyConfirmed = result.dirtyReadAt != null && entry.dirtyReadAt != null;
|
|
749
750
|
if (dirtyConfirmed) clearDeferredDirty(entry);
|
|
751
|
+
if (result.dirtyUntrackedOnly != null) this.recheckUntrackedDirty(entry, result.dirtyUntrackedOnly);
|
|
750
752
|
if (value != null && summariesEqual(value, result.summary)) {
|
|
751
753
|
if (dirtyConfirmed) this.fireChange(entry, value);
|
|
752
754
|
return;
|
|
@@ -755,7 +757,22 @@ var WorktreeSummaryService = class {
|
|
|
755
757
|
entry.value = summary;
|
|
756
758
|
this.fireChange(entry, summary);
|
|
757
759
|
}
|
|
760
|
+
recheckUntrackedDirty(entry, untrackedOnly) {
|
|
761
|
+
const isRecheck = entry.untrackedDirtyRecheckDue;
|
|
762
|
+
entry.untrackedDirtyRecheckDue = false;
|
|
763
|
+
clearTimeout(entry.untrackedDirtyRecheckTimer);
|
|
764
|
+
entry.untrackedDirtyRecheckTimer = void 0;
|
|
765
|
+
if (!untrackedOnly || isRecheck) return;
|
|
766
|
+
const timer = setTimeout(() => {
|
|
767
|
+
entry.untrackedDirtyRecheckTimer = void 0;
|
|
768
|
+
entry.untrackedDirtyRecheckDue = true;
|
|
769
|
+
this.queue(entry, dirtyField);
|
|
770
|
+
}, untrackedDirtyRecheckMs);
|
|
771
|
+
if (typeof timer !== "number") timer.unref();
|
|
772
|
+
entry.untrackedDirtyRecheckTimer = timer;
|
|
773
|
+
}
|
|
758
774
|
fail(entry, ex) {
|
|
775
|
+
entry.untrackedDirtyRecheckDue = false;
|
|
759
776
|
const previous = entry.value;
|
|
760
777
|
if (previous == null) {
|
|
761
778
|
if (entry.seed != null) {
|
|
@@ -799,6 +816,9 @@ var WorktreeSummaryService = class {
|
|
|
799
816
|
entry.value = void 0;
|
|
800
817
|
entry.seed = void 0;
|
|
801
818
|
clearDeferredDirty(entry);
|
|
819
|
+
clearTimeout(entry.untrackedDirtyRecheckTimer);
|
|
820
|
+
entry.untrackedDirtyRecheckTimer = void 0;
|
|
821
|
+
entry.untrackedDirtyRecheckDue = false;
|
|
802
822
|
entry.baseKeys = void 0;
|
|
803
823
|
entry.baseConfigKey = void 0;
|
|
804
824
|
entry.baseDefaultBranch = void 0;
|
|
@@ -850,6 +870,8 @@ function createEntry(key) {
|
|
|
850
870
|
seed: void 0,
|
|
851
871
|
dirtyReadAt: void 0,
|
|
852
872
|
dirtyReadTimer: void 0,
|
|
873
|
+
untrackedDirtyRecheckDue: false,
|
|
874
|
+
untrackedDirtyRecheckTimer: void 0,
|
|
853
875
|
baseKeys: void 0,
|
|
854
876
|
baseConfigKey: void 0,
|
|
855
877
|
baseDefaultBranch: void 0,
|
|
@@ -1015,7 +1037,8 @@ async function readSummary(repo, key, fields, previous, previousBaseKeys, previo
|
|
|
1015
1037
|
}
|
|
1016
1038
|
}
|
|
1017
1039
|
}
|
|
1018
|
-
const
|
|
1040
|
+
const dirtyAnswer = dirtyRead != null ? await dirtyRead : void 0;
|
|
1041
|
+
const dirty = dirtyAnswer != null ? dirtyAnswer !== false : previous?.dirty ?? false;
|
|
1019
1042
|
const summary = {
|
|
1020
1043
|
repoPath: key,
|
|
1021
1044
|
branch,
|
|
@@ -1038,6 +1061,7 @@ async function readSummary(repo, key, fields, previous, previousBaseKeys, previo
|
|
|
1038
1061
|
baseFullRead,
|
|
1039
1062
|
baseError,
|
|
1040
1063
|
dirtyReadAt,
|
|
1064
|
+
dirtyUntrackedOnly: dirtyAnswer != null ? dirtyAnswer === "untracked" : void 0,
|
|
1041
1065
|
fields
|
|
1042
1066
|
};
|
|
1043
1067
|
}
|
|
@@ -1336,10 +1360,18 @@ function baseKeysEqual(a, b) {
|
|
|
1336
1360
|
return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];
|
|
1337
1361
|
}
|
|
1338
1362
|
function readDirty(repo, signal) {
|
|
1339
|
-
const read = repo
|
|
1363
|
+
const read = readWorkingChanges(repo, signal);
|
|
1340
1364
|
read.catch(noop);
|
|
1341
1365
|
return read;
|
|
1342
1366
|
}
|
|
1367
|
+
async function readWorkingChanges(repo, signal) {
|
|
1368
|
+
if (await repo.status.hasWorkingChanges({ untracked: false }, signal)) return true;
|
|
1369
|
+
return await repo.status.hasWorkingChanges({
|
|
1370
|
+
staged: false,
|
|
1371
|
+
unstaged: false,
|
|
1372
|
+
untracked: true
|
|
1373
|
+
}, signal) ? "untracked" : false;
|
|
1374
|
+
}
|
|
1343
1375
|
function noop() {}
|
|
1344
1376
|
/**
|
|
1345
1377
|
* Uses the remote and branch git reported for the upstream; only when it reported neither does this split the name
|