@gitkraken/core-gitlens 0.61.1 → 0.63.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.
Files changed (72) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/dist/git/cache.d.ts +1 -0
  3. package/dist/git/cache.js +11 -0
  4. package/dist/git/cache.js.map +1 -1
  5. package/dist/git/errors.d.ts +15 -0
  6. package/dist/git/errors.js +9 -1
  7. package/dist/git/errors.js.map +1 -1
  8. package/dist/git/models/pullRequest.d.ts +3 -0
  9. package/dist/git/models/pullRequest.js.map +1 -1
  10. package/dist/git/providers/operations.d.ts +4 -3
  11. package/dist/git/providers/staging.d.ts +16 -8
  12. package/dist/git/run.types.d.ts +6 -0
  13. package/dist/git/service.js +6 -0
  14. package/dist/git/service.js.map +1 -1
  15. package/dist/git/utils/hiddenRefs.utils.d.ts +15 -0
  16. package/dist/git/utils/hiddenRefs.utils.js +68 -2
  17. package/dist/git/utils/hiddenRefs.utils.js.map +1 -1
  18. package/dist/git/utils/pullRequest.utils.d.ts +3 -6
  19. package/dist/git/utils/pullRequest.utils.js +6 -7
  20. package/dist/git/utils/pullRequest.utils.js.map +1 -1
  21. package/dist/git/watching/gitIgnoreFilter.d.ts +12 -5
  22. package/dist/git/watching/gitIgnoreFilter.js +26 -32
  23. package/dist/git/watching/gitIgnoreFilter.js.map +1 -1
  24. package/dist/git/watching/provider.d.ts +18 -3
  25. package/dist/git/watching/watchGroup.d.ts +7 -2
  26. package/dist/git/watching/watchGroup.js +51 -3
  27. package/dist/git/watching/watchGroup.js.map +1 -1
  28. package/dist/git/watching/watchService.d.ts +16 -2
  29. package/dist/git/watching/watchService.js +210 -88
  30. package/dist/git/watching/watchService.js.map +1 -1
  31. package/dist/git/watching/watcherPatterns.d.ts +1 -1
  32. package/dist/git/watching/watcherPatterns.js +11 -5
  33. package/dist/git/watching/watcherPatterns.js.map +1 -1
  34. package/dist/git-cli/cliGitProvider.d.ts +3 -6
  35. package/dist/git-cli/cliGitProvider.js +144 -38
  36. package/dist/git-cli/cliGitProvider.js.map +1 -1
  37. package/dist/git-cli/exec/git.js +4 -4
  38. package/dist/git-cli/exec/git.js.map +1 -1
  39. package/dist/git-cli/exec/indexLock.d.ts +7 -5
  40. package/dist/git-cli/exec/indexLock.js +19 -15
  41. package/dist/git-cli/exec/indexLock.js.map +1 -1
  42. package/dist/git-cli/providers/config.d.ts +1 -0
  43. package/dist/git-cli/providers/config.js +15 -5
  44. package/dist/git-cli/providers/config.js.map +1 -1
  45. package/dist/git-cli/providers/pausedOperations.js +2 -2
  46. package/dist/git-cli/providers/pausedOperations.js.map +1 -1
  47. package/dist/git-cli/providers/staging.d.ts +8 -8
  48. package/dist/git-cli/providers/staging.js +120 -25
  49. package/dist/git-cli/providers/staging.js.map +1 -1
  50. package/dist/ipc/discovery.js +1 -1
  51. package/dist/plus/agents/providers/claudeCodeTranscript.js +6 -6
  52. package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
  53. package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -1
  54. package/dist/plus/git-github/api/config.d.ts +5 -0
  55. package/dist/plus/git-github/api/config.js.map +1 -1
  56. package/dist/plus/git-github/api/github.js +24 -4
  57. package/dist/plus/git-github/api/github.js.map +1 -1
  58. package/dist/plus/git-github/models.d.ts +12 -0
  59. package/dist/plus/git-github/models.js +8 -3
  60. package/dist/plus/git-github/models.js.map +1 -1
  61. package/dist/plus/integrations/context.d.ts +5 -0
  62. package/dist/plus/integrations/providers/azure/azure.js +1 -1
  63. package/dist/plus/integrations/providers/github.js +7 -3
  64. package/dist/plus/integrations/providers/github.js.map +1 -1
  65. package/dist/plus/integrations/reads/etag.d.ts +5 -0
  66. package/dist/plus/integrations/reads/etag.js +2 -0
  67. package/dist/plus/integrations/reads/etag.js.map +1 -1
  68. package/dist/utils/env/node/exec.d.ts +2 -0
  69. package/dist/utils/env/node/exec.js +4 -2
  70. package/dist/utils/env/node/exec.js.map +1 -1
  71. package/docs/integrations.md +9 -9
  72. package/package.json +1 -1
@@ -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\tPullRequestSearchCriteria,\n\tPullRequestShape,\n\tPullRequestSortField,\n\tPullRequestSorting,\n\tPullRequestStackInfo,\n} from '../models/pullRequest.js';\nimport { defaultPullRequestSort, 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\nexport function effectivePullRequestSearchSort(criteria: PullRequestSearchCriteria | undefined): PullRequestSorting {\n\treturn criteria?.sort ?? (criteria?.changedSince != null ? 'updated:asc' : defaultPullRequestSort);\n}\n\nexport function isValidPullRequestChangedSince(value: string): boolean {\n\tif (!/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$/.test(value)) return false;\n\n\tconst time = Date.parse(value);\n\treturn !Number.isNaN(time) && new Date(time).toISOString() === `${value.slice(0, -1)}.000Z`;\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":";;;;;;;;;;;AAuBA,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,QA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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;EACH,WAAW,MAAM,WAAW,KAAI,SAAQ,EAAE,GAAG,IAAI,EAAE;EACnD,oBAAoB,MAAM;CAEX;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\tPullRequestSearchCriteria,\n\tPullRequestShape,\n\tPullRequestSortField,\n\tPullRequestSorting,\n\tPullRequestStackInfo,\n} from '../models/pullRequest.js';\nimport { defaultPullRequestSort, 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 lands: 1 when unstacked; when stacked, this layer and every layer below it\n * (every layer with `wholeStack`), less `mergedLayers`. Never less than 1. */\nexport function getStackedMergeCount(\n\tstack: Pick<PullRequestStackInfo, 'position' | 'size' | 'mergedLayers'> | undefined,\n\toptions?: { wholeStack?: boolean },\n): number {\n\tif (stack == null) return 1;\n\n\tconst count = options?.wholeStack ? stack.size : stack.position;\n\treturn Math.max(1, count - (stack.mergedLayers ?? 0));\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\nexport function effectivePullRequestSearchSort(criteria: PullRequestSearchCriteria | undefined): PullRequestSorting {\n\treturn criteria?.sort ?? (criteria?.changedSince != null ? 'updated:asc' : defaultPullRequestSort);\n}\n\nexport function isValidPullRequestChangedSince(value: string): boolean {\n\tif (!/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$/.test(value)) return false;\n\n\tconst time = Date.parse(value);\n\treturn !Number.isNaN(time) && new Date(time).toISOString() === `${value.slice(0, -1)}.000Z`;\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\tmergedLayers: value.stack.mergedLayers,\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":";;;;;;;;AAoBA,SAAgB,qBACf,OACA,SACS;CACT,IAAI,SAAS,MAAM,OAAO;CAE1B,MAAM,QAAQ,SAAS,aAAa,MAAM,OAAO,MAAM;CACvD,OAAO,KAAK,IAAI,GAAG,SAAS,MAAM,gBAAgB,EAAE;AACrD;;;;;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,I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M;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;GACrB,cAAc,MAAM,MAAM;EAC3B,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;EACH,WAAW,MAAM,WAAW,KAAI,SAAQ,EAAE,GAAG,IAAI,EAAE;EACnD,oBAAoB,MAAM;CAEX;AACjB"}
@@ -1,5 +1,9 @@
1
1
  import { FileSystemProvider } from "../context.js";
2
2
  //#region ../git/src/watching/gitIgnoreFilter.d.ts
3
+ interface IgnoreFilterConfig {
4
+ readonly globalExcludesPath?: string;
5
+ readonly ignoreCase?: boolean;
6
+ }
3
7
  export interface GitIgnoreFilterOptions {
4
8
  /** Absolute path to the repository root (working tree) */
5
9
  readonly repoPath: string;
@@ -12,6 +16,8 @@ export interface GitIgnoreFilterOptions {
12
16
  * May return undefined if not configured.
13
17
  */
14
18
  readonly getGlobalExcludesPath?: () => Promise<string | undefined>;
19
+ readonly getConfig?: () => Promise<IgnoreFilterConfig>;
20
+ readonly invalidateConfig?: () => void;
15
21
  /**
16
22
  * Returns the absolute path to `info/exclude`, which lives in the COMMON git dir for a linked worktree.
17
23
  * When provided, replaces the `gitDirPath`-based resolution; undefined means there is none to read.
@@ -60,10 +66,11 @@ export declare class GitIgnoreFilter {
60
66
  private readonly repoPath;
61
67
  private readonly gitDirPath;
62
68
  private readonly fs;
63
- private readonly getGlobalExcludesPath?;
69
+ private readonly getConfig;
70
+ private readonly invalidateConfig?;
64
71
  private readonly getInfoExcludePath?;
65
72
  private readonly getGitIgnorePaths?;
66
- private readonly getIgnoreCase?;
73
+ get canInvalidateConfig(): boolean;
67
74
  constructor(options: GitIgnoreFilterOptions);
68
75
  /** Resolves when patterns are loaded and any {@link revalidate} has settled. Safe to call multiple times. */
69
76
  ready(): Promise<void>;
@@ -86,7 +93,9 @@ export declare class GitIgnoreFilter {
86
93
  * Single-flight: an idle filter reloads at once, but while a reload runs, every further call shares one reload
87
94
  * queued behind it — a checkout touching many `.gitignore` files costs two reloads, not one per file.
88
95
  */
89
- refresh(): Promise<void>;
96
+ refresh(options?: {
97
+ configChanged?: boolean;
98
+ }): Promise<void>;
90
99
  /**
91
100
  * Reloads when an ignore source changed since the last load, for a caller that stopped watching them for a while.
92
101
  * Resolves true once that reload has committed; false when nothing changed, when no load has committed yet, or when
@@ -118,8 +127,6 @@ export declare class GitIgnoreFilter {
118
127
  private stamp;
119
128
  private readFile;
120
129
  private resolveInfoExcludePath;
121
- private readIgnoreCase;
122
- private resolveGlobalExcludesPath;
123
130
  }
124
131
  //#endregion
125
132
  //# sourceMappingURL=gitIgnoreFilter.d.ts.map
@@ -42,18 +42,28 @@ var GitIgnoreFilter = class {
42
42
  repoPath;
43
43
  gitDirPath;
44
44
  fs;
45
- getGlobalExcludesPath;
45
+ getConfig;
46
+ invalidateConfig;
46
47
  getInfoExcludePath;
47
48
  getGitIgnorePaths;
48
- getIgnoreCase;
49
+ get canInvalidateConfig() {
50
+ return this.invalidateConfig != null;
51
+ }
49
52
  constructor(options) {
50
53
  this.repoPath = options.repoPath;
51
54
  this.gitDirPath = options.gitDirPath;
52
55
  this.fs = options.fs;
53
- this.getGlobalExcludesPath = options.getGlobalExcludesPath;
56
+ this.getConfig = async () => {
57
+ if (options.getConfig != null) return options.getConfig();
58
+ const [path, ignoreCase] = await Promise.allSettled([Promise.resolve().then(() => options.getGlobalExcludesPath?.()), Promise.resolve().then(() => options.getIgnoreCase?.())]);
59
+ return {
60
+ globalExcludesPath: getSettledValue(path),
61
+ ignoreCase: getSettledValue(ignoreCase)
62
+ };
63
+ };
64
+ this.invalidateConfig = options.invalidateConfig;
54
65
  this.getInfoExcludePath = options.getInfoExcludePath;
55
66
  this.getGitIgnorePaths = options.getGitIgnorePaths;
56
- this.getIgnoreCase = options.getIgnoreCase;
57
67
  this.startLoad();
58
68
  }
59
69
  /** Resolves when patterns are loaded and any {@link revalidate} has settled. Safe to call multiple times. */
@@ -90,7 +100,8 @@ var GitIgnoreFilter = class {
90
100
  * Single-flight: an idle filter reloads at once, but while a reload runs, every further call shares one reload
91
101
  * queued behind it — a checkout touching many `.gitignore` files costs two reloads, not one per file.
92
102
  */
93
- refresh() {
103
+ refresh(options) {
104
+ if (options?.configChanged) this.invalidateConfig?.();
94
105
  if (this.inflight == null) return this.startLoad();
95
106
  if (this.trailing == null) {
96
107
  const run = () => {
@@ -180,18 +191,18 @@ var GitIgnoreFilter = class {
180
191
  async loadPatterns() {
181
192
  const id = this._generation.next();
182
193
  const stamps = /* @__PURE__ */ new Map();
183
- const globalExcludesPath = this.resolveGlobalExcludesPath();
194
+ const config = this.getConfig();
184
195
  const infoExcludePath = this.resolveInfoExcludePath();
185
- const [globalResult, infoResult, rootResult, nestedResult, ignoreCaseResult] = await Promise.allSettled([
186
- globalExcludesPath.then((path) => this.readSource(path, stamps)),
196
+ const [globalResult, infoResult, rootResult, nestedResult, configResult, infoPathResult] = await Promise.allSettled([
197
+ config.then(({ globalExcludesPath }) => this.readSource(globalExcludesPath, stamps)),
187
198
  infoExcludePath.then((path) => this.readSource(path, stamps)),
188
199
  this.readSource(`${this.repoPath}/.gitignore`, stamps),
189
200
  this.loadNested(stamps),
190
- this.readIgnoreCase()
201
+ config,
202
+ infoExcludePath
191
203
  ]);
192
- const [globalPathResult, infoPathResult] = await Promise.allSettled([globalExcludesPath, infoExcludePath]);
193
204
  if (id !== this._generation.current) return;
194
- const options = { ignorecase: getSettledValue(ignoreCaseResult) ?? defaultIgnoreCase };
205
+ const options = { ignorecase: getSettledValue(configResult)?.ignoreCase ?? defaultIgnoreCase };
195
206
  const ig = ignore(options);
196
207
  for (const content of [
197
208
  getSettledValue(globalResult),
@@ -215,20 +226,19 @@ var GitIgnoreFilter = class {
215
226
  this.nested = nested?.size ? nested : void 0;
216
227
  this.sources = {
217
228
  ignoreCase: options.ignorecase,
218
- globalExcludesPath: getSettledValue(globalPathResult),
229
+ globalExcludesPath: getSettledValue(configResult)?.globalExcludesPath,
219
230
  infoExcludePath: getSettledValue(infoPathResult),
220
231
  stamps
221
232
  };
222
233
  }
223
234
  /** Whether anything {@link loadPatterns} built `sources` from differs now; a source that can't be stat'ed has */
224
235
  async sourcesChanged(sources) {
225
- const [globalExcludesPath, infoExcludePath, ignoreCase, unchanged] = await Promise.allSettled([
226
- this.resolveGlobalExcludesPath(),
236
+ const [config, infoExcludePath, unchanged] = await Promise.allSettled([
237
+ this.getConfig(),
227
238
  this.resolveInfoExcludePath(),
228
- this.readIgnoreCase(),
229
239
  Promise.allSettled(Array.from(sources.stamps, async ([path, stamp]) => stamp != null && stamp === await this.stamp(path)))
230
240
  ]);
231
- return getSettledValue(globalExcludesPath) !== sources.globalExcludesPath || getSettledValue(infoExcludePath) !== sources.infoExcludePath || (getSettledValue(ignoreCase) ?? defaultIgnoreCase) !== sources.ignoreCase || getSettledValue(unchanged)?.every((r) => getSettledValue(r) === true) !== true;
241
+ return getSettledValue(config)?.globalExcludesPath !== sources.globalExcludesPath || getSettledValue(infoExcludePath) !== sources.infoExcludePath || (getSettledValue(config)?.ignoreCase ?? defaultIgnoreCase) !== sources.ignoreCase || getSettledValue(unchanged)?.every((r) => getSettledValue(r) === true) !== true;
232
242
  }
233
243
  /** Reads every nested `.gitignore`, keyed by its repo-relative directory (no trailing slash) */
234
244
  async loadNested(stamps) {
@@ -288,22 +298,6 @@ var GitIgnoreFilter = class {
288
298
  return;
289
299
  }
290
300
  }
291
- async readIgnoreCase() {
292
- if (this.getIgnoreCase == null) return void 0;
293
- try {
294
- return await this.getIgnoreCase();
295
- } catch {
296
- return;
297
- }
298
- }
299
- async resolveGlobalExcludesPath() {
300
- if (this.getGlobalExcludesPath == null) return void 0;
301
- try {
302
- return await this.getGlobalExcludesPath();
303
- } catch {
304
- return;
305
- }
306
- }
307
301
  };
308
302
  //#endregion
309
303
  export { GitIgnoreFilter };
@@ -1 +1 @@
1
- {"version":3,"file":"gitIgnoreFilter.js","names":[],"sources":["../../../../git/src/watching/gitIgnoreFilter.ts"],"sourcesContent":["import type { Ignore } from 'ignore';\nimport ignore from 'ignore';\nimport { getScopedCounter } from '@gitlens/utils/counter.js';\nimport { isLinux } from '@gitlens/utils/platform.js';\nimport { getSettledValue } from '@gitlens/utils/promise.js';\nimport { fileUri } from '@gitlens/utils/uri.js';\nimport type { FileSystemProvider } from '../context.js';\n\n/**\n * Case sensitivity when `core.ignorecase` is unset or unreadable. `ignore` matches case-insensitively by default, but\n * git follows `core.ignorecase` — false on Linux (and on a case-sensitive macOS volume), where matching `Build/`\n * against `build/` would call a real change ignored and drop it.\n */\nconst defaultIgnoreCase = !isLinux;\n\nexport interface GitIgnoreFilterOptions {\n\t/** Absolute path to the repository root (working tree) */\n\treadonly repoPath: string;\n\t/** Absolute path to the .git directory (for info/exclude when `getInfoExcludePath` isn't provided) */\n\treadonly gitDirPath: string;\n\t/** File system provider for reading ignore files */\n\treadonly fs: FileSystemProvider;\n\t/**\n\t * Returns the path to the global excludes file (core.excludesFile).\n\t * May return undefined if not configured.\n\t */\n\treadonly getGlobalExcludesPath?: () => Promise<string | undefined>;\n\t/**\n\t * Returns the absolute path to `info/exclude`, which lives in the COMMON git dir for a linked worktree.\n\t * When provided, replaces the `gitDirPath`-based resolution; undefined means there is none to read.\n\t */\n\treadonly getInfoExcludePath?: () => Promise<string | undefined>;\n\t/**\n\t * Returns the repo-relative, `/`-separated paths of every `.gitignore` git reads (root included).\n\t * Without it, only the root `.gitignore` is honoured.\n\t */\n\treadonly getGitIgnorePaths?: () => Promise<readonly string[]>;\n\t/**\n\t * Returns `core.ignorecase`, which decides whether patterns match case-insensitively. Undefined (or a failed read)\n\t * falls back to the platform default (case-sensitive on Linux only).\n\t */\n\treadonly getIgnoreCase?: () => Promise<boolean | undefined>;\n}\n\n/** What a committed load was built from, which {@link GitIgnoreFilter.revalidate} compares against */\ninterface LoadedSources {\n\treadonly ignoreCase: boolean;\n\treadonly globalExcludesPath: string | undefined;\n\treadonly infoExcludePath: string | undefined;\n\t/** Every ignore file the load read, by absolute path, with its {@link GitIgnoreFilter.stamp} taken before the read */\n\treadonly stamps: ReadonlyMap<string, string | undefined>;\n}\n\n/**\n * In-memory gitignore filter using the `ignore` npm package.\n * Fully library-owned — no VS Code dependencies.\n *\n * Loads patterns eagerly on creation, in git's precedence order (lowest first):\n * 1. Global excludes file (`core.excludesFile`)\n * 2. `info/exclude`\n * 3. `<repoPath>/.gitignore`\n * 4. Nested `.gitignore` files (via `getGitIgnorePaths`), deeper overriding shallower\n *\n * Once loaded, all checks are **synchronous** for maximum performance.\n * Call `ready()` before first use to ensure patterns are loaded.\n */\nexport class GitIgnoreFilter {\n\tprivate ig: Ignore = ignore({ ignorecase: defaultIgnoreCase });\n\t/** Matchers for nested `.gitignore` files, keyed by their repo-relative directory (no trailing slash) */\n\tprivate nested: Map<string, Ignore> | undefined;\n\t/** The newest load, which {@link ready} waits for; cleared once it settles */\n\tprivate loading: Promise<void> | undefined;\n\t/** The load running now; at most one runs at a time */\n\tprivate inflight: Promise<void> | undefined;\n\t/** The one load queued behind {@link inflight}, which every refresh made meanwhile shares */\n\tprivate trailing: Promise<void> | undefined;\n\t/** The running {@link revalidate}, which {@link ready} also waits for */\n\tprivate revalidating: Promise<boolean> | undefined;\n\tprivate sources: LoadedSources | undefined;\n\tprivate readonly _generation = getScopedCounter();\n\n\t// Reused across `isIgnored` calls (which are synchronous, so never interleave) to avoid per-event allocations\n\tprivate readonly _scratchMatchers: Ignore[] = [];\n\tprivate readonly _scratchBases: number[] = [];\n\n\tprivate readonly repoPath: string;\n\tprivate readonly gitDirPath: string;\n\tprivate readonly fs: FileSystemProvider;\n\tprivate readonly getGlobalExcludesPath?: () => Promise<string | undefined>;\n\tprivate readonly getInfoExcludePath?: () => Promise<string | undefined>;\n\tprivate readonly getGitIgnorePaths?: () => Promise<readonly string[]>;\n\tprivate readonly getIgnoreCase?: () => Promise<boolean | undefined>;\n\n\tconstructor(options: GitIgnoreFilterOptions) {\n\t\tthis.repoPath = options.repoPath;\n\t\tthis.gitDirPath = options.gitDirPath;\n\t\tthis.fs = options.fs;\n\t\tthis.getGlobalExcludesPath = options.getGlobalExcludesPath;\n\t\tthis.getInfoExcludePath = options.getInfoExcludePath;\n\t\tthis.getGitIgnorePaths = options.getGitIgnorePaths;\n\t\tthis.getIgnoreCase = options.getIgnoreCase;\n\n\t\t// Start loading immediately\n\t\tvoid this.startLoad();\n\t}\n\n\t/** Resolves when patterns are loaded and any {@link revalidate} has settled. Safe to call multiple times. */\n\tasync ready(): Promise<void> {\n\t\tif (this.revalidating != null) {\n\t\t\tawait this.revalidating;\n\t\t}\n\t\t// Read after the revalidation: a refresh made during it supersedes it\n\t\tif (this.loading != null) {\n\t\t\tawait this.loading;\n\t\t}\n\t}\n\n\t/**\n\t * Check if a path is ignored. Must be called after `ready()`.\n\t * Errs toward \"not ignored\": a false \"ignored\" drops a real change, a false \"not ignored\" only costs a refresh.\n\t * @param relativePath Path relative to the repository root (forward slashes; a trailing slash marks a directory)\n\t * @returns true if the path should be ignored\n\t */\n\tisIgnored(relativePath: string): boolean {\n\t\tif (!relativePath) return false;\n\n\t\ttry {\n\t\t\tif (this.nested == null) return this.ig.ignores(relativePath);\n\n\t\t\treturn this.isIgnoredNested(relativePath, this.nested);\n\t\t} catch {\n\t\t\t// `ignore` can throw on edge-case paths\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Filter an array of relative paths, returning only non-ignored ones.\n\t * Must be called after `ready()`.\n\t */\n\tfilter(relativePaths: readonly string[]): string[] {\n\t\treturn relativePaths.filter(p => !this.isIgnored(p));\n\t}\n\n\t/**\n\t * Reload all patterns (e.g., after a .gitignore or info/exclude changes), rediscovering nested `.gitignore` files.\n\t * Returns a promise that resolves when a reload started after this call is complete.\n\t *\n\t * Single-flight: an idle filter reloads at once, but while a reload runs, every further call shares one reload\n\t * queued behind it — a checkout touching many `.gitignore` files costs two reloads, not one per file.\n\t */\n\trefresh(): Promise<void> {\n\t\tif (this.inflight == null) return this.startLoad();\n\n\t\tif (this.trailing == null) {\n\t\t\tconst run = (): Promise<void> => {\n\t\t\t\tthis.trailing = undefined;\n\t\t\t\treturn this.startLoad();\n\t\t\t};\n\t\t\tthis.trailing = this.inflight.then(run, run);\n\t\t}\n\t\tthis.loading = this.trailing;\n\t\treturn this.trailing;\n\t}\n\n\t/**\n\t * Reloads when an ignore source changed since the last load, for a caller that stopped watching them for a while.\n\t * Resolves true once that reload has committed; false when nothing changed, when no load has committed yet, or when\n\t * a load is running, queued, or started meanwhile (it reads the sources afresh).\n\t *\n\t * Only the sources the last load read are stat'ed — the nested list isn't rediscovered, which would cost a git\n\t * spawn — so a nested `.gitignore` created since then goes unseen until the next {@link refresh}.\n\t */\n\trevalidate(): Promise<boolean> {\n\t\tif (this.revalidating != null) return this.revalidating;\n\n\t\tconst sources = this.sources;\n\t\tif (sources == null || this.loading != null) return Promise.resolve(false);\n\n\t\tconst generation = this._generation.current;\n\t\tconst revalidation: Promise<boolean> = this.sourcesChanged(sources)\n\t\t\t.then(async changed => {\n\t\t\t\tif (!changed || this._generation.current !== generation) return false;\n\n\t\t\t\tawait this.refresh();\n\t\t\t\treturn true;\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\tif (this.revalidating === revalidation) {\n\t\t\t\t\tthis.revalidating = undefined;\n\t\t\t\t}\n\t\t\t});\n\t\tthis.revalidating = revalidation;\n\t\treturn revalidation;\n\t}\n\n\tprivate startLoad(): Promise<void> {\n\t\tconst load: Promise<void> = this.loadPatterns().finally(() => {\n\t\t\tif (this.inflight === load) {\n\t\t\t\tthis.inflight = undefined;\n\t\t\t}\n\t\t\tif (this.loading === load) {\n\t\t\t\tthis.loading = undefined;\n\t\t\t}\n\t\t});\n\t\tthis.inflight = load;\n\t\tthis.loading = load;\n\t\treturn load;\n\t}\n\n\t/**\n\t * Mirrors git's directory walk: each ancestor directory is checked shallow→deep, and the first one found ignored\n\t * ignores the whole path (git never descends into it, so nothing below can re-include it). At each level, the\n\t * matchers whose directory is a proper ancestor apply, and the deepest decisive one wins, falling back to the root.\n\t */\n\tprivate isIgnoredNested(path: string, nested: Map<string, Ignore>): boolean {\n\t\tconst matchers = this._scratchMatchers;\n\t\tconst bases = this._scratchBases;\n\n\t\ttry {\n\t\t\t// A trailing slash belongs to the path itself (a directory form), not to an ancestor\n\t\t\tconst last = path.length - 1;\n\n\t\t\tlet slash = path.indexOf('/');\n\t\t\twhile (slash !== -1 && slash < last) {\n\t\t\t\tif (this.isLevelIgnored(path, slash + 1, matchers, bases)) return true;\n\n\t\t\t\t// A directory's own `.gitignore` applies below it, never to the directory itself\n\t\t\t\tconst matcher = nested.get(path.slice(0, slash));\n\t\t\t\tif (matcher != null) {\n\t\t\t\t\tmatchers.push(matcher);\n\t\t\t\t\tbases.push(slash + 1);\n\t\t\t\t}\n\n\t\t\t\tslash = path.indexOf('/', slash + 1);\n\t\t\t}\n\n\t\t\treturn this.isLevelIgnored(path, path.length, matchers, bases);\n\t\t} finally {\n\t\t\tmatchers.length = 0;\n\t\t\tbases.length = 0;\n\t\t}\n\t}\n\n\t/** Whether `path.slice(0, end)` is ignored, given its ancestors aren't */\n\tprivate isLevelIgnored(path: string, end: number, matchers: readonly Ignore[], bases: readonly number[]): boolean {\n\t\tfor (let i = matchers.length - 1; i >= 0; i--) {\n\t\t\tconst verdict = this.testLevel(matchers[i], path.slice(bases[i], end));\n\t\t\tif (verdict != null) return verdict;\n\t\t}\n\n\t\treturn this.testLevel(this.ig, path.slice(0, end)) ?? false;\n\t}\n\n\t/** Returns the matcher's decisive verdict for `path`, or undefined when it has none */\n\tprivate testLevel(matcher: Ignore, path: string): boolean | undefined {\n\t\tconst result = matcher.test(path);\n\t\tif (result.unignored) return false;\n\t\tif (!result.ignored) return undefined;\n\n\t\t// `ignore` folds its own verdict for each ancestor into a path's result: once the matcher considers a parent\n\t\t// ignored, every child reports that parent's result. Reaching here means a deeper matcher re-included that\n\t\t// parent, so this result says nothing about the path itself — the matcher's own rules are unknowable, so\n\t\t// answer \"not ignored\" rather than risk dropping a real change.\n\t\tconst parentEnd = path.lastIndexOf('/', path.length - 2);\n\t\tif (parentEnd !== -1 && matcher.test(path.slice(0, parentEnd + 1)).ignored) return false;\n\n\t\treturn true;\n\t}\n\n\tprivate async loadPatterns(): Promise<void> {\n\t\tconst id = this._generation.next();\n\t\tconst stamps = new Map<string, string | undefined>();\n\n\t\tconst globalExcludesPath = this.resolveGlobalExcludesPath();\n\t\tconst infoExcludePath = this.resolveInfoExcludePath();\n\t\tconst [globalResult, infoResult, rootResult, nestedResult, ignoreCaseResult] = await Promise.allSettled([\n\t\t\tglobalExcludesPath.then(path => this.readSource(path, stamps)),\n\t\t\tinfoExcludePath.then(path => this.readSource(path, stamps)),\n\t\t\tthis.readSource(`${this.repoPath}/.gitignore`, stamps),\n\t\t\tthis.loadNested(stamps),\n\t\t\tthis.readIgnoreCase(),\n\t\t]);\n\t\tconst [globalPathResult, infoPathResult] = await Promise.allSettled([globalExcludesPath, infoExcludePath]);\n\n\t\t// Only commit results if no newer refresh has started\n\t\tif (id !== this._generation.current) return;\n\n\t\tconst options = { ignorecase: getSettledValue(ignoreCaseResult) ?? defaultIgnoreCase };\n\n\t\t// Added in git's precedence order (lowest first), since the last matching pattern wins\n\t\tconst ig = ignore(options);\n\t\tfor (const content of [\n\t\t\tgetSettledValue(globalResult),\n\t\t\tgetSettledValue(infoResult),\n\t\t\tgetSettledValue(rootResult),\n\t\t]) {\n\t\t\tif (!content) continue;\n\n\t\t\ttry {\n\t\t\t\tig.add(content);\n\t\t\t} catch {\n\t\t\t\t// A source `ignore` can't parse is skipped rather than failing the whole load\n\t\t\t}\n\t\t}\n\n\t\tlet nested: Map<string, Ignore> | undefined;\n\t\tconst nestedContents = getSettledValue(nestedResult);\n\t\tif (nestedContents?.size) {\n\t\t\tnested = new Map();\n\t\t\tfor (const [dir, content] of nestedContents) {\n\t\t\t\ttry {\n\t\t\t\t\tnested.set(dir, ignore(options).add(content));\n\t\t\t\t} catch {\n\t\t\t\t\t// A file `ignore` can't parse is skipped rather than failing the whole load\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.ig = ig;\n\t\tthis.nested = nested?.size ? nested : undefined;\n\t\tthis.sources = {\n\t\t\tignoreCase: options.ignorecase,\n\t\t\tglobalExcludesPath: getSettledValue(globalPathResult),\n\t\t\tinfoExcludePath: getSettledValue(infoPathResult),\n\t\t\tstamps: stamps,\n\t\t};\n\t}\n\n\t/** Whether anything {@link loadPatterns} built `sources` from differs now; a source that can't be stat'ed has */\n\tprivate async sourcesChanged(sources: LoadedSources): Promise<boolean> {\n\t\tconst [globalExcludesPath, infoExcludePath, ignoreCase, unchanged] = await Promise.allSettled([\n\t\t\tthis.resolveGlobalExcludesPath(),\n\t\t\tthis.resolveInfoExcludePath(),\n\t\t\tthis.readIgnoreCase(),\n\t\t\tPromise.allSettled(\n\t\t\t\tArray.from(\n\t\t\t\t\tsources.stamps,\n\t\t\t\t\tasync ([path, stamp]) => stamp != null && stamp === (await this.stamp(path)),\n\t\t\t\t),\n\t\t\t),\n\t\t]);\n\n\t\treturn (\n\t\t\tgetSettledValue(globalExcludesPath) !== sources.globalExcludesPath ||\n\t\t\tgetSettledValue(infoExcludePath) !== sources.infoExcludePath ||\n\t\t\t(getSettledValue(ignoreCase) ?? defaultIgnoreCase) !== sources.ignoreCase ||\n\t\t\tgetSettledValue(unchanged)?.every(r => getSettledValue(r) === true) !== true\n\t\t);\n\t}\n\n\t/** Reads every nested `.gitignore`, keyed by its repo-relative directory (no trailing slash) */\n\tprivate async loadNested(stamps: Map<string, string | undefined>): Promise<Map<string, string> | undefined> {\n\t\tif (this.getGitIgnorePaths == null) return undefined;\n\n\t\tlet paths: readonly string[];\n\t\ttry {\n\t\t\tpaths = await this.getGitIgnorePaths();\n\t\t} catch {\n\t\t\t// Discovery failed — fall back to the root `.gitignore` alone\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst suffix = '/.gitignore';\n\t\tconst dirs = new Set<string>();\n\t\tfor (const path of paths) {\n\t\t\t// The root `.gitignore` (no directory) is loaded with the other root sources\n\t\t\tif (path.length <= suffix.length || !path.endsWith(suffix)) continue;\n\n\t\t\tdirs.add(path.slice(0, -suffix.length));\n\t\t}\n\t\tif (!dirs.size) return undefined;\n\n\t\tconst entries = await Promise.allSettled(\n\t\t\tArray.from(dirs, async dir => {\n\t\t\t\tconst content = await this.readSource(`${this.repoPath}/${dir}${suffix}`, stamps);\n\t\t\t\treturn content ? ([dir, content] as const) : undefined;\n\t\t\t}),\n\t\t);\n\n\t\tconst nested = new Map<string, string>();\n\t\tfor (const entry of entries) {\n\t\t\tconst value = getSettledValue(entry);\n\t\t\tif (value != null) {\n\t\t\t\tnested.set(value[0], value[1]);\n\t\t\t}\n\t\t}\n\t\treturn nested;\n\t}\n\n\t/** Stamps an ignore file, then reads it — stamped first, so an edit landing in between reads as a change later */\n\tprivate async readSource(\n\t\tpath: string | undefined,\n\t\tstamps: Map<string, string | undefined>,\n\t): Promise<string | undefined> {\n\t\tif (path == null) return undefined;\n\n\t\tstamps.set(path, await this.stamp(path));\n\t\treturn this.readFile(path);\n\t}\n\n\t/** `mtime:size`, `''` when the file is absent, or undefined when it can't be stat'ed */\n\tprivate async stamp(path: string): Promise<string | undefined> {\n\t\ttry {\n\t\t\tconst stat = await this.fs.stat(fileUri(path));\n\t\t\treturn stat != null ? `${stat.mtime}:${stat.size}` : '';\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate async readFile(path: string): Promise<string | undefined> {\n\t\ttry {\n\t\t\tconst data = await this.fs.readFile(fileUri(path));\n\t\t\treturn new TextDecoder().decode(data);\n\t\t} catch {\n\t\t\t// File might not exist or be unreadable — that's fine\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate async resolveInfoExcludePath(): Promise<string | undefined> {\n\t\tif (this.getInfoExcludePath == null) return `${this.gitDirPath}/info/exclude`;\n\n\t\ttry {\n\t\t\treturn await this.getInfoExcludePath();\n\t\t} catch {\n\t\t\t// The git dir couldn't be resolved\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate async readIgnoreCase(): Promise<boolean | undefined> {\n\t\tif (this.getIgnoreCase == null) return undefined;\n\n\t\ttry {\n\t\t\treturn await this.getIgnoreCase();\n\t\t} catch {\n\t\t\t// Unreadable — the platform default applies\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate async resolveGlobalExcludesPath(): Promise<string | undefined> {\n\t\tif (this.getGlobalExcludesPath == null) return undefined;\n\n\t\ttry {\n\t\t\treturn await this.getGlobalExcludesPath();\n\t\t} catch {\n\t\t\t// Global excludes might not be configured\n\t\t\treturn undefined;\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;AAaA,MAAM,oBAAoB,CAAC;;;;;;;;;;;;;;AAqD3B,IAAa,kBAAb,MAA6B;CAC5B,KAAqB,OAAO,EAAE,YAAY,kBAAkB,CAAC;;CAE7D;;CAEA;;CAEA;;CAEA;;CAEA;C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,IAAI,KAAK,iBAAiB,MAAM,OAAO,KAAA;EAEvC,IAAI;GACH,OAAO,MAAM,KAAK,cAAc;EACjC,QAAQ;GAEP;EACD;CACD;CAEA,MAAc,4BAAyD;EACtE,IAAI,KAAK,yBAAyB,MAAM,OAAO,KAAA;EAE/C,IAAI;GACH,OAAO,MAAM,KAAK,sBAAsB;EACzC,QAAQ;GAEP;EACD;CACD;AACD"}
1
+ {"version":3,"file":"gitIgnoreFilter.js","names":[],"sources":["../../../../git/src/watching/gitIgnoreFilter.ts"],"sourcesContent":["import type { Ignore } from 'ignore';\nimport ignore from 'ignore';\nimport { getScopedCounter } from '@gitlens/utils/counter.js';\nimport { isLinux } from '@gitlens/utils/platform.js';\nimport { getSettledValue } from '@gitlens/utils/promise.js';\nimport { fileUri } from '@gitlens/utils/uri.js';\nimport type { FileSystemProvider } from '../context.js';\n\n/**\n * Case sensitivity when `core.ignorecase` is unset or unreadable. `ignore` matches case-insensitively by default, but\n * git follows `core.ignorecase` — false on Linux (and on a case-sensitive macOS volume), where matching `Build/`\n * against `build/` would call a real change ignored and drop it.\n */\nconst defaultIgnoreCase = !isLinux;\n\ninterface IgnoreFilterConfig {\n\treadonly globalExcludesPath?: string;\n\treadonly ignoreCase?: boolean;\n}\n\nexport interface GitIgnoreFilterOptions {\n\t/** Absolute path to the repository root (working tree) */\n\treadonly repoPath: string;\n\t/** Absolute path to the .git directory (for info/exclude when `getInfoExcludePath` isn't provided) */\n\treadonly gitDirPath: string;\n\t/** File system provider for reading ignore files */\n\treadonly fs: FileSystemProvider;\n\t/**\n\t * Returns the path to the global excludes file (core.excludesFile).\n\t * May return undefined if not configured.\n\t */\n\treadonly getGlobalExcludesPath?: () => Promise<string | undefined>;\n\treadonly getConfig?: () => Promise<IgnoreFilterConfig>;\n\treadonly invalidateConfig?: () => void;\n\t/**\n\t * Returns the absolute path to `info/exclude`, which lives in the COMMON git dir for a linked worktree.\n\t * When provided, replaces the `gitDirPath`-based resolution; undefined means there is none to read.\n\t */\n\treadonly getInfoExcludePath?: () => Promise<string | undefined>;\n\t/**\n\t * Returns the repo-relative, `/`-separated paths of every `.gitignore` git reads (root included).\n\t * Without it, only the root `.gitignore` is honoured.\n\t */\n\treadonly getGitIgnorePaths?: () => Promise<readonly string[]>;\n\t/**\n\t * Returns `core.ignorecase`, which decides whether patterns match case-insensitively. Undefined (or a failed read)\n\t * falls back to the platform default (case-sensitive on Linux only).\n\t */\n\treadonly getIgnoreCase?: () => Promise<boolean | undefined>;\n}\n\n/** What a committed load was built from, which {@link GitIgnoreFilter.revalidate} compares against */\ninterface LoadedSources {\n\treadonly ignoreCase: boolean;\n\treadonly globalExcludesPath: string | undefined;\n\treadonly infoExcludePath: string | undefined;\n\t/** Every ignore file the load read, by absolute path, with its {@link GitIgnoreFilter.stamp} taken before the read */\n\treadonly stamps: ReadonlyMap<string, string | undefined>;\n}\n\n/**\n * In-memory gitignore filter using the `ignore` npm package.\n * Fully library-owned — no VS Code dependencies.\n *\n * Loads patterns eagerly on creation, in git's precedence order (lowest first):\n * 1. Global excludes file (`core.excludesFile`)\n * 2. `info/exclude`\n * 3. `<repoPath>/.gitignore`\n * 4. Nested `.gitignore` files (via `getGitIgnorePaths`), deeper overriding shallower\n *\n * Once loaded, all checks are **synchronous** for maximum performance.\n * Call `ready()` before first use to ensure patterns are loaded.\n */\nexport class GitIgnoreFilter {\n\tprivate ig: Ignore = ignore({ ignorecase: defaultIgnoreCase });\n\t/** Matchers for nested `.gitignore` files, keyed by their repo-relative directory (no trailing slash) */\n\tprivate nested: Map<string, Ignore> | undefined;\n\t/** The newest load, which {@link ready} waits for; cleared once it settles */\n\tprivate loading: Promise<void> | undefined;\n\t/** The load running now; at most one runs at a time */\n\tprivate inflight: Promise<void> | undefined;\n\t/** The one load queued behind {@link inflight}, which every refresh made meanwhile shares */\n\tprivate trailing: Promise<void> | undefined;\n\t/** The running {@link revalidate}, which {@link ready} also waits for */\n\tprivate revalidating: Promise<boolean> | undefined;\n\tprivate sources: LoadedSources | undefined;\n\tprivate readonly _generation = getScopedCounter();\n\n\t// Reused across `isIgnored` calls (which are synchronous, so never interleave) to avoid per-event allocations\n\tprivate readonly _scratchMatchers: Ignore[] = [];\n\tprivate readonly _scratchBases: number[] = [];\n\n\tprivate readonly repoPath: string;\n\tprivate readonly gitDirPath: string;\n\tprivate readonly fs: FileSystemProvider;\n\tprivate readonly getConfig: () => Promise<IgnoreFilterConfig>;\n\tprivate readonly invalidateConfig?: () => void;\n\tprivate readonly getInfoExcludePath?: () => Promise<string | undefined>;\n\tprivate readonly getGitIgnorePaths?: () => Promise<readonly string[]>;\n\n\tget canInvalidateConfig(): boolean {\n\t\treturn this.invalidateConfig != null;\n\t}\n\n\tconstructor(options: GitIgnoreFilterOptions) {\n\t\tthis.repoPath = options.repoPath;\n\t\tthis.gitDirPath = options.gitDirPath;\n\t\tthis.fs = options.fs;\n\t\tthis.getConfig = async () => {\n\t\t\tif (options.getConfig != null) return options.getConfig();\n\n\t\t\tconst [path, ignoreCase] = await Promise.allSettled([\n\t\t\t\tPromise.resolve().then(() => options.getGlobalExcludesPath?.()),\n\t\t\t\tPromise.resolve().then(() => options.getIgnoreCase?.()),\n\t\t\t]);\n\t\t\treturn { globalExcludesPath: getSettledValue(path), ignoreCase: getSettledValue(ignoreCase) };\n\t\t};\n\t\tthis.invalidateConfig = options.invalidateConfig;\n\t\tthis.getInfoExcludePath = options.getInfoExcludePath;\n\t\tthis.getGitIgnorePaths = options.getGitIgnorePaths;\n\n\t\t// Start loading immediately\n\t\tvoid this.startLoad();\n\t}\n\n\t/** Resolves when patterns are loaded and any {@link revalidate} has settled. Safe to call multiple times. */\n\tasync ready(): Promise<void> {\n\t\tif (this.revalidating != null) {\n\t\t\tawait this.revalidating;\n\t\t}\n\t\t// Read after the revalidation: a refresh made during it supersedes it\n\t\tif (this.loading != null) {\n\t\t\tawait this.loading;\n\t\t}\n\t}\n\n\t/**\n\t * Check if a path is ignored. Must be called after `ready()`.\n\t * Errs toward \"not ignored\": a false \"ignored\" drops a real change, a false \"not ignored\" only costs a refresh.\n\t * @param relativePath Path relative to the repository root (forward slashes; a trailing slash marks a directory)\n\t * @returns true if the path should be ignored\n\t */\n\tisIgnored(relativePath: string): boolean {\n\t\tif (!relativePath) return false;\n\n\t\ttry {\n\t\t\tif (this.nested == null) return this.ig.ignores(relativePath);\n\n\t\t\treturn this.isIgnoredNested(relativePath, this.nested);\n\t\t} catch {\n\t\t\t// `ignore` can throw on edge-case paths\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Filter an array of relative paths, returning only non-ignored ones.\n\t * Must be called after `ready()`.\n\t */\n\tfilter(relativePaths: readonly string[]): string[] {\n\t\treturn relativePaths.filter(p => !this.isIgnored(p));\n\t}\n\n\t/**\n\t * Reload all patterns (e.g., after a .gitignore or info/exclude changes), rediscovering nested `.gitignore` files.\n\t * Returns a promise that resolves when a reload started after this call is complete.\n\t *\n\t * Single-flight: an idle filter reloads at once, but while a reload runs, every further call shares one reload\n\t * queued behind it — a checkout touching many `.gitignore` files costs two reloads, not one per file.\n\t */\n\trefresh(options?: { configChanged?: boolean }): Promise<void> {\n\t\tif (options?.configChanged) {\n\t\t\tthis.invalidateConfig?.();\n\t\t}\n\t\tif (this.inflight == null) return this.startLoad();\n\n\t\tif (this.trailing == null) {\n\t\t\tconst run = (): Promise<void> => {\n\t\t\t\tthis.trailing = undefined;\n\t\t\t\treturn this.startLoad();\n\t\t\t};\n\t\t\tthis.trailing = this.inflight.then(run, run);\n\t\t}\n\t\tthis.loading = this.trailing;\n\t\treturn this.trailing;\n\t}\n\n\t/**\n\t * Reloads when an ignore source changed since the last load, for a caller that stopped watching them for a while.\n\t * Resolves true once that reload has committed; false when nothing changed, when no load has committed yet, or when\n\t * a load is running, queued, or started meanwhile (it reads the sources afresh).\n\t *\n\t * Only the sources the last load read are stat'ed — the nested list isn't rediscovered, which would cost a git\n\t * spawn — so a nested `.gitignore` created since then goes unseen until the next {@link refresh}.\n\t */\n\trevalidate(): Promise<boolean> {\n\t\tif (this.revalidating != null) return this.revalidating;\n\n\t\tconst sources = this.sources;\n\t\tif (sources == null || this.loading != null) return Promise.resolve(false);\n\n\t\tconst generation = this._generation.current;\n\t\tconst revalidation: Promise<boolean> = this.sourcesChanged(sources)\n\t\t\t.then(async changed => {\n\t\t\t\tif (!changed || this._generation.current !== generation) return false;\n\n\t\t\t\tawait this.refresh();\n\t\t\t\treturn true;\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\tif (this.revalidating === revalidation) {\n\t\t\t\t\tthis.revalidating = undefined;\n\t\t\t\t}\n\t\t\t});\n\t\tthis.revalidating = revalidation;\n\t\treturn revalidation;\n\t}\n\n\tprivate startLoad(): Promise<void> {\n\t\tconst load: Promise<void> = this.loadPatterns().finally(() => {\n\t\t\tif (this.inflight === load) {\n\t\t\t\tthis.inflight = undefined;\n\t\t\t}\n\t\t\tif (this.loading === load) {\n\t\t\t\tthis.loading = undefined;\n\t\t\t}\n\t\t});\n\t\tthis.inflight = load;\n\t\tthis.loading = load;\n\t\treturn load;\n\t}\n\n\t/**\n\t * Mirrors git's directory walk: each ancestor directory is checked shallow→deep, and the first one found ignored\n\t * ignores the whole path (git never descends into it, so nothing below can re-include it). At each level, the\n\t * matchers whose directory is a proper ancestor apply, and the deepest decisive one wins, falling back to the root.\n\t */\n\tprivate isIgnoredNested(path: string, nested: Map<string, Ignore>): boolean {\n\t\tconst matchers = this._scratchMatchers;\n\t\tconst bases = this._scratchBases;\n\n\t\ttry {\n\t\t\t// A trailing slash belongs to the path itself (a directory form), not to an ancestor\n\t\t\tconst last = path.length - 1;\n\n\t\t\tlet slash = path.indexOf('/');\n\t\t\twhile (slash !== -1 && slash < last) {\n\t\t\t\tif (this.isLevelIgnored(path, slash + 1, matchers, bases)) return true;\n\n\t\t\t\t// A directory's own `.gitignore` applies below it, never to the directory itself\n\t\t\t\tconst matcher = nested.get(path.slice(0, slash));\n\t\t\t\tif (matcher != null) {\n\t\t\t\t\tmatchers.push(matcher);\n\t\t\t\t\tbases.push(slash + 1);\n\t\t\t\t}\n\n\t\t\t\tslash = path.indexOf('/', slash + 1);\n\t\t\t}\n\n\t\t\treturn this.isLevelIgnored(path, path.length, matchers, bases);\n\t\t} finally {\n\t\t\tmatchers.length = 0;\n\t\t\tbases.length = 0;\n\t\t}\n\t}\n\n\t/** Whether `path.slice(0, end)` is ignored, given its ancestors aren't */\n\tprivate isLevelIgnored(path: string, end: number, matchers: readonly Ignore[], bases: readonly number[]): boolean {\n\t\tfor (let i = matchers.length - 1; i >= 0; i--) {\n\t\t\tconst verdict = this.testLevel(matchers[i], path.slice(bases[i], end));\n\t\t\tif (verdict != null) return verdict;\n\t\t}\n\n\t\treturn this.testLevel(this.ig, path.slice(0, end)) ?? false;\n\t}\n\n\t/** Returns the matcher's decisive verdict for `path`, or undefined when it has none */\n\tprivate testLevel(matcher: Ignore, path: string): boolean | undefined {\n\t\tconst result = matcher.test(path);\n\t\tif (result.unignored) return false;\n\t\tif (!result.ignored) return undefined;\n\n\t\t// `ignore` folds its own verdict for each ancestor into a path's result: once the matcher considers a parent\n\t\t// ignored, every child reports that parent's result. Reaching here means a deeper matcher re-included that\n\t\t// parent, so this result says nothing about the path itself — the matcher's own rules are unknowable, so\n\t\t// answer \"not ignored\" rather than risk dropping a real change.\n\t\tconst parentEnd = path.lastIndexOf('/', path.length - 2);\n\t\tif (parentEnd !== -1 && matcher.test(path.slice(0, parentEnd + 1)).ignored) return false;\n\n\t\treturn true;\n\t}\n\n\tprivate async loadPatterns(): Promise<void> {\n\t\tconst id = this._generation.next();\n\t\tconst stamps = new Map<string, string | undefined>();\n\n\t\tconst config = this.getConfig();\n\t\tconst infoExcludePath = this.resolveInfoExcludePath();\n\t\tconst [globalResult, infoResult, rootResult, nestedResult, configResult, infoPathResult] =\n\t\t\tawait Promise.allSettled([\n\t\t\t\tconfig.then(({ globalExcludesPath }) => this.readSource(globalExcludesPath, stamps)),\n\t\t\t\tinfoExcludePath.then(path => this.readSource(path, stamps)),\n\t\t\t\tthis.readSource(`${this.repoPath}/.gitignore`, stamps),\n\t\t\t\tthis.loadNested(stamps),\n\t\t\t\tconfig,\n\t\t\t\tinfoExcludePath,\n\t\t\t]);\n\n\t\t// Only commit results if no newer refresh has started\n\t\tif (id !== this._generation.current) return;\n\n\t\tconst options = { ignorecase: getSettledValue(configResult)?.ignoreCase ?? defaultIgnoreCase };\n\n\t\t// Added in git's precedence order (lowest first), since the last matching pattern wins\n\t\tconst ig = ignore(options);\n\t\tfor (const content of [\n\t\t\tgetSettledValue(globalResult),\n\t\t\tgetSettledValue(infoResult),\n\t\t\tgetSettledValue(rootResult),\n\t\t]) {\n\t\t\tif (!content) continue;\n\n\t\t\ttry {\n\t\t\t\tig.add(content);\n\t\t\t} catch {\n\t\t\t\t// A source `ignore` can't parse is skipped rather than failing the whole load\n\t\t\t}\n\t\t}\n\n\t\tlet nested: Map<string, Ignore> | undefined;\n\t\tconst nestedContents = getSettledValue(nestedResult);\n\t\tif (nestedContents?.size) {\n\t\t\tnested = new Map();\n\t\t\tfor (const [dir, content] of nestedContents) {\n\t\t\t\ttry {\n\t\t\t\t\tnested.set(dir, ignore(options).add(content));\n\t\t\t\t} catch {\n\t\t\t\t\t// A file `ignore` can't parse is skipped rather than failing the whole load\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.ig = ig;\n\t\tthis.nested = nested?.size ? nested : undefined;\n\t\tthis.sources = {\n\t\t\tignoreCase: options.ignorecase,\n\t\t\tglobalExcludesPath: getSettledValue(configResult)?.globalExcludesPath,\n\t\t\tinfoExcludePath: getSettledValue(infoPathResult),\n\t\t\tstamps: stamps,\n\t\t};\n\t}\n\n\t/** Whether anything {@link loadPatterns} built `sources` from differs now; a source that can't be stat'ed has */\n\tprivate async sourcesChanged(sources: LoadedSources): Promise<boolean> {\n\t\tconst [config, infoExcludePath, unchanged] = await Promise.allSettled([\n\t\t\tthis.getConfig(),\n\t\t\tthis.resolveInfoExcludePath(),\n\t\t\tPromise.allSettled(\n\t\t\t\tArray.from(\n\t\t\t\t\tsources.stamps,\n\t\t\t\t\tasync ([path, stamp]) => stamp != null && stamp === (await this.stamp(path)),\n\t\t\t\t),\n\t\t\t),\n\t\t]);\n\n\t\treturn (\n\t\t\tgetSettledValue(config)?.globalExcludesPath !== sources.globalExcludesPath ||\n\t\t\tgetSettledValue(infoExcludePath) !== sources.infoExcludePath ||\n\t\t\t(getSettledValue(config)?.ignoreCase ?? defaultIgnoreCase) !== sources.ignoreCase ||\n\t\t\tgetSettledValue(unchanged)?.every(r => getSettledValue(r) === true) !== true\n\t\t);\n\t}\n\n\t/** Reads every nested `.gitignore`, keyed by its repo-relative directory (no trailing slash) */\n\tprivate async loadNested(stamps: Map<string, string | undefined>): Promise<Map<string, string> | undefined> {\n\t\tif (this.getGitIgnorePaths == null) return undefined;\n\n\t\tlet paths: readonly string[];\n\t\ttry {\n\t\t\tpaths = await this.getGitIgnorePaths();\n\t\t} catch {\n\t\t\t// Discovery failed — fall back to the root `.gitignore` alone\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst suffix = '/.gitignore';\n\t\tconst dirs = new Set<string>();\n\t\tfor (const path of paths) {\n\t\t\t// The root `.gitignore` (no directory) is loaded with the other root sources\n\t\t\tif (path.length <= suffix.length || !path.endsWith(suffix)) continue;\n\n\t\t\tdirs.add(path.slice(0, -suffix.length));\n\t\t}\n\t\tif (!dirs.size) return undefined;\n\n\t\tconst entries = await Promise.allSettled(\n\t\t\tArray.from(dirs, async dir => {\n\t\t\t\tconst content = await this.readSource(`${this.repoPath}/${dir}${suffix}`, stamps);\n\t\t\t\treturn content ? ([dir, content] as const) : undefined;\n\t\t\t}),\n\t\t);\n\n\t\tconst nested = new Map<string, string>();\n\t\tfor (const entry of entries) {\n\t\t\tconst value = getSettledValue(entry);\n\t\t\tif (value != null) {\n\t\t\t\tnested.set(value[0], value[1]);\n\t\t\t}\n\t\t}\n\t\treturn nested;\n\t}\n\n\t/** Stamps an ignore file, then reads it — stamped first, so an edit landing in between reads as a change later */\n\tprivate async readSource(\n\t\tpath: string | undefined,\n\t\tstamps: Map<string, string | undefined>,\n\t): Promise<string | undefined> {\n\t\tif (path == null) return undefined;\n\n\t\tstamps.set(path, await this.stamp(path));\n\t\treturn this.readFile(path);\n\t}\n\n\t/** `mtime:size`, `''` when the file is absent, or undefined when it can't be stat'ed */\n\tprivate async stamp(path: string): Promise<string | undefined> {\n\t\ttry {\n\t\t\tconst stat = await this.fs.stat(fileUri(path));\n\t\t\treturn stat != null ? `${stat.mtime}:${stat.size}` : '';\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate async readFile(path: string): Promise<string | undefined> {\n\t\ttry {\n\t\t\tconst data = await this.fs.readFile(fileUri(path));\n\t\t\treturn new TextDecoder().decode(data);\n\t\t} catch {\n\t\t\t// File might not exist or be unreadable — that's fine\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate async resolveInfoExcludePath(): Promise<string | undefined> {\n\t\tif (this.getInfoExcludePath == null) return `${this.gitDirPath}/info/exclude`;\n\n\t\ttry {\n\t\t\treturn await this.getInfoExcludePath();\n\t\t} catch {\n\t\t\t// The git dir couldn't be resolved\n\t\t\treturn undefined;\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;AAaA,MAAM,oBAAoB,CAAC;;;;;;;;;;;;;;AA4D3B,IAAa,kBAAb,MAA6B;CAC5B,KAAqB,OAAO,EAAE,YAAY,kBAAkB,CAAC;;CAE7D;;CAEA;;CAEA;;CAEA;;CAEA;CACA;CACA,cAA+B,iBAAiB;CAGhD,mBAA8C,CAAC;CAC/C,gBAA2C,CAAC;CAE5C;CACA;CACA;CACA;CACA;CACA;CACA;CAEA,IAAI,sBAA+B;EAClC,OAAO,KAAK,oBAAoB;CACjC;CAEA,YAAY,SAAiC;EAC5C,KAAK,WAAW,QAAQ;EACxB,KAAK,aAAa,QAAQ;EAC1B,KAAK,KAAK,QAAQ;EAClB,KAAK,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M,KAAK,mBAAmB;EACtC,QAAQ;GAEP;EACD;CACD;AACD"}
@@ -23,9 +23,13 @@ export type GitIgnoreRefreshReason = 'initial' | 'worktree' | 'metadata' | 'reco
23
23
  export interface GitIgnoreWatchInputs {
24
24
  readonly infoExcludePath: string;
25
25
  readonly excludesFilePath: string | null;
26
+ /** Absolute system and global Git config candidates, including missing files. An empty array confirms none apply. */
27
+ readonly configWatchPaths?: readonly string[];
26
28
  readonly ignoreCase: boolean;
27
29
  /** Checkout-relative directories, with `/` separators and no trailing slash. Fixed exclusions take precedence. */
28
30
  readonly protectedDirectories: readonly string[];
31
+ /** Literal, slash-separated indexed entries matched by Git ignores, relative to this checkout. Absent for legacy inputs. */
32
+ readonly protectedPaths?: readonly string[];
29
33
  }
30
34
  /** A working-tree watch with provider-managed Git ignore pruning. */
31
35
  export interface GitIgnoringFileWatcher extends FileWatcher {
@@ -57,8 +61,8 @@ export interface FileWatcherOptions {
57
61
  */
58
62
  readonly excludes?: readonly string[];
59
63
  /**
60
- * Reports this watcher's {@link FileWatcherReliability} whenever it changes; passed only when the host opted into
61
- * polling (`WatchServiceOptions.polling`). May be called synchronously inside `createWatcher`, and again later
64
+ * Reports this watcher's {@link FileWatcherReliability} whenever it changes; passed for polling and for working-tree and metadata watches
65
+ * with tracked pruning support. May be called synchronously inside `createWatcher`, and again later
62
66
  * (a watch going down, or coming back). Each watcher reports its own state, so one created on a path that is
63
67
  * already down reports `unwatchable` itself. Going from `unwatchable` to anything else makes core rescan.
64
68
  */
@@ -67,7 +71,7 @@ export interface FileWatcherOptions {
67
71
  * Called once, when a watch the provider places asynchronously goes live: whatever changed under `basePath` between
68
72
  * `createWatcher` and then went unseen, so core rescans. A provider whose watch is live when `createWatcher` returns
69
73
  * needn't call it, unless it declares `callsOnDidStart`: then it calls it inside `createWatcher`, which costs no
70
- * rescan. Passed only to working-tree watchers, whether or not the host opted into polling.
74
+ * rescan. Also passed to metadata watches for providers declaring supportsTrackedGitIgnorePaths.
71
75
  */
72
76
  readonly onDidStart?: () => void;
73
77
  }
@@ -97,6 +101,17 @@ export interface FileWatchingProvider {
97
101
  * set for a provider that can use it.
98
102
  */
99
103
  readonly supportsExcludes?: boolean;
104
+ /**
105
+ * Preserves events for protectedPaths and their ancestors (including renames), subject to fixed exclusions.
106
+ * Honor ignoreCase and literal path characters. Acknowledge each metadata and delegated watch via onDidStart
107
+ * once live, and report each watch’s reliability changes even without polling. Observe configWatchPaths and the
108
+ * effective excludesFilePath across creation, removal and atomic replacement before acknowledging a refresh.
109
+ * Report external source changes via overflow so Core can refresh both rules and tracked paths. Reject a
110
+ * refresh when coverage is incomplete. Report discovered nested `.gitignore` files, including those in moved
111
+ * or imported directories and those discovered lazily, or signal overflow. New rules may already have pruned
112
+ * events before discovery. Core reconciles the checkout after refreshing its protections.
113
+ */
114
+ readonly supportsTrackedGitIgnorePaths?: boolean;
100
115
  /**
101
116
  * True when the provider calls `options.onDidStart` for every working-tree watch once it goes live (unless the watch
102
117
  * reports `unwatchable` first). Core then leaves to that rescan what it would otherwise read at once (a newly
@@ -19,8 +19,9 @@ export interface WatchGroupHooks {
19
19
  * worktree's HEAD may have moved.
20
20
  */
21
21
  readonly onRepoChanged: (repoPath: string, changes: RepositoryChange[], ref?: string | false, overflow?: boolean, configBranches?: ReadonlySet<string>, movedWorktree?: string) => void;
22
+ readonly onMetadataCoverageChanged?: (live: boolean) => void;
22
23
  readonly onFetchHeadChanged?: (repoPath: string) => void;
23
- readonly onIgnoresChanged?: (repoPath: string) => void;
24
+ readonly onIgnoresChanged?: (repoPath: string, overflow?: boolean) => void;
24
25
  /** The refs whose loose files a poll stats for this session, read at each poll */
25
26
  readonly getProbeRefs?: () => Iterable<string>;
26
27
  /** A watcher this session hears through went `unwatchable`, or stopped being it (see {@link WatchGroup.isUnwatchable}) */
@@ -39,6 +40,8 @@ interface SessionEntry {
39
40
  /** For a linked session, its `<n>` in `<common>/worktrees/<n>`; otherwise `undefined` */
40
41
  readonly worktreeId: string | undefined;
41
42
  readonly hooks: WatchGroupHooks;
43
+ metadataLive: boolean;
44
+ coverage: boolean;
42
45
  reliability: FileWatcherReliability;
43
46
  /** Polls in place of (or beside) the root watcher while it isn't `reliable` */
44
47
  target?: GitDirProbeTarget;
@@ -111,6 +114,7 @@ export declare class WatchGroup implements UnifiedDisposable {
111
114
  */
112
115
  private readonly readDirectory?;
113
116
  private readonly _sessions;
117
+ private _commonLive;
114
118
  private _commonWatcher;
115
119
  private _commonReliability;
116
120
  private _commonTarget;
@@ -200,7 +204,8 @@ export declare class WatchGroup implements UnifiedDisposable {
200
204
  private endAllRetiring;
201
205
  private isRetiringTarget;
202
206
  private disposeCommonWatcher;
203
- /** Hosts that didn't opt into polling get exactly the options they always had */
207
+ hasLiveMetadataCoverage(repoPath: string): boolean;
208
+ private updateMetadataCoverage;
204
209
  private getWatcherOptions;
205
210
  /**
206
211
  * The ignored worktrees' folders join the `.git` excludes of a watcher over the common git dir: a tool that keeps its
@@ -89,6 +89,7 @@ var WatchGroup = class {
89
89
  readFile;
90
90
  readDirectory;
91
91
  _sessions = /* @__PURE__ */ new Map();
92
+ _commonLive = false;
92
93
  _commonWatcher;
93
94
  _commonReliability = "reliable";
94
95
  _commonTarget;
@@ -190,6 +191,7 @@ var WatchGroup = class {
190
191
  const rootPattern = isStandard ? dotGitGlobCombined : dotGitGlobRoot;
191
192
  const commonReliability = isStandard ? this.getCommonReliability() : void 0;
192
193
  let entry;
194
+ let metadataLive = false;
193
195
  let initialReliability = "reliable";
194
196
  const rootWatcher = this.provider.createWatcher(gitDir.uri.fsPath, rootPattern, (event) => {
195
197
  if (entry == null) return;
@@ -200,6 +202,12 @@ var WatchGroup = class {
200
202
  }, this.getWatcherOptions(gitDir.uri.fsPath, (state) => {
201
203
  if (entry == null) initialReliability = state;
202
204
  else if (this._sessions.get(repoPath) === entry) this.setRootReliability(entry, state);
205
+ }, (live) => {
206
+ metadataLive = live;
207
+ if (entry != null && this._sessions.get(repoPath) === entry) {
208
+ entry.metadataLive = live;
209
+ this.updateMetadataCoverage();
210
+ }
203
211
  }));
204
212
  const entryGitDirPath = gitDir.uri.fsPath;
205
213
  entry = {
@@ -209,6 +217,8 @@ var WatchGroup = class {
209
217
  coversCommon: isStandard,
210
218
  worktreeId: isStandard ? void 0 : this.getWorktreeId(entryGitDirPath),
211
219
  hooks,
220
+ metadataLive,
221
+ coverage: false,
212
222
  reliability: "reliable"
213
223
  };
214
224
  this._sessions.set(repoPath, entry);
@@ -217,6 +227,7 @@ var WatchGroup = class {
217
227
  this.retireCommonWatcher();
218
228
  this.handOverCommon(commonReliability);
219
229
  } else if (!some(this._sessions.values(), (e) => e.coversCommon)) this.ensureCommonWatcher();
230
+ this.updateMetadataCoverage();
220
231
  }
221
232
  /** Remove a session from this group. Disposes its root watcher. */
222
233
  removeSession(repoPath) {
@@ -236,6 +247,7 @@ var WatchGroup = class {
236
247
  this.disposeCommonWatcher();
237
248
  this.endAllRetiring();
238
249
  } else if (commonReliability != null) this.handOverCommon(commonReliability);
250
+ this.updateMetadataCoverage();
239
251
  }
240
252
  getWorktreeId(gitDirPath) {
241
253
  return getWorktreeAdminId(gitDirPath, this.commonGitDir);
@@ -245,14 +257,22 @@ var WatchGroup = class {
245
257
  if (this._commonWatcher != null || this._disposed) return;
246
258
  let watcher;
247
259
  let initialReliability = "reliable";
260
+ let metadataLive = false;
248
261
  const options = this.getWatcherOptions(this.commonGitDir, (state) => {
249
262
  if (watcher == null) initialReliability = state;
250
263
  else if (this._commonWatcher === watcher) this.setCommonReliability(state);
264
+ }, (live) => {
265
+ metadataLive = live;
266
+ if (watcher != null && this._commonWatcher === watcher) {
267
+ this._commonLive = live;
268
+ this.updateMetadataCoverage();
269
+ }
251
270
  });
252
271
  watcher = this.provider.createWatcher(this.commonGitDir, dotGitGlobCommon, (event) => {
253
272
  if (event.reason !== "overflow") this._commonTarget?.forget(event.path);
254
273
  this.onCommonEvent(event);
255
274
  }, options);
275
+ this._commonLive = metadataLive;
256
276
  this._commonWatcher = watcher;
257
277
  if (initialReliability !== "reliable") {
258
278
  if (handingOver) this.setCommonPolling(initialReliability);
@@ -306,9 +326,37 @@ var WatchGroup = class {
306
326
  this._commonTarget = void 0;
307
327
  }
308
328
  }
309
- /** Hosts that didn't opt into polling get exactly the options they always had */
310
- getWatcherOptions(basePath, onDidChangeReliability) {
329
+ hasLiveMetadataCoverage(repoPath) {
330
+ return this._sessions.get(repoPath)?.coverage === true;
331
+ }
332
+ updateMetadataCoverage() {
333
+ if (!this.provider.supportsTrackedGitIgnorePaths) return;
334
+ const commonLive = this._commonWatcher != null && this._commonLive || some(this._sessions.values(), (entry) => entry.coversCommon && entry.metadataLive);
335
+ for (const entry of this._sessions.values()) {
336
+ const covered = entry.metadataLive && commonLive;
337
+ if (entry.coverage === covered) continue;
338
+ entry.coverage = covered;
339
+ entry.hooks.onMetadataCoverageChanged?.(covered);
340
+ }
341
+ }
342
+ getWatcherOptions(basePath, onDidChangeReliability, onCoverage) {
311
343
  const excludes = this.getExcludes(basePath);
344
+ if (this.provider.supportsTrackedGitIgnorePaths) {
345
+ let started = false;
346
+ let reliable = true;
347
+ return {
348
+ excludes,
349
+ onDidStart: () => {
350
+ started = true;
351
+ onCoverage(reliable);
352
+ },
353
+ onDidChangeReliability: (state) => {
354
+ reliable = state === "reliable";
355
+ onCoverage(started && reliable);
356
+ if (this.poller != null) onDidChangeReliability(state);
357
+ }
358
+ };
359
+ }
312
360
  return this.poller != null ? {
313
361
  excludes,
314
362
  onDidChangeReliability
@@ -476,7 +524,7 @@ var WatchGroup = class {
476
524
  deliverOverflow(entry) {
477
525
  entry.hooks.onRepoChanged(entry.repoPath, [...allWatchedRepositoryChanges], void 0, true);
478
526
  entry.hooks.onFetchHeadChanged?.(entry.repoPath);
479
- entry.hooks.onIgnoresChanged?.(entry.repoPath);
527
+ entry.hooks.onIgnoresChanged?.(entry.repoPath, true);
480
528
  }
481
529
  onRootEvent(event, entry) {
482
530
  if (event.reason === "overflow") {