@gitkraken/core-gitlens 0.37.0 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +67 -1
- package/dist/git/cache.d.ts +128 -8
- package/dist/git/cache.js +425 -46
- package/dist/git/cache.js.map +1 -1
- package/dist/git/features.d.ts +1 -1
- package/dist/git/features.js +3 -0
- package/dist/git/features.js.map +1 -1
- package/dist/git/providers/branches.d.ts +42 -1
- package/dist/git/providers/diff.d.ts +17 -0
- package/dist/git/providers/provider.d.ts +7 -0
- package/dist/git/providers/shared/remotes.js +8 -4
- package/dist/git/providers/shared/remotes.js.map +1 -1
- package/dist/git/remotes/matcher.js +2 -2
- package/dist/git/remotes/matcher.js.map +1 -1
- package/dist/git/repositoryService.d.ts +16 -1
- package/dist/git/repositoryService.js +51 -3
- package/dist/git/repositoryService.js.map +1 -1
- package/dist/git/run.types.d.ts +1 -0
- package/dist/git/service.js +6 -2
- package/dist/git/service.js.map +1 -1
- package/dist/git/utils/fileStatus.utils.d.ts +5 -0
- package/dist/git/utils/fileStatus.utils.js +18 -1
- package/dist/git/utils/fileStatus.utils.js.map +1 -1
- package/dist/git/watching/changeEvent.d.ts +13 -3
- package/dist/git/watching/changeEvent.js +15 -4
- package/dist/git/watching/changeEvent.js.map +1 -1
- package/dist/git/watching/changeOrdinal.d.ts +9 -0
- package/dist/git/watching/changeOrdinal.js +14 -0
- package/dist/git/watching/changeOrdinal.js.map +1 -0
- package/dist/git/watching/unwatchedCacheValidator.d.ts +38 -5
- package/dist/git/watching/unwatchedCacheValidator.js +180 -36
- package/dist/git/watching/unwatchedCacheValidator.js.map +1 -1
- package/dist/git/watching/watchGroup.d.ts +63 -14
- package/dist/git/watching/watchGroup.js +213 -74
- package/dist/git/watching/watchGroup.js.map +1 -1
- package/dist/git/watching/watchService.js +4 -3
- package/dist/git/watching/watchService.js.map +1 -1
- package/dist/git/watching/watchSession.d.ts +10 -2
- package/dist/git/watching/watchSession.js +18 -4
- package/dist/git/watching/watchSession.js.map +1 -1
- package/dist/git/watching/watcherPatterns.d.ts +18 -4
- package/dist/git/watching/watcherPatterns.js +39 -8
- package/dist/git/watching/watcherPatterns.js.map +1 -1
- package/dist/git/watching/worktreeSummary.d.ts +23 -12
- package/dist/git/watching/worktreeSummary.js +164 -41
- package/dist/git/watching/worktreeSummary.js.map +1 -1
- package/dist/git-cli/cliGitProvider.d.ts +1 -0
- package/dist/git-cli/cliGitProvider.js +11 -2
- package/dist/git-cli/cliGitProvider.js.map +1 -1
- package/dist/git-cli/exec/git.d.ts +7 -2
- package/dist/git-cli/exec/git.js +46 -10
- package/dist/git-cli/exec/git.js.map +1 -1
- package/dist/git-cli/exec/headState.d.ts +24 -0
- package/dist/git-cli/exec/headState.js +46 -6
- package/dist/git-cli/exec/headState.js.map +1 -1
- package/dist/git-cli/parsers/logParser.js +6 -3
- package/dist/git-cli/parsers/logParser.js.map +1 -1
- package/dist/git-cli/providers/branches.d.ts +135 -10
- package/dist/git-cli/providers/branches.js +622 -80
- package/dist/git-cli/providers/branches.js.map +1 -1
- package/dist/git-cli/providers/commits.d.ts +16 -0
- package/dist/git-cli/providers/commits.js +80 -28
- package/dist/git-cli/providers/commits.js.map +1 -1
- package/dist/git-cli/providers/config.d.ts +10 -0
- package/dist/git-cli/providers/config.js +50 -12
- package/dist/git-cli/providers/config.js.map +1 -1
- package/dist/git-cli/providers/contributors.js +11 -7
- package/dist/git-cli/providers/contributors.js.map +1 -1
- package/dist/git-cli/providers/diff.d.ts +12 -0
- package/dist/git-cli/providers/diff.js +107 -15
- package/dist/git-cli/providers/diff.js.map +1 -1
- package/dist/git-cli/providers/graph.js +32 -25
- package/dist/git-cli/providers/graph.js.map +1 -1
- package/dist/git-cli/providers/operations.d.ts +37 -3
- package/dist/git-cli/providers/operations.js +124 -46
- package/dist/git-cli/providers/operations.js.map +1 -1
- package/dist/git-cli/providers/patch.js +1 -1
- package/dist/git-cli/providers/patch.js.map +1 -1
- package/dist/git-cli/providers/refs.d.ts +1 -1
- package/dist/git-cli/providers/refs.js +10 -11
- package/dist/git-cli/providers/refs.js.map +1 -1
- package/dist/git-cli/providers/status.d.ts +4 -5
- package/dist/git-cli/providers/status.js +36 -33
- package/dist/git-cli/providers/status.js.map +1 -1
- package/dist/git-cli/providers/tags.d.ts +8 -0
- package/dist/git-cli/providers/tags.js +53 -34
- package/dist/git-cli/providers/tags.js.map +1 -1
- package/dist/git-cli/service.d.ts +15 -0
- package/dist/git-cli/service.js +19 -1
- package/dist/git-cli/service.js.map +1 -1
- package/dist/plus/git-github/api/github.d.ts +4 -0
- package/dist/plus/git-github/api/github.js +11 -1
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/providers/github/diff.d.ts +1 -0
- package/dist/plus/git-github/providers/github/diff.js +6 -1
- package/dist/plus/git-github/providers/github/diff.js.map +1 -1
- package/dist/plus/integrations/integrationService.js +9 -0
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/providers/jira-server.js +1 -1
- package/dist/plus/integrations/providers/jira-server.js.map +1 -1
- package/dist/plus/integrations/providers/jira.d.ts +38 -6
- package/dist/plus/integrations/providers/jira.js +111 -69
- package/dist/plus/integrations/providers/jira.js.map +1 -1
- package/dist/plus/integrations/providers/linear.d.ts +31 -3
- package/dist/plus/integrations/providers/linear.js +77 -18
- package/dist/plus/integrations/providers/linear.js.map +1 -1
- package/dist/plus/integrations/providers/utils/discoveryCache.d.ts +41 -4
- package/dist/plus/integrations/providers/utils/discoveryCache.js +50 -11
- package/dist/plus/integrations/providers/utils/discoveryCache.js.map +1 -1
- package/dist/utils/env/node/exec.d.ts +5 -4
- package/dist/utils/env/node/exec.js +52 -9
- package/dist/utils/env/node/exec.js.map +1 -1
- package/dist/utils/holdOffMap.d.ts +23 -0
- package/dist/utils/holdOffMap.js +43 -0
- package/dist/utils/holdOffMap.js.map +1 -0
- package/dist/utils/promiseCache.d.ts +15 -2
- package/dist/utils/promiseCache.js +34 -4
- package/dist/utils/promiseCache.js.map +1 -1
- package/package.json +1 -1
|
@@ -23,44 +23,23 @@ var TagsGitSubProvider = class {
|
|
|
23
23
|
this.provider = provider;
|
|
24
24
|
}
|
|
25
25
|
async getTag(repoPath, name, cancellation) {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
if (!repoPath) return void 0;
|
|
27
|
+
const { values } = await this.getSharedTags(repoPath, cancellation);
|
|
28
|
+
return values.find((t) => t.name === name)?.withRepoPath(repoPath);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Whether `getTags(repoPath)` holds a tag `matches` accepts (any when omitted), judged on each as that list would
|
|
32
|
+
* hold it, without keeping that worktree's copy of the list
|
|
33
|
+
*/
|
|
34
|
+
async hasTag(repoPath, matches, cancellation) {
|
|
35
|
+
if (!repoPath) return false;
|
|
36
|
+
const { values } = await this.getSharedTags(repoPath, cancellation);
|
|
37
|
+
return matches == null ? values.length !== 0 : values.some((t) => matches(t.withRepoPath(repoPath)));
|
|
28
38
|
}
|
|
29
39
|
async getTags(repoPath, options, cancellation) {
|
|
30
40
|
if (!repoPath) return emptyPagedResult;
|
|
31
41
|
const scope = getScopedLogger();
|
|
32
|
-
let tagsResult = await this.cache.getTags(repoPath,
|
|
33
|
-
signal ??= cancellation;
|
|
34
|
-
try {
|
|
35
|
-
try {
|
|
36
|
-
var _usingCtx$1 = _usingCtx();
|
|
37
|
-
const records = await this.provider.refs.getRefs(commonPath, signal);
|
|
38
|
-
if (!records.length) return emptyPagedResult;
|
|
39
|
-
const sw = _usingCtx$1.u(maybeStopWatch(scope, { log: {
|
|
40
|
-
onlyExit: true,
|
|
41
|
-
level: "debug"
|
|
42
|
-
} }));
|
|
43
|
-
const tags = [];
|
|
44
|
-
for (const record of records) {
|
|
45
|
-
const fullName = record.name;
|
|
46
|
-
if (!fullName.startsWith("refs/tags/")) continue;
|
|
47
|
-
const annotated = Boolean(record.peeledObjectname);
|
|
48
|
-
const sha = record.peeledObjectname || record.objectname;
|
|
49
|
-
tags.push(new GitTag(commonPath, fullName, sha, record.subject, record.creatorDate ? new Date(record.creatorDate) : void 0, record.authorDate ? new Date(record.authorDate) : void 0, annotated));
|
|
50
|
-
}
|
|
51
|
-
sw?.stop({ suffix: ` parsed ${String(tags.length)} tags` });
|
|
52
|
-
return { values: tags };
|
|
53
|
-
} catch (_) {
|
|
54
|
-
_usingCtx$1.e = _;
|
|
55
|
-
} finally {
|
|
56
|
-
_usingCtx$1.d();
|
|
57
|
-
}
|
|
58
|
-
} catch (ex) {
|
|
59
|
-
scope?.error(ex);
|
|
60
|
-
if (isCancellationError(ex)) throw ex;
|
|
61
|
-
return emptyPagedResult;
|
|
62
|
-
}
|
|
63
|
-
}, cancellation);
|
|
42
|
+
let tagsResult = await this.cache.getTags(repoPath, (commonPath, cacheable, signal) => this.readTags(commonPath, cacheable, signal ?? cancellation, scope), cancellation);
|
|
64
43
|
if (options?.filter != null) tagsResult = {
|
|
65
44
|
...tagsResult,
|
|
66
45
|
values: tagsResult.values.filter(options.filter)
|
|
@@ -68,6 +47,46 @@ var TagsGitSubProvider = class {
|
|
|
68
47
|
if (options?.sort) sortTags(tagsResult.values, typeof options.sort === "boolean" ? void 0 : options.sort);
|
|
69
48
|
return tagsResult;
|
|
70
49
|
}
|
|
50
|
+
/** The tags every worktree of `repoPath` shares, listed from the common path, read once whoever asks */
|
|
51
|
+
getSharedTags(repoPath, cancellation) {
|
|
52
|
+
const scope = getScopedLogger();
|
|
53
|
+
return this.cache.getSharedTags(repoPath, (commonPath, cacheable, signal) => this.readTags(commonPath, cacheable, signal ?? cancellation, scope), cancellation);
|
|
54
|
+
}
|
|
55
|
+
async readTags(commonPath, cacheable, signal, scope) {
|
|
56
|
+
try {
|
|
57
|
+
try {
|
|
58
|
+
var _usingCtx$1 = _usingCtx();
|
|
59
|
+
const records = await this.provider.refs.getRefs(commonPath, signal);
|
|
60
|
+
if (!records.length) {
|
|
61
|
+
cacheable.invalidate();
|
|
62
|
+
return emptyPagedResult;
|
|
63
|
+
}
|
|
64
|
+
const sw = _usingCtx$1.u(maybeStopWatch(scope, { log: {
|
|
65
|
+
onlyExit: true,
|
|
66
|
+
level: "debug"
|
|
67
|
+
} }));
|
|
68
|
+
const tags = [];
|
|
69
|
+
for (const record of records) {
|
|
70
|
+
const fullName = record.name;
|
|
71
|
+
if (!fullName.startsWith("refs/tags/")) continue;
|
|
72
|
+
const annotated = Boolean(record.peeledObjectname);
|
|
73
|
+
const sha = record.peeledObjectname || record.objectname;
|
|
74
|
+
tags.push(new GitTag(commonPath, fullName, sha, record.subject, record.creatorDate ? new Date(record.creatorDate) : void 0, record.authorDate ? new Date(record.authorDate) : void 0, annotated));
|
|
75
|
+
}
|
|
76
|
+
sw?.stop({ suffix: ` parsed ${String(tags.length)} tags` });
|
|
77
|
+
return { values: tags };
|
|
78
|
+
} catch (_) {
|
|
79
|
+
_usingCtx$1.e = _;
|
|
80
|
+
} finally {
|
|
81
|
+
_usingCtx$1.d();
|
|
82
|
+
}
|
|
83
|
+
} catch (ex) {
|
|
84
|
+
cacheable.invalidate();
|
|
85
|
+
scope?.error(ex);
|
|
86
|
+
if (isCancellationError(ex)) throw ex;
|
|
87
|
+
return emptyPagedResult;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
71
90
|
async getTagsWithCommit(repoPath, sha, options, cancellation) {
|
|
72
91
|
const result = await this.tagsContainingCore(repoPath, sha, options, cancellation);
|
|
73
92
|
if (!result.stdout) return [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tags.js","names":[],"sources":["../../../../git-cli/src/providers/tags.ts"],"sourcesContent":["import type { Cache } from '@gitlens/git/cache.js';\nimport type { GitServiceContext } from '@gitlens/git/context.js';\nimport { TagError } from '@gitlens/git/errors.js';\nimport { GitTag } from '@gitlens/git/models/tag.js';\nimport type { GitTagsSubProvider } from '@gitlens/git/providers/tags.js';\nimport type { TagSortOptions } from '@gitlens/git/utils/sorting.js';\nimport { sortTags } from '@gitlens/git/utils/sorting.js';\nimport { ensureArray, filterMap } from '@gitlens/utils/array.js';\nimport { isCancellationError } from '@gitlens/utils/cancellation.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport type { PagedResult, PagingOptions } from '@gitlens/utils/paging.js';\nimport { emptyPagedResult } from '@gitlens/utils/paging.js';\nimport { maybeStopWatch } from '@gitlens/utils/stopwatch.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport type { GitResult } from '../exec/exec.types.js';\nimport type { Git, GitError } from '../exec/git.js';\nimport { getGitCommandError, gitConfigsBranch } from '../exec/git.js';\n\nexport class TagsGitSubProvider implements GitTagsSubProvider {\n\tconstructor(\n\t\tprivate readonly context: GitServiceContext,\n\t\tprivate readonly git: Git,\n\t\tprivate readonly cache: Cache,\n\t\tprivate readonly provider: CliGitProviderInternal,\n\t) {}\n\n\t@debug({ quiet: true })\n\tasync getTag(repoPath: string, name: string, cancellation?: AbortSignal): Promise<GitTag | undefined> {\n\t\tconst {\n\t\t\tvalues: [tag],\n\t\t} = await this.getTags(repoPath, { filter: t => t.name === name }, cancellation);\n\t\treturn tag;\n\t}\n\n\t@debug({ quiet: true, args: repoPath => ({ repoPath: repoPath }) })\n\tasync getTags(\n\t\trepoPath: string,\n\t\toptions?: {\n\t\t\tfilter?: (t: GitTag) => boolean;\n\t\t\tpaging?: PagingOptions;\n\t\t\tsort?: boolean | TagSortOptions;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<PagedResult<GitTag>> {\n\t\tif (!repoPath) return emptyPagedResult;\n\n\t\tconst scope = getScopedLogger();\n\n\t\tlet tagsResult = await this.cache.getTags(\n\t\t\trepoPath,\n\t\t\tasync (commonPath, _cacheable, signal) => {\n\t\t\t\t// Prefer the aggregate signal from the cache; fall back to the caller's cancellation.\n\t\t\t\tsignal ??= cancellation;\n\t\t\t\ttry {\n\t\t\t\t\tconst records = await this.provider.refs.getRefs(commonPath, signal);\n\t\t\t\t\tif (!records.length) return emptyPagedResult;\n\n\t\t\t\t\tusing sw = maybeStopWatch(scope, { log: { onlyExit: true, level: 'debug' } });\n\n\t\t\t\t\tconst tags: GitTag[] = [];\n\n\t\t\t\t\tfor (const record of records) {\n\t\t\t\t\t\tconst fullName = record.name;\n\t\t\t\t\t\tif (!fullName.startsWith('refs/tags/')) continue;\n\n\t\t\t\t\t\t// Annotated tags: peeledObjectname is the commit SHA; objectname is the tag-object SHA.\n\t\t\t\t\t\t// Lightweight tags: peeledObjectname is empty; objectname is already the commit SHA.\n\t\t\t\t\t\tconst annotated = Boolean(record.peeledObjectname);\n\t\t\t\t\t\tconst sha = record.peeledObjectname || record.objectname;\n\n\t\t\t\t\t\ttags.push(\n\t\t\t\t\t\t\tnew GitTag(\n\t\t\t\t\t\t\t\tcommonPath,\n\t\t\t\t\t\t\t\tfullName,\n\t\t\t\t\t\t\t\tsha,\n\t\t\t\t\t\t\t\trecord.subject,\n\t\t\t\t\t\t\t\trecord.creatorDate ? new Date(record.creatorDate) : undefined,\n\t\t\t\t\t\t\t\trecord.authorDate ? new Date(record.authorDate) : undefined,\n\t\t\t\t\t\t\t\tannotated,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tsw?.stop({ suffix: ` parsed ${String(tags.length)} tags` });\n\n\t\t\t\t\treturn { values: tags };\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tscope?.error(ex);\n\t\t\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t\t\treturn emptyPagedResult;\n\t\t\t\t}\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\n\t\tif (options?.filter != null) {\n\t\t\ttagsResult = {\n\t\t\t\t...tagsResult,\n\t\t\t\tvalues: tagsResult.values.filter(options.filter),\n\t\t\t};\n\t\t}\n\n\t\tif (options?.sort) {\n\t\t\tsortTags(tagsResult.values, typeof options.sort === 'boolean' ? undefined : options.sort);\n\t\t}\n\n\t\treturn tagsResult;\n\t}\n\n\t@debug({ quiet: true })\n\tasync getTagsWithCommit(\n\t\trepoPath: string,\n\t\tsha: string,\n\t\toptions?: { commitDate?: Date; mode?: 'contains' | 'pointsAt' },\n\t\tcancellation?: AbortSignal,\n\t): Promise<string[]> {\n\t\tconst result = await this.tagsContainingCore(repoPath, sha, options, cancellation);\n\t\tif (!result.stdout) return [];\n\n\t\treturn filterMap(result.stdout.split('\\n'), b => b.trim() || undefined);\n\t}\n\n\tprivate async tagsContainingCore(\n\t\trepoPath: string,\n\t\tsha: string,\n\t\toptions?: { mode?: 'contains' | 'pointsAt' },\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitResult> {\n\t\tconst params: string[] = ['tag', '--format=%(refname:short)'];\n\t\tparams.push(options?.mode === 'pointsAt' ? `--points-at=${sha}` : `--contains=${sha}`);\n\n\t\treturn this.git.run(\n\t\t\t{\n\t\t\t\tcwd: repoPath,\n\t\t\t\tcancellation: cancellation,\n\t\t\t\tconfigs: gitConfigsBranch,\n\t\t\t\terrors: 'ignore',\n\t\t\t},\n\t\t\t...params,\n\t\t);\n\t}\n\n\t@debug()\n\tasync createTag(repoPath: string, name: string, sha: string, message?: string): Promise<void> {\n\t\tconst args = ['tag', name, sha];\n\t\tif (message != null && message.length > 0) {\n\t\t\targs.push('-m', message);\n\t\t}\n\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t} catch (ex) {\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'tag',\n\t\t\t\tex as GitError,\n\t\t\t\treason =>\n\t\t\t\t\tnew TagError(\n\t\t\t\t\t\t{ reason: reason, action: 'create', tag: name, gitCommand: { repoPath: repoPath, args: args } },\n\t\t\t\t\t\tex as GitError,\n\t\t\t\t\t),\n\t\t\t);\n\t\t} finally {\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'tags');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['tags']);\n\t\t}\n\t}\n\n\t@debug()\n\tasync deleteTag(repoPath: string, name: string): Promise<void> {\n\t\tconst args = ['tag', '-d', name];\n\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t} catch (ex) {\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'tag',\n\t\t\t\tex as GitError,\n\t\t\t\treason =>\n\t\t\t\t\tnew TagError(\n\t\t\t\t\t\t{ reason: reason, action: 'delete', tag: name, gitCommand: { repoPath: repoPath, args: args } },\n\t\t\t\t\t\tex as GitError,\n\t\t\t\t\t),\n\t\t\t);\n\t\t} finally {\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'tags');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['tags']);\n\t\t}\n\t}\n\n\t@debug()\n\tasync pushTag(\n\t\trepoPath: string,\n\t\tname: string | string[],\n\t\tremote: string,\n\t\toptions?: { force?: boolean },\n\t): Promise<void> {\n\t\tconst names = ensureArray(name);\n\t\tconst args = ['push'];\n\t\tif (options?.force) {\n\t\t\targs.push('--force');\n\t\t}\n\n\t\targs.push(remote, ...names.map(n => `refs/tags/${n}`));\n\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t} catch (ex) {\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'tag',\n\t\t\t\tex as GitError,\n\t\t\t\treason =>\n\t\t\t\t\tnew TagError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason,\n\t\t\t\t\t\t\taction: 'push',\n\t\t\t\t\t\t\ttag: names.join(', '),\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: args },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex as GitError,\n\t\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAmBA,IAAa,qBAAb,MAA8D;CAE3C;CACA;CACA;CACA;CAJlB,YACC,SACA,KACA,OACA,UACC;EAJgB,KAA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AAM,CAAA,GAAA,mBAAA,WAAA,aAAA,IAAA;AAsBN,WAAA,CAAA,MAAM,CAAA,GAAA,mBAAA,WAAA,WAAA,IAAA"}
|
|
1
|
+
{"version":3,"file":"tags.js","names":[],"sources":["../../../../git-cli/src/providers/tags.ts"],"sourcesContent":["import type { Cache } from '@gitlens/git/cache.js';\nimport type { GitServiceContext } from '@gitlens/git/context.js';\nimport { TagError } from '@gitlens/git/errors.js';\nimport { GitTag } from '@gitlens/git/models/tag.js';\nimport type { GitTagsSubProvider } from '@gitlens/git/providers/tags.js';\nimport type { TagSortOptions } from '@gitlens/git/utils/sorting.js';\nimport { sortTags } from '@gitlens/git/utils/sorting.js';\nimport { ensureArray, filterMap } from '@gitlens/utils/array.js';\nimport { isCancellationError } from '@gitlens/utils/cancellation.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport type { ScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport type { PagedResult, PagingOptions } from '@gitlens/utils/paging.js';\nimport { emptyPagedResult } from '@gitlens/utils/paging.js';\nimport type { CacheController } from '@gitlens/utils/promiseCache.js';\nimport { maybeStopWatch } from '@gitlens/utils/stopwatch.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport type { GitResult } from '../exec/exec.types.js';\nimport type { Git, GitError } from '../exec/git.js';\nimport { getGitCommandError, gitConfigsBranch } from '../exec/git.js';\n\nexport class TagsGitSubProvider implements GitTagsSubProvider {\n\tconstructor(\n\t\tprivate readonly context: GitServiceContext,\n\t\tprivate readonly git: Git,\n\t\tprivate readonly cache: Cache,\n\t\tprivate readonly provider: CliGitProviderInternal,\n\t) {}\n\n\t@debug({ quiet: true })\n\tasync getTag(repoPath: string, name: string, cancellation?: AbortSignal): Promise<GitTag | undefined> {\n\t\tif (!repoPath) return undefined;\n\n\t\tconst { values } = await this.getSharedTags(repoPath, cancellation);\n\t\treturn values.find(t => t.name === name)?.withRepoPath(repoPath);\n\t}\n\n\t/**\n\t * Whether `getTags(repoPath)` holds a tag `matches` accepts (any when omitted), judged on each as that list would\n\t * hold it, without keeping that worktree's copy of the list\n\t */\n\tasync hasTag(\n\t\trepoPath: string,\n\t\tmatches: ((tag: GitTag) => boolean) | undefined,\n\t\tcancellation?: AbortSignal,\n\t): Promise<boolean> {\n\t\tif (!repoPath) return false;\n\n\t\tconst { values } = await this.getSharedTags(repoPath, cancellation);\n\t\treturn matches == null ? values.length !== 0 : values.some(t => matches(t.withRepoPath(repoPath)));\n\t}\n\n\t@debug({ quiet: true, args: repoPath => ({ repoPath: repoPath }) })\n\tasync getTags(\n\t\trepoPath: string,\n\t\toptions?: {\n\t\t\tfilter?: (t: GitTag) => boolean;\n\t\t\tpaging?: PagingOptions;\n\t\t\tsort?: boolean | TagSortOptions;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<PagedResult<GitTag>> {\n\t\tif (!repoPath) return emptyPagedResult;\n\n\t\tconst scope = getScopedLogger();\n\n\t\tlet tagsResult = await this.cache.getTags(\n\t\t\trepoPath,\n\t\t\t(commonPath, cacheable, signal) => this.readTags(commonPath, cacheable, signal ?? cancellation, scope),\n\t\t\tcancellation,\n\t\t);\n\n\t\tif (options?.filter != null) {\n\t\t\ttagsResult = {\n\t\t\t\t...tagsResult,\n\t\t\t\tvalues: tagsResult.values.filter(options.filter),\n\t\t\t};\n\t\t}\n\n\t\tif (options?.sort) {\n\t\t\tsortTags(tagsResult.values, typeof options.sort === 'boolean' ? undefined : options.sort);\n\t\t}\n\n\t\treturn tagsResult;\n\t}\n\n\t/** The tags every worktree of `repoPath` shares, listed from the common path, read once whoever asks */\n\tprivate getSharedTags(repoPath: string, cancellation?: AbortSignal): Promise<PagedResult<GitTag>> {\n\t\tconst scope = getScopedLogger();\n\n\t\treturn this.cache.getSharedTags(\n\t\t\trepoPath,\n\t\t\t(commonPath, cacheable, signal) => this.readTags(commonPath, cacheable, signal ?? cancellation, scope),\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprivate async readTags(\n\t\tcommonPath: string,\n\t\tcacheable: CacheController,\n\t\tsignal: AbortSignal | undefined,\n\t\tscope: ScopedLogger | undefined,\n\t): Promise<PagedResult<GitTag>> {\n\t\ttry {\n\t\t\tconst records = await this.provider.refs.getRefs(commonPath, signal);\n\t\t\tif (!records.length) {\n\t\t\t\t// Empty also means the listing failed; the listing's own cached answer covers a\n\t\t\t\t// repository that truly has no refs without another git run\n\t\t\t\tcacheable.invalidate();\n\t\t\t\treturn emptyPagedResult;\n\t\t\t}\n\n\t\t\tusing sw = maybeStopWatch(scope, { log: { onlyExit: true, level: 'debug' } });\n\n\t\t\tconst tags: GitTag[] = [];\n\n\t\t\tfor (const record of records) {\n\t\t\t\tconst fullName = record.name;\n\t\t\t\tif (!fullName.startsWith('refs/tags/')) continue;\n\n\t\t\t\t// Annotated tags: peeledObjectname is the commit SHA; objectname is the tag-object SHA.\n\t\t\t\t// Lightweight tags: peeledObjectname is empty; objectname is already the commit SHA.\n\t\t\t\tconst annotated = Boolean(record.peeledObjectname);\n\t\t\t\tconst sha = record.peeledObjectname || record.objectname;\n\n\t\t\t\ttags.push(\n\t\t\t\t\tnew GitTag(\n\t\t\t\t\t\tcommonPath,\n\t\t\t\t\t\tfullName,\n\t\t\t\t\t\tsha,\n\t\t\t\t\t\trecord.subject,\n\t\t\t\t\t\trecord.creatorDate ? new Date(record.creatorDate) : undefined,\n\t\t\t\t\t\trecord.authorDate ? new Date(record.authorDate) : undefined,\n\t\t\t\t\t\tannotated,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tsw?.stop({ suffix: ` parsed ${String(tags.length)} tags` });\n\n\t\t\treturn { values: tags };\n\t\t} catch (ex) {\n\t\t\tcacheable.invalidate();\n\t\t\tscope?.error(ex);\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\treturn emptyPagedResult;\n\t\t}\n\t}\n\n\t@debug({ quiet: true })\n\tasync getTagsWithCommit(\n\t\trepoPath: string,\n\t\tsha: string,\n\t\toptions?: { commitDate?: Date; mode?: 'contains' | 'pointsAt' },\n\t\tcancellation?: AbortSignal,\n\t): Promise<string[]> {\n\t\tconst result = await this.tagsContainingCore(repoPath, sha, options, cancellation);\n\t\tif (!result.stdout) return [];\n\n\t\treturn filterMap(result.stdout.split('\\n'), b => b.trim() || undefined);\n\t}\n\n\tprivate async tagsContainingCore(\n\t\trepoPath: string,\n\t\tsha: string,\n\t\toptions?: { mode?: 'contains' | 'pointsAt' },\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitResult> {\n\t\tconst params: string[] = ['tag', '--format=%(refname:short)'];\n\t\tparams.push(options?.mode === 'pointsAt' ? `--points-at=${sha}` : `--contains=${sha}`);\n\n\t\treturn this.git.run(\n\t\t\t{\n\t\t\t\tcwd: repoPath,\n\t\t\t\tcancellation: cancellation,\n\t\t\t\tconfigs: gitConfigsBranch,\n\t\t\t\terrors: 'ignore',\n\t\t\t},\n\t\t\t...params,\n\t\t);\n\t}\n\n\t@debug()\n\tasync createTag(repoPath: string, name: string, sha: string, message?: string): Promise<void> {\n\t\tconst args = ['tag', name, sha];\n\t\tif (message != null && message.length > 0) {\n\t\t\targs.push('-m', message);\n\t\t}\n\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t} catch (ex) {\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'tag',\n\t\t\t\tex as GitError,\n\t\t\t\treason =>\n\t\t\t\t\tnew TagError(\n\t\t\t\t\t\t{ reason: reason, action: 'create', tag: name, gitCommand: { repoPath: repoPath, args: args } },\n\t\t\t\t\t\tex as GitError,\n\t\t\t\t\t),\n\t\t\t);\n\t\t} finally {\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'tags');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['tags']);\n\t\t}\n\t}\n\n\t@debug()\n\tasync deleteTag(repoPath: string, name: string): Promise<void> {\n\t\tconst args = ['tag', '-d', name];\n\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t} catch (ex) {\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'tag',\n\t\t\t\tex as GitError,\n\t\t\t\treason =>\n\t\t\t\t\tnew TagError(\n\t\t\t\t\t\t{ reason: reason, action: 'delete', tag: name, gitCommand: { repoPath: repoPath, args: args } },\n\t\t\t\t\t\tex as GitError,\n\t\t\t\t\t),\n\t\t\t);\n\t\t} finally {\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'tags');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['tags']);\n\t\t}\n\t}\n\n\t@debug()\n\tasync pushTag(\n\t\trepoPath: string,\n\t\tname: string | string[],\n\t\tremote: string,\n\t\toptions?: { force?: boolean },\n\t): Promise<void> {\n\t\tconst names = ensureArray(name);\n\t\tconst args = ['push'];\n\t\tif (options?.force) {\n\t\t\targs.push('--force');\n\t\t}\n\n\t\targs.push(remote, ...names.map(n => `refs/tags/${n}`));\n\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t} catch (ex) {\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'tag',\n\t\t\t\tex as GitError,\n\t\t\t\treason =>\n\t\t\t\t\tnew TagError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason,\n\t\t\t\t\t\t\taction: 'push',\n\t\t\t\t\t\t\ttag: names.join(', '),\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: args },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex as GitError,\n\t\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAqBA,IAAa,qBAAb,MAA8D;CAE3C;CACA;CACA;CACA;CAJlB,YACC,SACA,KACA,OACA,UACC;EAJgB,KAAA,UAAA;EACA,KAAA,MAAA;EACA,KAAA,QAAA;EACA,KAAA,WAAA;CACf;CAEH,MACM,O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Q;IACR,KAAK,MAAM,KAAK,IAAI;IACpB,YAAY;KAAY;KAAgB;IAAK;GAC9C,GACA,EACD,CACF;EACD;CACD;AACD;AA3OE,WAAA,CAAA,MAAM,EAAE,OAAO,KAAK,CAAC,CAAA,GAAA,mBAAA,WAAA,UAAA,IAAA;AAuBrB,WAAA,CAAA,MAAM;CAAE,OAAO;CAAM,OAAM,cAAa,EAAY,SAAS;AAAG,CAAC,CAAA,GAAA,mBAAA,WAAA,WAAA,IAAA;AAkGjE,WAAA,CAAA,MAAM,EAAE,OAAO,KAAK,CAAC,CAAA,GAAA,mBAAA,WAAA,qBAAA,IAAA;AAiCrB,WAAA,CAAA,MAAM,CAAA,GAAA,mBAAA,WAAA,aAAA,IAAA;AAyBN,WAAA,CAAA,MAAM,CAAA,GAAA,mBAAA,WAAA,aAAA,IAAA;AAsBN,WAAA,CAAA,MAAM,CAAA,GAAA,mBAAA,WAAA,WAAA,IAAA"}
|
|
@@ -85,6 +85,21 @@ export interface CliGitServiceOptions {
|
|
|
85
85
|
*
|
|
86
86
|
* git.dispose(); // cleans up provider, cache, and module-level state
|
|
87
87
|
* ```
|
|
88
|
+
*
|
|
89
|
+
* The cache shares a repository's data between its checkouts only once each checkout is registered
|
|
90
|
+
* (`cache.registerRepoPath`). A host that registers checkouts in the background can have each one registered before
|
|
91
|
+
* its first read through `forRepo` by setting a registrar once it has the service (see
|
|
92
|
+
* `Cache.setRepoPathRegistrar`; `undefined` declines a path):
|
|
93
|
+
*
|
|
94
|
+
* ```typescript
|
|
95
|
+
* cache.setRepoPathRegistrar(path =>
|
|
96
|
+
* isKnownCheckout(path)
|
|
97
|
+
* ? git.forRepo(path)!.config.getGitDir!().then(gitDir => {
|
|
98
|
+
* if (gitDir != null) cache.registerRepoPath(fileUri(path), gitDir);
|
|
99
|
+
* })
|
|
100
|
+
* : undefined,
|
|
101
|
+
* );
|
|
102
|
+
* ```
|
|
88
103
|
*/
|
|
89
104
|
export declare function createCliGitService(options: CliGitServiceOptions): GitService;
|
|
90
105
|
//#endregion
|
package/dist/git-cli/service.js
CHANGED
|
@@ -24,6 +24,21 @@ import { env } from "node:process";
|
|
|
24
24
|
*
|
|
25
25
|
* git.dispose(); // cleans up provider, cache, and module-level state
|
|
26
26
|
* ```
|
|
27
|
+
*
|
|
28
|
+
* The cache shares a repository's data between its checkouts only once each checkout is registered
|
|
29
|
+
* (`cache.registerRepoPath`). A host that registers checkouts in the background can have each one registered before
|
|
30
|
+
* its first read through `forRepo` by setting a registrar once it has the service (see
|
|
31
|
+
* `Cache.setRepoPathRegistrar`; `undefined` declines a path):
|
|
32
|
+
*
|
|
33
|
+
* ```typescript
|
|
34
|
+
* cache.setRepoPathRegistrar(path =>
|
|
35
|
+
* isKnownCheckout(path)
|
|
36
|
+
* ? git.forRepo(path)!.config.getGitDir!().then(gitDir => {
|
|
37
|
+
* if (gitDir != null) cache.registerRepoPath(fileUri(path), gitDir);
|
|
38
|
+
* })
|
|
39
|
+
* : undefined,
|
|
40
|
+
* );
|
|
41
|
+
* ```
|
|
27
42
|
*/
|
|
28
43
|
function createCliGitService(options) {
|
|
29
44
|
const service = GitService.createSingleton(options.watchingProvider, {
|
|
@@ -82,7 +97,10 @@ function createCliGitService(options) {
|
|
|
82
97
|
service.watchService?.onDidChangeWorkingTree((repoPath) => provider.cache.onWorkingTreeChanged(repoPath));
|
|
83
98
|
service.watchService?.onDidChangeRepository((e) => {
|
|
84
99
|
const changes = e.getUnannouncedChanges();
|
|
85
|
-
if (changes.length) provider.cache.onRepositoryChanged(e.repoPath, changes, {
|
|
100
|
+
if (changes.length) provider.cache.onRepositoryChanged(e.repoPath, changes, {
|
|
101
|
+
movedWorktrees: e.movedWorktrees,
|
|
102
|
+
observedAt: e.observedAt
|
|
103
|
+
});
|
|
86
104
|
});
|
|
87
105
|
service.watchService?.onDidChangeFetchHead((repoPath) => provider.cache.onRepositoryChanged(repoPath, ["lastFetched"]));
|
|
88
106
|
return service;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","names":[],"sources":["../../../git-cli/src/service.ts"],"sourcesContent":["import { env } from 'node:process';\nimport { GitService } from '@gitlens/git/service.js';\nimport type { FileWatchingProvider } from '@gitlens/git/watching/provider.js';\nimport { UnwatchedCacheValidator } from '@gitlens/git/watching/unwatchedCacheValidator.js';\nimport { isNotFound } from '@gitlens/git/watching/watchGroup.js';\nimport type { WatchPollingOptions } from '@gitlens/git/watching/watchService.js';\nimport type { WorktreeSummaryServiceOptions } from '@gitlens/git/watching/worktreeSummary.js';\nimport { fileUri } from '@gitlens/utils/uri.js';\nimport type { CliGitProviderOptions } from './cliGitProvider.js';\nimport { CliGitProvider } from './cliGitProvider.js';\nimport type { GitLocation } from './exec/locator.js';\nimport { findGitPath } from './exec/locator.js';\n\n/**\n * Options for {@link createCliGitService}.\n */\nexport interface CliGitServiceOptions {\n\t/**\n\t * Path(s) to the git binary.\n\t * Auto-detected if omitted (searches PATH, platform-specific locations).\n\t * Ignored when {@link locator} is provided.\n\t */\n\tgitPath?: string | string[];\n\n\t/**\n\t * Custom git binary resolver. When provided, used instead of the\n\t * default `findGitPath(gitPath)` lookup.\n\t */\n\tlocator?: () => Promise<GitLocation>;\n\n\t/** Host-provided context hooks (cache events, workspace, integrations, telemetry, fs) */\n\tcontext: CliGitProviderOptions['context'];\n\n\t/**\n\t * Git execution options passed through to the underlying Git executor. `gitOptions.isTrusted(repoPath)` is the\n\t * per-repository trust gate: a `false` answer rejects git runs in that path with `WorkspaceUntrustedError` before\n\t * any process starts. It applies only when `context.workspace.isTrusted` is unset; that flag wins when present.\n\t */\n\tgitOptions?: CliGitProviderOptions['gitOptions'];\n\n\t/** Use an existing Cache instance, or one will be created */\n\tcache?: CliGitProviderOptions['cache'];\n\n\t/** Folders, relative to a repository's common git dir, whose worktrees core acts as if didn't exist */\n\tignoredWorktreeFolders?: CliGitProviderOptions['ignoredWorktreeFolders'];\n\n\t/** Refreshes a checkout's index after core's own writes rewrote it (see `CliGitProviderOptions`); off by default */\n\trefreshIndexAfterWrites?: CliGitProviderOptions['refreshIndexAfterWrites'];\n\n\t/**\n\t * Filesystem watching provider. When provided, the {@link GitService}\n\t * will watch repositories for changes (file creates, edits, deletes).\n\t */\n\twatchingProvider?: FileWatchingProvider;\n\n\t/**\n\t * Polls in place of (or beside) the watchers {@link watchingProvider} reports it can't trust. When omitted, no\n\t * watcher is asked.\n\t */\n\twatchPolling?: WatchPollingOptions;\n\n\t/**\n\t * Keeps the caches that never expire (branches, current branch, refs, tags, remotes, worktrees, stashes, gk config,\n\t * paused operation, and what derives from them) fresh for repositories whose `.git` directory nothing watches:\n\t * before such a read, stats the files a watcher would have reported, and lists the ref directories and worktree\n\t * admin entries, applying what moved as a watcher event would. Files git writes by rename are read only once the\n\t * directory they're in moved, so a read of an idle repository costs a stat per git dir, per ref directory, per\n\t * linked worktree and per file git writes in place, at most once per 250ms per repository; a watched one costs\n\t * nothing, unless its watch is suspended, which holds what it hears until it resumes. Never runs git: a repository\n\t * whose git dir nothing resolved yet is read from its own files, and one whose files can't show it (bare, a\n\t * submodule, `--separate-git-dir`, `core.worktree`) isn't validated until a read resolves it, its files looked at\n\t * again every 30 seconds. What moves in a worktree under an {@link ignoredWorktreeFolders} folder clears nothing. Without a\n\t * {@link watchingProvider}, every repository counts as unwatched. A read waits at most `timeoutMs` (default 1000)\n\t * for the stats, then is served from the cache, and the stats run one at a time per repository and two at once\n\t * overall. A stat on a hung mount holds one of Node's file-system threads until it returns; one outstanding past\n\t * `timeoutMs` lets other repositories' stats go on, as long as the stats hold all but two of the threads\n\t * (`UV_THREADPOOL_SIZE`, default 4), which leaves the host two. Off by default.\n\t */\n\tvalidateUnwatchedCaches?: boolean | { readonly timeoutMs?: number };\n\n\t/** For tests only; production never passes it (see `WorktreeSummaryServiceOptions.verifyBaseRemeasure`) */\n\tverifyBaseRemeasure?: WorktreeSummaryServiceOptions['verifyBaseRemeasure'];\n}\n\n/**\n * Creates a ready-to-use {@link GitService} backed by the CLI git provider.\n *\n * This is the primary entry point for standalone (non-VS Code) consumers\n * of the `@gitlens/git-cli` library. It creates a singleton {@link GitService},\n * wires up a {@link CliGitProvider}, and registers it for all repository paths.\n *\n * @example\n * ```typescript\n * const git = createCliGitService({ context: {} });\n *\n * const repo = git.forRepo('/path/to/repo')!;\n * const branches = await repo.branches.getBranches();\n * const status = await repo.status.getStatus();\n * await repo.ops!.fetch({ remote: 'origin' });\n *\n * git.dispose(); // cleans up provider, cache, and module-level state\n * ```\n */\nexport function createCliGitService(options: CliGitServiceOptions): GitService {\n\tconst service = GitService.createSingleton(options.watchingProvider, {\n\t\twatchPolling: options.watchPolling,\n\t\tverifyBaseRemeasure: options.verifyBaseRemeasure,\n\t\t// The host's file system reads the shared `.git/config` the watch service compares reports of\n\t\treadFile: path => options.context.fs.readFile(fileUri(path)),\n\t\t// And lists the directory the admin entries of its worktrees are in\n\t\treadDirectory: path => options.context.fs.readDirectory(fileUri(path)),\n\t});\n\n\tconst locator = options.locator ?? (() => findGitPath(options.gitPath ?? null));\n\tconst provider = new CliGitProvider({\n\t\tcontext: options.context,\n\t\tlocator: locator,\n\t\tgitOptions: options.gitOptions,\n\t\tcache: options.cache,\n\t\tignoredWorktreeFolders: options.ignoredWorktreeFolders,\n\t\trefreshIndexAfterWrites: options.refreshIndexAfterWrites,\n\t});\n\n\tservice.register(provider, () => true);\n\n\tif (options.validateUnwatchedCaches) {\n\t\tconst fs = options.context.fs;\n\t\tconst validator = new UnwatchedCacheValidator({\n\t\t\tcache: provider.cache,\n\t\t\ttimeoutMs:\n\t\t\t\ttypeof options.validateUnwatchedCaches === 'object'\n\t\t\t\t\t? options.validateUnwatchedCaches.timeoutMs\n\t\t\t\t\t: undefined,\n\t\t\tmaxFsThreads: getThreadPoolSize() - 2,\n\t\t\tstat: async path => {\n\t\t\t\ttry {\n\t\t\t\t\tconst stat = await fs.stat(fileUri(path));\n\t\t\t\t\treturn stat != null ? { mtime: stat.mtime, size: stat.size } : undefined;\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tif (isNotFound(ex)) return undefined;\n\n\t\t\t\t\tthrow ex;\n\t\t\t\t}\n\t\t\t},\n\t\t\treadDirectory: path => fs.readDirectory(fileUri(path)),\n\t\t\treadFile: async path => {\n\t\t\t\ttry {\n\t\t\t\t\treturn await fs.readFile(fileUri(path));\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tif (isNotFound(ex)) return undefined;\n\n\t\t\t\t\tthrow ex;\n\t\t\t\t}\n\t\t\t},\n\t\t\t// Only for a path whose git dir is cached, which it finds the common git dir from without running git\n\t\t\tgetIgnoredWorktreeRoots: repoPath =>\n\t\t\t\tprovider.cache.gitDir.get(repoPath) != null\n\t\t\t\t\t? provider.getIgnoredWorktreeRoots(repoPath)\n\t\t\t\t\t: Promise.resolve([]),\n\t\t\tresolveGitDir: repoPath => provider.config.resolveGitDirWithoutGit(repoPath),\n\t\t\t// The watch service keys repositories as the cache does (`getRepositoryKey` normalizes a file path alike)\n\t\t\tisWatched: repoPath => service.watchService?.isRepoWatched(repoPath) ?? false,\n\t\t});\n\t\tprovider.cache.setReadValidator(\n\t\t\trepoPath => validator.validate(repoPath),\n\t\t\t() => validator.getResourceUsage(),\n\t\t);\n\t\tservice.watchService?.onDidChangeRepoWatched(e => {\n\t\t\tif (e.watched) {\n\t\t\t\tvalidator.onWatched(e.repoPath);\n\t\t\t} else {\n\t\t\t\tvalidator.onUnwatched(e.repoPath);\n\t\t\t}\n\t\t});\n\t}\n\n\t// Advance the provider cache's status generation clock from the watch session's global events — the standalone\n\t// analogue of what the VS Code host wires in `GitProviderService`. Without this, a consumer that passes a\n\t// `watchingProvider` and drives watch sessions gets FS events but a FROZEN clock, so `dedupeByStatusGeneration`\n\t// degrades to the pre-change/post-change stale-join this branch exists to fix. Standalone has no `Repository`\n\t// models, so there are no force-fired `closed`/`lastFetched` bypassing the session for the global repo event to\n\t// miss. Subscriptions are torn down with the service (its `watchService`'s emitters are disposed on dispose).\n\tservice.watchService?.onDidChangeWorkingTree(repoPath => provider.cache.onWorkingTreeChanged(repoPath));\n\t// Announced kinds were evicted when core announced its write; evicting them again would discard what the host\n\t// re-read since\n\tservice.watchService?.onDidChangeRepository(e => {\n\t\tconst changes = e.getUnannouncedChanges();\n\t\tif (changes.length) {\n\t\t\tprovider.cache.onRepositoryChanged(e.repoPath, changes, { movedWorktrees: e.movedWorktrees });\n\t\t}\n\t});\n\t// FETCH_HEAD maps to no session change, and there's no `Repository` model here to force-fire `lastFetched` (as\n\t// the VS Code host does), so bridge it straight to the cache or the last-fetched time is never re-read.\n\tservice.watchService?.onDidChangeFetchHead(repoPath =>\n\t\tprovider.cache.onRepositoryChanged(repoPath, ['lastFetched']),\n\t);\n\treturn service;\n}\n\n/** The size of libuv's thread pool, which runs Node's file-system calls, as libuv reads it at its first use */\nfunction getThreadPoolSize(): number {\n\tconst size = Number.parseInt(env.UV_THREADPOOL_SIZE ?? '', 10);\n\treturn Number.isNaN(size) ? 4 : Math.min(Math.max(size, 1), 1024);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAuGA,SAAgB,oBAAoB,SAA2C;CAC9E,MAAM,UAAU,WAAW,gBAAgB,QAAQ,kBAAkB;EACpE,cAAc,QAAQ;EACtB,qBAAqB,QAAQ;EAE7B,WAAU,SAAQ,QAAQ,QAAQ,GAAG,SAAS,QAAQ,IAAI,CAAC;EAE3D,gBAAe,SAAQ,QAAQ,QAAQ,GAAG,cAAc,QAAQ,IAAI,CAAC;CACtE,CAAC;CAED,MAAM,UAAU,QAAQ,kBAAkB,YAAY,QAAQ,WAAW,IAAI;CAC7E,MAAM,WAAW,IAAI,eAAe;EACnC,SAAS,QAAQ;EACR;EACT,YAAY,QAAQ;EACpB,OAAO,QAAQ;EACf,wBAAwB,QAAQ;EAChC,yBAAyB,QAAQ;CAClC,CAAC;CAED,QAAQ,SAAS,gBAAgB,IAAI;CAErC,IAAI,QAAQ,yBAAyB;EACpC,MAAM,KAAK,QAAQ,QAAQ;EAC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,UAAU,SAAS,EAAE,gBAAgB,EAAE,eAAe,CAAC;CAE9F,CAAC;CAGD,QAAQ,cAAc,sBAAqB,aAC1C,SAAS,MAAM,oBAAoB,UAAU,CAAC,aAAa,CAAC,CAC7D;CACA,OAAO;AACR;;AAGA,SAAS,oBAA4B;CACpC,MAAM,OAAO,OAAO,SAAS,IAAI,sBAAsB,IAAI,EAAE;CAC7D,OAAO,OAAO,MAAM,IAAI,IAAI,IAAI,KAAK,IAAI,KAAK,IAAI,MAAM,CAAC,GAAG,IAAI;AACjE"}
|
|
1
|
+
{"version":3,"file":"service.js","names":[],"sources":["../../../git-cli/src/service.ts"],"sourcesContent":["import { env } from 'node:process';\nimport { GitService } from '@gitlens/git/service.js';\nimport type { FileWatchingProvider } from '@gitlens/git/watching/provider.js';\nimport { UnwatchedCacheValidator } from '@gitlens/git/watching/unwatchedCacheValidator.js';\nimport { isNotFound } from '@gitlens/git/watching/watchGroup.js';\nimport type { WatchPollingOptions } from '@gitlens/git/watching/watchService.js';\nimport type { WorktreeSummaryServiceOptions } from '@gitlens/git/watching/worktreeSummary.js';\nimport { fileUri } from '@gitlens/utils/uri.js';\nimport type { CliGitProviderOptions } from './cliGitProvider.js';\nimport { CliGitProvider } from './cliGitProvider.js';\nimport type { GitLocation } from './exec/locator.js';\nimport { findGitPath } from './exec/locator.js';\n\n/**\n * Options for {@link createCliGitService}.\n */\nexport interface CliGitServiceOptions {\n\t/**\n\t * Path(s) to the git binary.\n\t * Auto-detected if omitted (searches PATH, platform-specific locations).\n\t * Ignored when {@link locator} is provided.\n\t */\n\tgitPath?: string | string[];\n\n\t/**\n\t * Custom git binary resolver. When provided, used instead of the\n\t * default `findGitPath(gitPath)` lookup.\n\t */\n\tlocator?: () => Promise<GitLocation>;\n\n\t/** Host-provided context hooks (cache events, workspace, integrations, telemetry, fs) */\n\tcontext: CliGitProviderOptions['context'];\n\n\t/**\n\t * Git execution options passed through to the underlying Git executor. `gitOptions.isTrusted(repoPath)` is the\n\t * per-repository trust gate: a `false` answer rejects git runs in that path with `WorkspaceUntrustedError` before\n\t * any process starts. It applies only when `context.workspace.isTrusted` is unset; that flag wins when present.\n\t */\n\tgitOptions?: CliGitProviderOptions['gitOptions'];\n\n\t/** Use an existing Cache instance, or one will be created */\n\tcache?: CliGitProviderOptions['cache'];\n\n\t/** Folders, relative to a repository's common git dir, whose worktrees core acts as if didn't exist */\n\tignoredWorktreeFolders?: CliGitProviderOptions['ignoredWorktreeFolders'];\n\n\t/** Refreshes a checkout's index after core's own writes rewrote it (see `CliGitProviderOptions`); off by default */\n\trefreshIndexAfterWrites?: CliGitProviderOptions['refreshIndexAfterWrites'];\n\n\t/**\n\t * Filesystem watching provider. When provided, the {@link GitService}\n\t * will watch repositories for changes (file creates, edits, deletes).\n\t */\n\twatchingProvider?: FileWatchingProvider;\n\n\t/**\n\t * Polls in place of (or beside) the watchers {@link watchingProvider} reports it can't trust. When omitted, no\n\t * watcher is asked.\n\t */\n\twatchPolling?: WatchPollingOptions;\n\n\t/**\n\t * Keeps the caches that never expire (branches, current branch, refs, tags, remotes, worktrees, stashes, gk config,\n\t * paused operation, and what derives from them) fresh for repositories whose `.git` directory nothing watches:\n\t * before such a read, stats the files a watcher would have reported, and lists the ref directories and worktree\n\t * admin entries, applying what moved as a watcher event would. Files git writes by rename are read only once the\n\t * directory they're in moved, so a read of an idle repository costs a stat per git dir, per ref directory, per\n\t * linked worktree and per file git writes in place, at most once per 250ms per repository; a watched one costs\n\t * nothing, unless its watch is suspended, which holds what it hears until it resumes. Never runs git: a repository\n\t * whose git dir nothing resolved yet is read from its own files, and one whose files can't show it (bare, a\n\t * submodule, `--separate-git-dir`, `core.worktree`) isn't validated until a read resolves it, its files looked at\n\t * again every 30 seconds. What moves in a worktree under an {@link ignoredWorktreeFolders} folder clears nothing. Without a\n\t * {@link watchingProvider}, every repository counts as unwatched. A read waits at most `timeoutMs` (default 1000)\n\t * for the stats, then is served from the cache, and the stats run one at a time per repository and two at once\n\t * overall. A stat on a hung mount holds one of Node's file-system threads until it returns; one outstanding past\n\t * `timeoutMs` lets other repositories' stats go on, as long as the stats hold all but two of the threads\n\t * (`UV_THREADPOOL_SIZE`, default 4), which leaves the host two. Off by default.\n\t */\n\tvalidateUnwatchedCaches?: boolean | { readonly timeoutMs?: number };\n\n\t/** For tests only; production never passes it (see `WorktreeSummaryServiceOptions.verifyBaseRemeasure`) */\n\tverifyBaseRemeasure?: WorktreeSummaryServiceOptions['verifyBaseRemeasure'];\n}\n\n/**\n * Creates a ready-to-use {@link GitService} backed by the CLI git provider.\n *\n * This is the primary entry point for standalone (non-VS Code) consumers\n * of the `@gitlens/git-cli` library. It creates a singleton {@link GitService},\n * wires up a {@link CliGitProvider}, and registers it for all repository paths.\n *\n * @example\n * ```typescript\n * const git = createCliGitService({ context: {} });\n *\n * const repo = git.forRepo('/path/to/repo')!;\n * const branches = await repo.branches.getBranches();\n * const status = await repo.status.getStatus();\n * await repo.ops!.fetch({ remote: 'origin' });\n *\n * git.dispose(); // cleans up provider, cache, and module-level state\n * ```\n *\n * The cache shares a repository's data between its checkouts only once each checkout is registered\n * (`cache.registerRepoPath`). A host that registers checkouts in the background can have each one registered before\n * its first read through `forRepo` by setting a registrar once it has the service (see\n * `Cache.setRepoPathRegistrar`; `undefined` declines a path):\n *\n * ```typescript\n * cache.setRepoPathRegistrar(path =>\n * \tisKnownCheckout(path)\n * \t\t? git.forRepo(path)!.config.getGitDir!().then(gitDir => {\n * \t\t\t\tif (gitDir != null) cache.registerRepoPath(fileUri(path), gitDir);\n * \t\t\t})\n * \t\t: undefined,\n * );\n * ```\n */\nexport function createCliGitService(options: CliGitServiceOptions): GitService {\n\tconst service = GitService.createSingleton(options.watchingProvider, {\n\t\twatchPolling: options.watchPolling,\n\t\tverifyBaseRemeasure: options.verifyBaseRemeasure,\n\t\t// The host's file system reads the shared `.git/config` the watch service compares reports of\n\t\treadFile: path => options.context.fs.readFile(fileUri(path)),\n\t\t// And lists the directory the admin entries of its worktrees are in\n\t\treadDirectory: path => options.context.fs.readDirectory(fileUri(path)),\n\t});\n\n\tconst locator = options.locator ?? (() => findGitPath(options.gitPath ?? null));\n\tconst provider = new CliGitProvider({\n\t\tcontext: options.context,\n\t\tlocator: locator,\n\t\tgitOptions: options.gitOptions,\n\t\tcache: options.cache,\n\t\tignoredWorktreeFolders: options.ignoredWorktreeFolders,\n\t\trefreshIndexAfterWrites: options.refreshIndexAfterWrites,\n\t});\n\n\tservice.register(provider, () => true);\n\n\tif (options.validateUnwatchedCaches) {\n\t\tconst fs = options.context.fs;\n\t\tconst validator = new UnwatchedCacheValidator({\n\t\t\tcache: provider.cache,\n\t\t\ttimeoutMs:\n\t\t\t\ttypeof options.validateUnwatchedCaches === 'object'\n\t\t\t\t\t? options.validateUnwatchedCaches.timeoutMs\n\t\t\t\t\t: undefined,\n\t\t\tmaxFsThreads: getThreadPoolSize() - 2,\n\t\t\tstat: async path => {\n\t\t\t\ttry {\n\t\t\t\t\tconst stat = await fs.stat(fileUri(path));\n\t\t\t\t\treturn stat != null ? { mtime: stat.mtime, size: stat.size } : undefined;\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tif (isNotFound(ex)) return undefined;\n\n\t\t\t\t\tthrow ex;\n\t\t\t\t}\n\t\t\t},\n\t\t\treadDirectory: path => fs.readDirectory(fileUri(path)),\n\t\t\treadFile: async path => {\n\t\t\t\ttry {\n\t\t\t\t\treturn await fs.readFile(fileUri(path));\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tif (isNotFound(ex)) return undefined;\n\n\t\t\t\t\tthrow ex;\n\t\t\t\t}\n\t\t\t},\n\t\t\t// Only for a path whose git dir is cached, which it finds the common git dir from without running git\n\t\t\tgetIgnoredWorktreeRoots: repoPath =>\n\t\t\t\tprovider.cache.gitDir.get(repoPath) != null\n\t\t\t\t\t? provider.getIgnoredWorktreeRoots(repoPath)\n\t\t\t\t\t: Promise.resolve([]),\n\t\t\tresolveGitDir: repoPath => provider.config.resolveGitDirWithoutGit(repoPath),\n\t\t\t// The watch service keys repositories as the cache does (`getRepositoryKey` normalizes a file path alike)\n\t\t\tisWatched: repoPath => service.watchService?.isRepoWatched(repoPath) ?? false,\n\t\t});\n\t\tprovider.cache.setReadValidator(\n\t\t\trepoPath => validator.validate(repoPath),\n\t\t\t() => validator.getResourceUsage(),\n\t\t);\n\t\tservice.watchService?.onDidChangeRepoWatched(e => {\n\t\t\tif (e.watched) {\n\t\t\t\tvalidator.onWatched(e.repoPath);\n\t\t\t} else {\n\t\t\t\tvalidator.onUnwatched(e.repoPath);\n\t\t\t}\n\t\t});\n\t}\n\n\t// Advance the provider cache's status generation clock from the watch session's global events — the standalone\n\t// analogue of what the VS Code host wires in `GitProviderService`. Without this, a consumer that passes a\n\t// `watchingProvider` and drives watch sessions gets FS events but a FROZEN clock, so `dedupeByStatusGeneration`\n\t// degrades to the pre-change/post-change stale-join this branch exists to fix. Standalone has no `Repository`\n\t// models, so there are no force-fired `closed`/`lastFetched` bypassing the session for the global repo event to\n\t// miss. Subscriptions are torn down with the service (its `watchService`'s emitters are disposed on dispose).\n\tservice.watchService?.onDidChangeWorkingTree(repoPath => provider.cache.onWorkingTreeChanged(repoPath));\n\t// Announced kinds were evicted when core announced its write; evicting them again would discard what the host\n\t// re-read since\n\tservice.watchService?.onDidChangeRepository(e => {\n\t\tconst changes = e.getUnannouncedChanges();\n\t\tif (changes.length) {\n\t\t\tprovider.cache.onRepositoryChanged(e.repoPath, changes, {\n\t\t\t\tmovedWorktrees: e.movedWorktrees,\n\t\t\t\tobservedAt: e.observedAt,\n\t\t\t});\n\t\t}\n\t});\n\t// FETCH_HEAD maps to no session change, and there's no `Repository` model here to force-fire `lastFetched` (as\n\t// the VS Code host does), so bridge it straight to the cache or the last-fetched time is never re-read.\n\tservice.watchService?.onDidChangeFetchHead(repoPath =>\n\t\tprovider.cache.onRepositoryChanged(repoPath, ['lastFetched']),\n\t);\n\treturn service;\n}\n\n/** The size of libuv's thread pool, which runs Node's file-system calls, as libuv reads it at its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RequestSearchResult | undefined>;
|
|
667
|
+
/**
|
|
668
|
+
* The exact opened + merged state set is ordered newest-created first, overriding unquoted `sort:` qualifiers
|
|
669
|
+
* in the search text. Other state sets keep GitHub's order, including any caller-supplied sort.
|
|
670
|
+
*/
|
|
667
671
|
searchPullRequests(provider: Provider, token: GitHubTokenInfo, options?: {
|
|
668
672
|
search?: string;
|
|
669
673
|
user?: string;
|
|
@@ -3218,11 +3218,16 @@ var GitHubApi = class {
|
|
|
3218
3218
|
throw this.handleException(ex, provider, scope);
|
|
3219
3219
|
}
|
|
3220
3220
|
}
|
|
3221
|
+
/**
|
|
3222
|
+
* The exact opened + merged state set is ordered newest-created first, overriding unquoted `sort:` qualifiers
|
|
3223
|
+
* in the search text. Other state sets keep GitHub's order, including any caller-supplied sort.
|
|
3224
|
+
*/
|
|
3221
3225
|
async searchPullRequests(provider, token, options, cancellation) {
|
|
3222
3226
|
const scope = getScopedLogger();
|
|
3223
3227
|
const pageSize = 10;
|
|
3224
3228
|
const include = options?.include?.length ? options.include : void 0;
|
|
3225
|
-
const
|
|
3229
|
+
const splitStates = requiresGitHubPullRequestStateFacets(include);
|
|
3230
|
+
const stateSearches = splitStates ? [{
|
|
3226
3231
|
alias: "opened",
|
|
3227
3232
|
qualifier: "is:open"
|
|
3228
3233
|
}, {
|
|
@@ -3256,6 +3261,10 @@ var GitHubApi = class {
|
|
|
3256
3261
|
${fields.join("\n ")}
|
|
3257
3262
|
}`;
|
|
3258
3263
|
let search = options?.search?.trim() ?? "";
|
|
3264
|
+
if (splitStates) {
|
|
3265
|
+
search = search.replace(/"(?:\\.|[^"\\])*"|(?:^|\s)sort:(?:"(?:\\.|[^"\\])*"|[^\s"]*)/gi, (match) => match.startsWith("\"") ? match : "");
|
|
3266
|
+
search = `${search.trim()} sort:created-desc`.trim();
|
|
3267
|
+
}
|
|
3259
3268
|
if (options?.user) search += ` user:${options.user}`;
|
|
3260
3269
|
if (options?.repos != null && options.repos.length > 0) {
|
|
3261
3270
|
const repo = " repo:";
|
|
@@ -3278,6 +3287,7 @@ var GitHubApi = class {
|
|
|
3278
3287
|
if (rsp == null) return [];
|
|
3279
3288
|
const results = [];
|
|
3280
3289
|
for (const { alias } of stateSearches) for (const node of rsp[alias]?.nodes ?? []) results.push(fromGitHubPullRequest(node, provider, "text-search"));
|
|
3290
|
+
if (splitStates) results.sort(getPullRequestComparator("created:desc"));
|
|
3281
3291
|
return [...uniqueBy(filterPullRequestsBySearchState(results, include), (pr) => pr.url, (original, _current) => original)].slice(0, pageSize);
|
|
3282
3292
|
} catch (ex) {
|
|
3283
3293
|
throw this.handleException(ex, provider, scope);
|