@gitkraken/core-gitlens 0.32.0 → 0.33.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 +27 -1
- package/dist/git/cache.d.ts +90 -15
- package/dist/git/cache.js +215 -44
- package/dist/git/cache.js.map +1 -1
- package/dist/git/models/repositoryIdentities.d.ts +0 -1
- package/dist/git/models/repositoryIdentities.js +1 -4
- package/dist/git/models/repositoryIdentities.js.map +1 -1
- package/dist/git/providers/provider.d.ts +7 -0
- package/dist/git/remotes/gitlab.js +15 -9
- package/dist/git/remotes/gitlab.js.map +1 -1
- package/dist/git/service.js +4 -1
- package/dist/git/service.js.map +1 -1
- package/dist/git/utils/repository.utils.d.ts +10 -0
- package/dist/git/utils/repository.utils.js +25 -2
- package/dist/git/utils/repository.utils.js.map +1 -1
- package/dist/git/watching/changeEvent.d.ts +13 -3
- package/dist/git/watching/changeEvent.js +19 -4
- package/dist/git/watching/changeEvent.js.map +1 -1
- package/dist/git/watching/watchGroup.d.ts +4 -2
- package/dist/git/watching/watchGroup.js +32 -17
- package/dist/git/watching/watchGroup.js.map +1 -1
- package/dist/git/watching/watchService.d.ts +4 -1
- package/dist/git/watching/watchService.js +18 -15
- package/dist/git/watching/watchService.js.map +1 -1
- package/dist/git/watching/watchSession.d.ts +27 -12
- package/dist/git/watching/watchSession.js +49 -19
- package/dist/git/watching/watchSession.js.map +1 -1
- package/dist/git/watching/worktreeSummary.js +7 -7
- package/dist/git/watching/worktreeSummary.js.map +1 -1
- package/dist/git-cli/cliGitProvider.d.ts +28 -2
- package/dist/git-cli/cliGitProvider.js +62 -19
- package/dist/git-cli/cliGitProvider.js.map +1 -1
- package/dist/git-cli/exec/git.js +7 -2
- package/dist/git-cli/exec/git.js.map +1 -1
- package/dist/git-cli/providers/branches.js +15 -10
- package/dist/git-cli/providers/branches.js.map +1 -1
- package/dist/git-cli/providers/config.d.ts +2 -0
- package/dist/git-cli/providers/config.js +19 -8
- package/dist/git-cli/providers/config.js.map +1 -1
- package/dist/git-cli/providers/worktrees.js +34 -10
- package/dist/git-cli/providers/worktrees.js.map +1 -1
- package/dist/git-cli/service.js +1 -1
- package/dist/git-cli/service.js.map +1 -1
- package/dist/plus/integrations/models/integration.js +1 -1
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/gitlab.d.ts +10 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.js +62 -15
- package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.d.ts +8 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.js +32 -16
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -71,6 +71,5 @@ export interface RepositoryIdentityResponse {
|
|
|
71
71
|
readonly repoOwnerDomain?: string;
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
-
export declare function getPathFromProviderIdentity<ID extends string | GkProviderId>(provider: RepositoryIdentityProviderDescriptor<ID>): string;
|
|
75
74
|
//#endregion
|
|
76
75
|
//# sourceMappingURL=repositoryIdentities.d.ts.map
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
//#region ../git/src/models/repositoryIdentities.ts
|
|
2
2
|
const missingRepositoryId = "-";
|
|
3
|
-
function getPathFromProviderIdentity(provider) {
|
|
4
|
-
return provider.repoOwnerDomain ? `${provider.repoOwnerDomain}/${provider.repoDomain}/${provider.repoName}` : `${provider.repoDomain}/${provider.repoName}`;
|
|
5
|
-
}
|
|
6
3
|
//#endregion
|
|
7
|
-
export {
|
|
4
|
+
export { missingRepositoryId };
|
|
8
5
|
|
|
9
6
|
//# sourceMappingURL=repositoryIdentities.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repositoryIdentities.js","names":[],"sources":["../../../../git/src/models/repositoryIdentities.ts"],"sourcesContent":["import type { Branded, Unbrand } from '@gitlens/utils/brand.js';\nimport type { HostingServiceType } from '@gitlens/utils/hostingServiceType.js';\n\nexport const missingRepositoryId = '-';\n\nexport type GkProviderId = Branded<\n\t'github' | 'githubEnterprise' | 'gitlab' | 'gitlabSelfHosted' | 'bitbucket' | 'bitbucketServer' | 'azureDevops',\n\t'GkProviderId'\n>;\nexport type GkRepositoryId = Branded<string, 'GkRepositoryId'>;\n\n// `@gitlens/utils` can't import this package, so `HostingServiceType` copies the list above; this fails\n// to compile the moment the two drift.\ntype AssertTrue<T extends true> = T;\nexport type GkProviderIdMirrorsHostingServiceType = AssertTrue<\n\tUnbrand<GkProviderId> extends HostingServiceType\n\t\t? HostingServiceType extends Unbrand<GkProviderId>\n\t\t\t? true\n\t\t\t: false\n\t\t: false\n>;\n\nexport interface RepositoryIdentityRemoteDescriptor {\n\treadonly url?: string;\n\treadonly domain?: string;\n\treadonly path?: string;\n}\n\nexport interface RepositoryIdentityProviderDescriptor<ID extends string | GkProviderId = GkProviderId> {\n\treadonly id?: ID;\n\treadonly domain?: string;\n\treadonly repoDomain?: string;\n\treadonly repoName?: string;\n\treadonly repoOwnerDomain?: string;\n}\n\n// TODO: replace this string with GkProviderId eventually once we wrangle our backend provider ids\nexport interface RepositoryIdentityDescriptor<ID extends string | GkProviderId = GkProviderId> {\n\treadonly name: string;\n\n\treadonly initialCommitSha?: string;\n\treadonly remote?: RepositoryIdentityRemoteDescriptor;\n\treadonly provider?: RepositoryIdentityProviderDescriptor<ID>;\n}\n\nexport interface RepositoryIdentity extends RepositoryIdentityDescriptor {\n\treadonly id: GkRepositoryId;\n\treadonly createdAt: Date;\n\treadonly updatedAt: Date;\n}\n\ntype BaseRepositoryIdentityRequest = {\n\t// name: string;\n\tinitialCommitSha?: string;\n};\n\ntype BaseRepositoryIdentityRequestWithCommitSha = BaseRepositoryIdentityRequest & {\n\tinitialCommitSha: string;\n};\n\ntype BaseRepositoryIdentityRequestWithRemote = BaseRepositoryIdentityRequest & {\n\tremote: { url: string; domain: string; path: string };\n};\n\ntype BaseRepositoryIdentityRequestWithRemoteProvider = BaseRepositoryIdentityRequestWithRemote & {\n\tprovider: {\n\t\tid: GkProviderId;\n\t\trepoDomain: string;\n\t\trepoName: string;\n\t\trepoOwnerDomain?: string;\n\t};\n};\n\ntype BaseRepositoryIdentityRequestWithoutRemoteProvider = BaseRepositoryIdentityRequestWithRemote & {\n\tprovider?: never;\n};\n\nexport type RepositoryIdentityRequest =\n\t| BaseRepositoryIdentityRequestWithCommitSha\n\t| BaseRepositoryIdentityRequestWithRemote\n\t| BaseRepositoryIdentityRequestWithRemoteProvider\n\t| BaseRepositoryIdentityRequestWithoutRemoteProvider;\n\nexport interface RepositoryIdentityResponse {\n\treadonly id: GkRepositoryId;\n\treadonly createdAt: string;\n\treadonly updatedAt: string;\n\n\t// readonly name: string;\n\n\treadonly initialCommitSha?: string;\n\treadonly remote?: {\n\t\treadonly url?: string;\n\t\treadonly domain?: string;\n\t\treadonly path?: string;\n\t};\n\treadonly provider?: {\n\t\treadonly id?: GkProviderId;\n\t\treadonly repoDomain?: string;\n\t\treadonly repoName?: string;\n\t\treadonly repoOwnerDomain?: string;\n\t};\n}\n
|
|
1
|
+
{"version":3,"file":"repositoryIdentities.js","names":[],"sources":["../../../../git/src/models/repositoryIdentities.ts"],"sourcesContent":["import type { Branded, Unbrand } from '@gitlens/utils/brand.js';\nimport type { HostingServiceType } from '@gitlens/utils/hostingServiceType.js';\n\nexport const missingRepositoryId = '-';\n\nexport type GkProviderId = Branded<\n\t'github' | 'githubEnterprise' | 'gitlab' | 'gitlabSelfHosted' | 'bitbucket' | 'bitbucketServer' | 'azureDevops',\n\t'GkProviderId'\n>;\nexport type GkRepositoryId = Branded<string, 'GkRepositoryId'>;\n\n// `@gitlens/utils` can't import this package, so `HostingServiceType` copies the list above; this fails\n// to compile the moment the two drift.\ntype AssertTrue<T extends true> = T;\nexport type GkProviderIdMirrorsHostingServiceType = AssertTrue<\n\tUnbrand<GkProviderId> extends HostingServiceType\n\t\t? HostingServiceType extends Unbrand<GkProviderId>\n\t\t\t? true\n\t\t\t: false\n\t\t: false\n>;\n\nexport interface RepositoryIdentityRemoteDescriptor {\n\treadonly url?: string;\n\treadonly domain?: string;\n\treadonly path?: string;\n}\n\nexport interface RepositoryIdentityProviderDescriptor<ID extends string | GkProviderId = GkProviderId> {\n\treadonly id?: ID;\n\treadonly domain?: string;\n\treadonly repoDomain?: string;\n\treadonly repoName?: string;\n\treadonly repoOwnerDomain?: string;\n}\n\n// TODO: replace this string with GkProviderId eventually once we wrangle our backend provider ids\nexport interface RepositoryIdentityDescriptor<ID extends string | GkProviderId = GkProviderId> {\n\treadonly name: string;\n\n\treadonly initialCommitSha?: string;\n\treadonly remote?: RepositoryIdentityRemoteDescriptor;\n\treadonly provider?: RepositoryIdentityProviderDescriptor<ID>;\n}\n\nexport interface RepositoryIdentity extends RepositoryIdentityDescriptor {\n\treadonly id: GkRepositoryId;\n\treadonly createdAt: Date;\n\treadonly updatedAt: Date;\n}\n\ntype BaseRepositoryIdentityRequest = {\n\t// name: string;\n\tinitialCommitSha?: string;\n};\n\ntype BaseRepositoryIdentityRequestWithCommitSha = BaseRepositoryIdentityRequest & {\n\tinitialCommitSha: string;\n};\n\ntype BaseRepositoryIdentityRequestWithRemote = BaseRepositoryIdentityRequest & {\n\tremote: { url: string; domain: string; path: string };\n};\n\ntype BaseRepositoryIdentityRequestWithRemoteProvider = BaseRepositoryIdentityRequestWithRemote & {\n\tprovider: {\n\t\tid: GkProviderId;\n\t\trepoDomain: string;\n\t\trepoName: string;\n\t\trepoOwnerDomain?: string;\n\t};\n};\n\ntype BaseRepositoryIdentityRequestWithoutRemoteProvider = BaseRepositoryIdentityRequestWithRemote & {\n\tprovider?: never;\n};\n\nexport type RepositoryIdentityRequest =\n\t| BaseRepositoryIdentityRequestWithCommitSha\n\t| BaseRepositoryIdentityRequestWithRemote\n\t| BaseRepositoryIdentityRequestWithRemoteProvider\n\t| BaseRepositoryIdentityRequestWithoutRemoteProvider;\n\nexport interface RepositoryIdentityResponse {\n\treadonly id: GkRepositoryId;\n\treadonly createdAt: string;\n\treadonly updatedAt: string;\n\n\t// readonly name: string;\n\n\treadonly initialCommitSha?: string;\n\treadonly remote?: {\n\t\treadonly url?: string;\n\t\treadonly domain?: string;\n\t\treadonly path?: string;\n\t};\n\treadonly provider?: {\n\t\treadonly id?: GkProviderId;\n\t\treadonly repoDomain?: string;\n\t\treadonly repoName?: string;\n\t\treadonly repoOwnerDomain?: string;\n\t};\n}\n"],"mappings":";AAGA,MAAa,sBAAsB"}
|
|
@@ -36,6 +36,13 @@ export interface AnnouncedRepositoryChanges {
|
|
|
36
36
|
* see `GitServiceHooks.repository.onChanged`
|
|
37
37
|
*/
|
|
38
38
|
readonly configConfinedToRefs?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* With `worktreeHead` among {@link changes}, the admin ids (the `<id>` of `.git/worktrees/<id>`) of the linked
|
|
41
|
+
* worktrees whose HEAD the write rewrote, or whose admin entry it added or removed; none for a write that moved only
|
|
42
|
+
* the main checkout's HEAD. A watcher's report of a linked worktree it doesn't name is taken for an outside move.
|
|
43
|
+
* Absent, the write may have moved any linked worktree's HEAD.
|
|
44
|
+
*/
|
|
45
|
+
readonly movedWorktrees?: readonly string[];
|
|
39
46
|
}
|
|
40
47
|
/**
|
|
41
48
|
* Common interface for all git providers (CLI, GitHub, etc.).
|
|
@@ -4,8 +4,13 @@ import __decorate from "../../_virtual/@oxc-project+runtime/helpers/esm/decorate
|
|
|
4
4
|
import { RemoteProvider, parseRefCandidates } from "../models/remoteProvider.js";
|
|
5
5
|
import * as l10n from "@vscode/l10n";
|
|
6
6
|
//#region ../git/src/remotes/gitlab.ts
|
|
7
|
-
const autolinkFullIssuesRegex = /\b([^/\s]+\/[^/\s]+?)(?:\\)?#([0-9]+)\b(?!]\()/g;
|
|
8
|
-
const autolinkFullMergeRequestsRegex = /\b([^/\s]+\/[^/\s]+?)(?:\\)?!([0-9]+)\b(?!]\()/g;
|
|
7
|
+
const autolinkFullIssuesRegex = /\b((?:[^/\s]+\/)+[^/\s]+?)(?:\\)?#([0-9]+)\b(?!]\()/g;
|
|
8
|
+
const autolinkFullMergeRequestsRegex = /\b((?:[^/\s]+\/)+[^/\s]+?)(?:\\)?!([0-9]+)\b(?!]\()/g;
|
|
9
|
+
/** Splits at the last slash: the owner is the whole namespace (`group/subgroup`) and the name is the project */
|
|
10
|
+
function splitNamespaceAndName(path) {
|
|
11
|
+
const index = path.lastIndexOf("/");
|
|
12
|
+
return [path.substring(0, index), path.substring(index + 1)];
|
|
13
|
+
}
|
|
9
14
|
var GitLabRemoteProvider = class GitLabRemoteProvider extends RemoteProvider {
|
|
10
15
|
get apiBaseUrl() {
|
|
11
16
|
return this.custom ? `${this.protocol}://${this.domain}/api` : `https://${this.domain}/api`;
|
|
@@ -69,7 +74,7 @@ var GitLabRemoteProvider = class GitLabRemoteProvider extends RemoteProvider {
|
|
|
69
74
|
match = autolinkFullIssuesRegex.exec(text);
|
|
70
75
|
if (match == null) break;
|
|
71
76
|
[, ownerAndRepo, num] = match;
|
|
72
|
-
const [owner, repo] = ownerAndRepo
|
|
77
|
+
const [owner, repo] = splitNamespaceAndName(ownerAndRepo);
|
|
73
78
|
autolinks.set(num, {
|
|
74
79
|
provider: this,
|
|
75
80
|
id: num,
|
|
@@ -120,7 +125,7 @@ var GitLabRemoteProvider = class GitLabRemoteProvider extends RemoteProvider {
|
|
|
120
125
|
match = autolinkFullMergeRequestsRegex.exec(text);
|
|
121
126
|
if (match == null) break;
|
|
122
127
|
[, ownerAndRepo, num] = match;
|
|
123
|
-
const [owner, repo] = ownerAndRepo
|
|
128
|
+
const [owner, repo] = splitNamespaceAndName(ownerAndRepo);
|
|
124
129
|
autolinks.set(num, {
|
|
125
130
|
provider: this,
|
|
126
131
|
id: num,
|
|
@@ -177,7 +182,7 @@ var GitLabRemoteProvider = class GitLabRemoteProvider extends RemoteProvider {
|
|
|
177
182
|
createPullRequestWithDetails: true
|
|
178
183
|
};
|
|
179
184
|
}
|
|
180
|
-
static fileRegex =
|
|
185
|
+
static fileRegex = /^\/-\/blob(.+)$/i;
|
|
181
186
|
static rangeRegex = /^L(\d+)(?:-(\d+))?$/;
|
|
182
187
|
parseRemoteFileUri(uri) {
|
|
183
188
|
if (uri.authority !== this.domain) return void 0;
|
|
@@ -194,9 +199,9 @@ var GitLabRemoteProvider = class GitLabRemoteProvider extends RemoteProvider {
|
|
|
194
199
|
}
|
|
195
200
|
}
|
|
196
201
|
}
|
|
197
|
-
const match = GitLabRemoteProvider.fileRegex.exec(uri.path);
|
|
202
|
+
const match = GitLabRemoteProvider.fileRegex.exec(uri.path.substring(this.path.length + 1));
|
|
198
203
|
if (match == null) return void 0;
|
|
199
|
-
const [,
|
|
204
|
+
const [, path] = match;
|
|
200
205
|
return parseRefCandidates(path, startLine, endLine);
|
|
201
206
|
}
|
|
202
207
|
getUrlForBranches() {
|
|
@@ -219,9 +224,10 @@ var GitLabRemoteProvider = class GitLabRemoteProvider extends RemoteProvider {
|
|
|
219
224
|
"merge_request[target_branch]": base.branch ?? ""
|
|
220
225
|
});
|
|
221
226
|
if (base.remote.url !== head.remote.url) {
|
|
227
|
+
const [owner, name] = splitNamespaceAndName(base.remote.path);
|
|
222
228
|
const repoInfo = await this.context?.getRepositoryInfo?.(this.id, {
|
|
223
|
-
owner
|
|
224
|
-
name
|
|
229
|
+
owner,
|
|
230
|
+
name
|
|
225
231
|
});
|
|
226
232
|
if (!repoInfo) return void 0;
|
|
227
233
|
query.set("merge_request[target_project_id]", repoInfo.id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlab.js","names":[],"sources":["../../../../git/src/remotes/gitlab.ts"],"sourcesContent":["import * as l10n from '@vscode/l10n';\nimport type { Brand, Unbrand } from '@gitlens/utils/brand.js';\nimport { memoize } from '@gitlens/utils/decorators/memoize.js';\nimport { equalsIgnoreCase } from '@gitlens/utils/string.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\nimport type { Autolink, AutolinkReference, DynamicAutolinkReference } from '../models/autolink.js';\nimport type { LineRange } from '../models/lineRange.js';\nimport type {\n\tParsedRemoteFileUri,\n\tRemoteProviderId,\n\tRemoteProviderSupportedFeatures,\n} from '../models/remoteProvider.js';\nimport { parseRefCandidates, RemoteProvider } from '../models/remoteProvider.js';\nimport type { CreatePullRequestRemoteResource } from '../models/remoteResource.js';\nimport type { GkProviderId } from '../models/repositoryIdentities.js';\nimport type { ResourceDescriptor } from '../models/resourceDescriptor.js';\nimport type { GitRevisionRangeNotation } from '../models/revision.js';\n\nexport interface GitLabRepositoryDescriptor extends ResourceDescriptor {\n\towner: string;\n\tname: string;\n}\n\nconst autolinkFullIssuesRegex = /\\b([^/\\s]+\\/[^/\\s]+?)(?:\\\\)?#([0-9]+)\\b(?!]\\()/g;\nconst autolinkFullMergeRequestsRegex = /\\b([^/\\s]+\\/[^/\\s]+?)(?:\\\\)?!([0-9]+)\\b(?!]\\()/g;\n\nexport class GitLabRemoteProvider extends RemoteProvider<GitLabRepositoryDescriptor> {\n\tget apiBaseUrl(): string {\n\t\treturn this.custom ? `${this.protocol}://${this.domain}/api` : `https://${this.domain}/api`;\n\t}\n\n\tprotected override get issueLinkPattern(): string {\n\t\treturn `${this.baseUrl}/-/issues/<num>`;\n\t}\n\n\tprivate _autolinks: (AutolinkReference | DynamicAutolinkReference)[] | undefined;\n\toverride get autolinks(): (AutolinkReference | DynamicAutolinkReference)[] {\n\t\tthis._autolinks ??= [\n\t\t\t...super.autolinks,\n\t\t\t{\n\t\t\t\tprefix: '#',\n\t\t\t\turl: this.issueLinkPattern,\n\t\t\t\talphanumeric: false,\n\t\t\t\tignoreCase: false,\n\t\t\t\ttitle: l10n.t('Open Issue #{number} on {provider}', { number: '<num>', provider: this.name }),\n\n\t\t\t\ttype: 'issue',\n\t\t\t\tdescription: l10n.t('{provider} Issue #{number}', { provider: this.name, number: '<num>' }),\n\t\t\t},\n\t\t\t{\n\t\t\t\tprefix: '!',\n\t\t\t\turl: `${this.baseUrl}/-/merge_requests/<num>`,\n\t\t\t\talphanumeric: false,\n\t\t\t\tignoreCase: false,\n\t\t\t\ttitle: l10n.t('Open Merge Request !{number} on {provider}', {\n\t\t\t\t\tnumber: '<num>',\n\t\t\t\t\tprovider: this.name,\n\t\t\t\t}),\n\n\t\t\t\ttype: 'pullrequest',\n\t\t\t\tdescription: l10n.t('{provider} Merge Request !{number}', {\n\t\t\t\t\tprovider: this.name,\n\t\t\t\t\tnumber: '<num>',\n\t\t\t\t}),\n\t\t\t},\n\t\t\t{\n\t\t\t\tdescriptors: [\n\t\t\t\t\t{\n\t\t\t\t\t\tregex: autolinkFullIssuesRegex,\n\t\t\t\t\t\turl: (repo, num) => `${this.protocol}://${this.domain}/${repo}/-/issues/${num}`,\n\t\t\t\t\t\ttitle: (repo, num) =>\n\t\t\t\t\t\t\tl10n.t('Open Issue #{number} from {repository} on {provider}', {\n\t\t\t\t\t\t\t\tnumber: num,\n\t\t\t\t\t\t\t\trepository: repo,\n\t\t\t\t\t\t\t\tprovider: this.name,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\tlabel: (repo, num) =>\n\t\t\t\t\t\t\tl10n.t('GitLab Issue {repository}#{number}', { repository: repo, number: num }),\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tparse: (text: string, autolinks: Map<string, Autolink>) => {\n\t\t\t\t\tlet ownerAndRepo: string;\n\t\t\t\t\tlet num: string;\n\n\t\t\t\t\tlet match;\n\t\t\t\t\tdo {\n\t\t\t\t\t\tmatch = autolinkFullIssuesRegex.exec(text);\n\t\t\t\t\t\tif (match == null) break;\n\n\t\t\t\t\t\t[, ownerAndRepo, num] = match;\n\n\t\t\t\t\t\tconst [owner, repo] = ownerAndRepo.split('/', 2);\n\t\t\t\t\t\tautolinks.set(num, {\n\t\t\t\t\t\t\tprovider: this,\n\t\t\t\t\t\t\tid: num,\n\t\t\t\t\t\t\tprefix: `${ownerAndRepo}#`,\n\t\t\t\t\t\t\turl: `${this.protocol}://${this.domain}/${ownerAndRepo}/-/issues/${num}`,\n\t\t\t\t\t\t\talphanumeric: false,\n\t\t\t\t\t\t\tignoreCase: true,\n\t\t\t\t\t\t\ttitle: l10n.t('Open Issue #{number} from {repository} on {provider}', {\n\t\t\t\t\t\t\t\tnumber: '<num>',\n\t\t\t\t\t\t\t\trepository: ownerAndRepo,\n\t\t\t\t\t\t\t\tprovider: this.name,\n\t\t\t\t\t\t\t}),\n\n\t\t\t\t\t\t\ttype: 'issue',\n\t\t\t\t\t\t\tdescription: l10n.t('{provider} Issue {repository}#{number}', {\n\t\t\t\t\t\t\t\tprovider: this.name,\n\t\t\t\t\t\t\t\trepository: ownerAndRepo,\n\t\t\t\t\t\t\t\tnumber: num,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tdescriptor: {\n\t\t\t\t\t\t\t\tkey: this.remoteKey,\n\t\t\t\t\t\t\t\towner: owner,\n\t\t\t\t\t\t\t\tname: repo,\n\t\t\t\t\t\t\t} satisfies GitLabRepositoryDescriptor,\n\t\t\t\t\t\t});\n\t\t\t\t\t} while (true);\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdescriptors: [\n\t\t\t\t\t{\n\t\t\t\t\t\tregex: autolinkFullMergeRequestsRegex,\n\t\t\t\t\t\turl: (repo, num) => `${this.protocol}://${this.domain}/${repo}/-/merge_requests/${num}`,\n\t\t\t\t\t\ttitle: (repo, num) =>\n\t\t\t\t\t\t\tl10n.t('Open Merge Request !{number} from {repository} on {provider}', {\n\t\t\t\t\t\t\t\tnumber: num,\n\t\t\t\t\t\t\t\trepository: repo,\n\t\t\t\t\t\t\t\tprovider: this.name,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\tlabel: (repo, num) =>\n\t\t\t\t\t\t\tl10n.t('{provider} Merge Request {repository}!{number}', {\n\t\t\t\t\t\t\t\tprovider: this.name,\n\t\t\t\t\t\t\t\trepository: repo,\n\t\t\t\t\t\t\t\tnumber: num,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tparse: (text: string, autolinks: Map<string, Autolink>) => {\n\t\t\t\t\tlet ownerAndRepo: string;\n\t\t\t\t\tlet num: string;\n\n\t\t\t\t\tlet match;\n\t\t\t\t\tdo {\n\t\t\t\t\t\tmatch = autolinkFullMergeRequestsRegex.exec(text);\n\t\t\t\t\t\tif (match == null) break;\n\n\t\t\t\t\t\t[, ownerAndRepo, num] = match;\n\n\t\t\t\t\t\tconst [owner, repo] = ownerAndRepo.split('/', 2);\n\t\t\t\t\t\tautolinks.set(num, {\n\t\t\t\t\t\t\tprovider: this,\n\t\t\t\t\t\t\tid: num,\n\t\t\t\t\t\t\tprefix: `${ownerAndRepo}!`,\n\t\t\t\t\t\t\turl: `${this.protocol}://${this.domain}/${ownerAndRepo}/-/merge_requests/${num}`,\n\t\t\t\t\t\t\talphanumeric: false,\n\t\t\t\t\t\t\tignoreCase: true,\n\t\t\t\t\t\t\ttitle: l10n.t('Open Merge Request !{number} from {repository} on {provider}', {\n\t\t\t\t\t\t\t\tnumber: '<num>',\n\t\t\t\t\t\t\t\trepository: ownerAndRepo,\n\t\t\t\t\t\t\t\tprovider: this.name,\n\t\t\t\t\t\t\t}),\n\n\t\t\t\t\t\t\ttype: 'pullrequest',\n\t\t\t\t\t\t\tdescription: l10n.t('{provider} Merge Request !{number} from {repository}', {\n\t\t\t\t\t\t\t\tprovider: this.name,\n\t\t\t\t\t\t\t\tnumber: num,\n\t\t\t\t\t\t\t\trepository: ownerAndRepo,\n\t\t\t\t\t\t\t}),\n\n\t\t\t\t\t\t\tdescriptor: {\n\t\t\t\t\t\t\t\tkey: this.remoteKey,\n\t\t\t\t\t\t\t\towner: owner,\n\t\t\t\t\t\t\t\tname: repo,\n\t\t\t\t\t\t\t} satisfies GitLabRepositoryDescriptor,\n\t\t\t\t\t\t});\n\t\t\t\t\t} while (true);\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\t\treturn this._autolinks;\n\t}\n\n\toverride get icon(): string {\n\t\treturn 'gitlab';\n\t}\n\n\tget id(): RemoteProviderId {\n\t\treturn 'gitlab';\n\t}\n\n\tget gkProviderId(): GkProviderId {\n\t\treturn (!equalsIgnoreCase(this.domain, 'gitlab.com')\n\t\t\t? 'gitlabSelfHosted'\n\t\t\t: 'gitlab') satisfies Unbrand<GkProviderId> as Brand<GkProviderId>;\n\t}\n\n\tget name(): string {\n\t\treturn this.formatName('GitLab');\n\t}\n\n\t@memoize()\n\toverride get repoDesc(): GitLabRepositoryDescriptor {\n\t\tconst [owner, repo] = this.splitPath(this.path);\n\t\treturn { key: this.remoteKey, owner: owner, name: repo };\n\t}\n\n\toverride get supportedFeatures(): RemoteProviderSupportedFeatures {\n\t\treturn {\n\t\t\t...super.supportedFeatures,\n\t\t\tcreatePullRequestWithDetails: true,\n\t\t};\n\t}\n\n\tprivate static readonly fileRegex = /^\\/([^/]+)\\/([^/]+?)\\/-\\/blob(.+)$/i;\n\tprivate static readonly rangeRegex = /^L(\\d+)(?:-(\\d+))?$/;\n\n\toverride parseRemoteFileUri(uri: Uri): ParsedRemoteFileUri | undefined {\n\t\tif (uri.authority !== this.domain) return undefined;\n\t\tif (!uri.path.startsWith(`/${this.path}/`)) return undefined;\n\n\t\tlet startLine;\n\t\tlet endLine;\n\t\tif (uri.fragment) {\n\t\t\tconst match = GitLabRemoteProvider.rangeRegex.exec(uri.fragment);\n\t\t\tif (match != null) {\n\t\t\t\tconst [, start, end] = match;\n\t\t\t\tif (start) {\n\t\t\t\t\tstartLine = parseInt(start, 10);\n\t\t\t\t\tif (end) {\n\t\t\t\t\t\tendLine = parseInt(end, 10);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst match = GitLabRemoteProvider.fileRegex.exec(uri.path);\n\t\tif (match == null) return undefined;\n\n\t\tconst [, , , path] = match;\n\n\t\treturn parseRefCandidates(path, startLine, endLine);\n\t}\n\n\tprotected getUrlForBranches(): string {\n\t\treturn this.encodeUrl(`${this.baseUrl}/-/branches`);\n\t}\n\n\tprotected getUrlForBranch(branch: string): string {\n\t\treturn this.encodeUrl(`${this.baseUrl}/-/tree/${branch}`);\n\t}\n\n\tprotected getUrlForCommit(sha: string): string {\n\t\treturn this.encodeUrl(`${this.baseUrl}/-/commit/${sha}`);\n\t}\n\n\tprotected override getUrlForComparison(base: string, head: string, notation: GitRevisionRangeNotation): string {\n\t\treturn this.encodeUrl(`${this.baseUrl}/-/compare/${base}${notation}${head}`);\n\t}\n\n\tprotected override async getUrlForCreatePullRequest(\n\t\tresource: CreatePullRequestRemoteResource,\n\t): Promise<string | undefined> {\n\t\tconst { base, head, details } = resource;\n\n\t\tconst query = new URLSearchParams({\n\t\t\tutf8: '\\u2713',\n\t\t\t'merge_request[source_branch]': head.branch,\n\t\t\t'merge_request[target_branch]': base.branch ?? '',\n\t\t});\n\n\t\tif (base.remote.url !== head.remote.url) {\n\t\t\tconst repoInfo = await this.context?.getRepositoryInfo?.(this.id, {\n\t\t\t\towner: base.remote.path.split('/')[0],\n\t\t\t\tname: base.remote.path.split('/')[1],\n\t\t\t});\n\t\t\tif (!repoInfo) return undefined;\n\n\t\t\tquery.set('merge_request[target_project_id]', repoInfo.id);\n\t\t}\n\n\t\tif (details?.title) {\n\t\t\tquery.set('merge_request[title]', details.title);\n\t\t}\n\t\tif (details?.description) {\n\t\t\tquery.set('merge_request[description]', details.description);\n\t\t}\n\n\t\treturn `${this.encodeUrl(`${this.getRepoBaseUrl(head.remote.path)}/-/merge_requests/new`)}?${query.toString()}`;\n\t}\n\n\tprotected getUrlForFile(fileName: string, branch?: string, sha?: string, range?: LineRange): string {\n\t\tlet line;\n\t\tif (range != null) {\n\t\t\tif (range.startLine === range.endLine) {\n\t\t\t\tline = `#L${range.startLine}`;\n\t\t\t} else {\n\t\t\t\tline = `#L${range.startLine}-${range.endLine}`;\n\t\t\t}\n\t\t} else {\n\t\t\tline = '';\n\t\t}\n\n\t\tif (sha) return `${this.encodeUrl(`${this.baseUrl}/-/blob/${sha}/${fileName}`)}${line}`;\n\t\tif (branch) return `${this.encodeUrl(`${this.baseUrl}/-/blob/${branch}/${fileName}`)}${line}`;\n\t\treturn `${this.encodeUrl(`${this.baseUrl}?path=${fileName}`)}${line}`;\n\t}\n}\n"],"mappings":";;;;;;AAuBA,MAAM,0BAA0B;AAChC,MAAM,iCAAiC;AAEvC,IAAa,uBAAb,MAAa,6BAA6B,eAA2C;CACpF,IAAI,aAAqB;EACxB,OAAO,KAAK,SAAS,GAAG,KAAK,SAAS,KAAK,KAAK,OAAO,QAAQ,WAAW,KAAK,OAAO;CACvF;CAEA,IAAuB,mBAA2B;EACjD,OAAO,GAAG,KAAK,QAAQ;CACxB;CAEA;CACA,IAAa,YAA8D;EAC1E,KAAK,eAAe;GACnB,GAAG,MAAM;GACT;IACC,QAAQ;IACR,KAAK,KAAK;IACV,cAAc;IACd,YAAY;IACZ,OAAO,KAAK,EAAE,sCAAsC;KAAE,QAAQ;KAAS,UAAU,KAAK;IAAK,CAAC;IAE5F,MAAM;IACN,aAAa,KAAK,EAAE,8BAA8B;KAAE,UAAU,KAAK;KAAM,QAAQ;IAAQ,CAAC;GAC3F;GACA;IACC,QAAQ;IACR,KAAK,GAAG,KAAK,QAAQ;IACrB,cAAc;IACd,YAAY;IACZ,OAAO,KAAK,EAAE,8CAA8C;KAC3D,QAAQ;KACR,UAAU,KAAK;IAChB,CAAC;IAED,MAAM;IACN,aAAa,KAAK,EAAE,sCAAsC;KACzD,UAAU,KAAK;KACf,QAAQ;IACT,CAAC;GACF;GACA;IACC,aAAa,CACZ;KACC,OAAO;KACP,MAAM,MAAM,QAAQ,GAAG,KAAK,SAAS,KAAK,KAAK,OAAO,GAAG,KAAK,YAAY;KAC1E,QAAQ,MAAM,QACb,KAAK,EAAE,wDAAwD;MAC9D,QAAQ;MACR,YAAY;MACZ,UAAU,KAAK;KAChB,CAAC;KACF,QAAQ,MAAM,QACb,KAAK,EAAE,sCA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eAAe,KAAK,OAAO,IAAI,EAAE,sBAAsB,EAAE,GAAG,MAAM,SAAS;CAC7G;CAEA,cAAwB,UAAkB,QAAiB,KAAc,OAA2B;EACnG,IAAI;EACJ,IAAI,SAAS,MAAM;GAClB,IAAI,MAAM,cAAc,MAAM,SAC7B,OAAO,KAAK,MAAM;QAElB,OAAO,KAAK,MAAM,UAAU,GAAG,MAAM;EAEvC,OACC,OAAO;EAGR,IAAI,KAAK,OAAO,GAAG,KAAK,UAAU,GAAG,KAAK,QAAQ,UAAU,IAAI,GAAG,UAAU,IAAI;EACjF,IAAI,QAAQ,OAAO,GAAG,KAAK,UAAU,GAAG,KAAK,QAAQ,UAAU,OAAO,GAAG,UAAU,IAAI;EACvF,OAAO,GAAG,KAAK,UAAU,GAAG,KAAK,QAAQ,QAAQ,UAAU,IAAI;CAChE;AACD;AA1GE,WAAA,CAAA,QAAQ,CAAA,GAAA,qBAAA,WAAA,YAAA,IAAA"}
|
|
1
|
+
{"version":3,"file":"gitlab.js","names":[],"sources":["../../../../git/src/remotes/gitlab.ts"],"sourcesContent":["import * as l10n from '@vscode/l10n';\nimport type { Brand, Unbrand } from '@gitlens/utils/brand.js';\nimport { memoize } from '@gitlens/utils/decorators/memoize.js';\nimport { equalsIgnoreCase } from '@gitlens/utils/string.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\nimport type { Autolink, AutolinkReference, DynamicAutolinkReference } from '../models/autolink.js';\nimport type { LineRange } from '../models/lineRange.js';\nimport type {\n\tParsedRemoteFileUri,\n\tRemoteProviderId,\n\tRemoteProviderSupportedFeatures,\n} from '../models/remoteProvider.js';\nimport { parseRefCandidates, RemoteProvider } from '../models/remoteProvider.js';\nimport type { CreatePullRequestRemoteResource } from '../models/remoteResource.js';\nimport type { GkProviderId } from '../models/repositoryIdentities.js';\nimport type { ResourceDescriptor } from '../models/resourceDescriptor.js';\nimport type { GitRevisionRangeNotation } from '../models/revision.js';\n\nexport interface GitLabRepositoryDescriptor extends ResourceDescriptor {\n\towner: string;\n\tname: string;\n}\n\nconst autolinkFullIssuesRegex = /\\b((?:[^/\\s]+\\/)+[^/\\s]+?)(?:\\\\)?#([0-9]+)\\b(?!]\\()/g;\nconst autolinkFullMergeRequestsRegex = /\\b((?:[^/\\s]+\\/)+[^/\\s]+?)(?:\\\\)?!([0-9]+)\\b(?!]\\()/g;\n\n/** Splits at the last slash: the owner is the whole namespace (`group/subgroup`) and the name is the project */\nfunction splitNamespaceAndName(path: string): [owner: string, name: string] {\n\tconst index = path.lastIndexOf('/');\n\treturn [path.substring(0, index), path.substring(index + 1)];\n}\n\nexport class GitLabRemoteProvider extends RemoteProvider<GitLabRepositoryDescriptor> {\n\tget apiBaseUrl(): string {\n\t\treturn this.custom ? `${this.protocol}://${this.domain}/api` : `https://${this.domain}/api`;\n\t}\n\n\tprotected override get issueLinkPattern(): string {\n\t\treturn `${this.baseUrl}/-/issues/<num>`;\n\t}\n\n\tprivate _autolinks: (AutolinkReference | DynamicAutolinkReference)[] | undefined;\n\toverride get autolinks(): (AutolinkReference | DynamicAutolinkReference)[] {\n\t\tthis._autolinks ??= [\n\t\t\t...super.autolinks,\n\t\t\t{\n\t\t\t\tprefix: '#',\n\t\t\t\turl: this.issueLinkPattern,\n\t\t\t\talphanumeric: false,\n\t\t\t\tignoreCase: false,\n\t\t\t\ttitle: l10n.t('Open Issue #{number} on {provider}', { number: '<num>', provider: this.name }),\n\n\t\t\t\ttype: 'issue',\n\t\t\t\tdescription: l10n.t('{provider} Issue #{number}', { provider: this.name, number: '<num>' }),\n\t\t\t},\n\t\t\t{\n\t\t\t\tprefix: '!',\n\t\t\t\turl: `${this.baseUrl}/-/merge_requests/<num>`,\n\t\t\t\talphanumeric: false,\n\t\t\t\tignoreCase: false,\n\t\t\t\ttitle: l10n.t('Open Merge Request !{number} on {provider}', {\n\t\t\t\t\tnumber: '<num>',\n\t\t\t\t\tprovider: this.name,\n\t\t\t\t}),\n\n\t\t\t\ttype: 'pullrequest',\n\t\t\t\tdescription: l10n.t('{provider} Merge Request !{number}', {\n\t\t\t\t\tprovider: this.name,\n\t\t\t\t\tnumber: '<num>',\n\t\t\t\t}),\n\t\t\t},\n\t\t\t{\n\t\t\t\tdescriptors: [\n\t\t\t\t\t{\n\t\t\t\t\t\tregex: autolinkFullIssuesRegex,\n\t\t\t\t\t\turl: (repo, num) => `${this.protocol}://${this.domain}/${repo}/-/issues/${num}`,\n\t\t\t\t\t\ttitle: (repo, num) =>\n\t\t\t\t\t\t\tl10n.t('Open Issue #{number} from {repository} on {provider}', {\n\t\t\t\t\t\t\t\tnumber: num,\n\t\t\t\t\t\t\t\trepository: repo,\n\t\t\t\t\t\t\t\tprovider: this.name,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\tlabel: (repo, num) =>\n\t\t\t\t\t\t\tl10n.t('GitLab Issue {repository}#{number}', { repository: repo, number: num }),\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tparse: (text: string, autolinks: Map<string, Autolink>) => {\n\t\t\t\t\tlet ownerAndRepo: string;\n\t\t\t\t\tlet num: string;\n\n\t\t\t\t\tlet match;\n\t\t\t\t\tdo {\n\t\t\t\t\t\tmatch = autolinkFullIssuesRegex.exec(text);\n\t\t\t\t\t\tif (match == null) break;\n\n\t\t\t\t\t\t[, ownerAndRepo, num] = match;\n\n\t\t\t\t\t\tconst [owner, repo] = splitNamespaceAndName(ownerAndRepo);\n\t\t\t\t\t\tautolinks.set(num, {\n\t\t\t\t\t\t\tprovider: this,\n\t\t\t\t\t\t\tid: num,\n\t\t\t\t\t\t\tprefix: `${ownerAndRepo}#`,\n\t\t\t\t\t\t\turl: `${this.protocol}://${this.domain}/${ownerAndRepo}/-/issues/${num}`,\n\t\t\t\t\t\t\talphanumeric: false,\n\t\t\t\t\t\t\tignoreCase: true,\n\t\t\t\t\t\t\ttitle: l10n.t('Open Issue #{number} from {repository} on {provider}', {\n\t\t\t\t\t\t\t\tnumber: '<num>',\n\t\t\t\t\t\t\t\trepository: ownerAndRepo,\n\t\t\t\t\t\t\t\tprovider: this.name,\n\t\t\t\t\t\t\t}),\n\n\t\t\t\t\t\t\ttype: 'issue',\n\t\t\t\t\t\t\tdescription: l10n.t('{provider} Issue {repository}#{number}', {\n\t\t\t\t\t\t\t\tprovider: this.name,\n\t\t\t\t\t\t\t\trepository: ownerAndRepo,\n\t\t\t\t\t\t\t\tnumber: num,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tdescriptor: {\n\t\t\t\t\t\t\t\tkey: this.remoteKey,\n\t\t\t\t\t\t\t\towner: owner,\n\t\t\t\t\t\t\t\tname: repo,\n\t\t\t\t\t\t\t} satisfies GitLabRepositoryDescriptor,\n\t\t\t\t\t\t});\n\t\t\t\t\t} while (true);\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdescriptors: [\n\t\t\t\t\t{\n\t\t\t\t\t\tregex: autolinkFullMergeRequestsRegex,\n\t\t\t\t\t\turl: (repo, num) => `${this.protocol}://${this.domain}/${repo}/-/merge_requests/${num}`,\n\t\t\t\t\t\ttitle: (repo, num) =>\n\t\t\t\t\t\t\tl10n.t('Open Merge Request !{number} from {repository} on {provider}', {\n\t\t\t\t\t\t\t\tnumber: num,\n\t\t\t\t\t\t\t\trepository: repo,\n\t\t\t\t\t\t\t\tprovider: this.name,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\tlabel: (repo, num) =>\n\t\t\t\t\t\t\tl10n.t('{provider} Merge Request {repository}!{number}', {\n\t\t\t\t\t\t\t\tprovider: this.name,\n\t\t\t\t\t\t\t\trepository: repo,\n\t\t\t\t\t\t\t\tnumber: num,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tparse: (text: string, autolinks: Map<string, Autolink>) => {\n\t\t\t\t\tlet ownerAndRepo: string;\n\t\t\t\t\tlet num: string;\n\n\t\t\t\t\tlet match;\n\t\t\t\t\tdo {\n\t\t\t\t\t\tmatch = autolinkFullMergeRequestsRegex.exec(text);\n\t\t\t\t\t\tif (match == null) break;\n\n\t\t\t\t\t\t[, ownerAndRepo, num] = match;\n\n\t\t\t\t\t\tconst [owner, repo] = splitNamespaceAndName(ownerAndRepo);\n\t\t\t\t\t\tautolinks.set(num, {\n\t\t\t\t\t\t\tprovider: this,\n\t\t\t\t\t\t\tid: num,\n\t\t\t\t\t\t\tprefix: `${ownerAndRepo}!`,\n\t\t\t\t\t\t\turl: `${this.protocol}://${this.domain}/${ownerAndRepo}/-/merge_requests/${num}`,\n\t\t\t\t\t\t\talphanumeric: false,\n\t\t\t\t\t\t\tignoreCase: true,\n\t\t\t\t\t\t\ttitle: l10n.t('Open Merge Request !{number} from {repository} on {provider}', {\n\t\t\t\t\t\t\t\tnumber: '<num>',\n\t\t\t\t\t\t\t\trepository: ownerAndRepo,\n\t\t\t\t\t\t\t\tprovider: this.name,\n\t\t\t\t\t\t\t}),\n\n\t\t\t\t\t\t\ttype: 'pullrequest',\n\t\t\t\t\t\t\tdescription: l10n.t('{provider} Merge Request !{number} from {repository}', {\n\t\t\t\t\t\t\t\tprovider: this.name,\n\t\t\t\t\t\t\t\tnumber: num,\n\t\t\t\t\t\t\t\trepository: ownerAndRepo,\n\t\t\t\t\t\t\t}),\n\n\t\t\t\t\t\t\tdescriptor: {\n\t\t\t\t\t\t\t\tkey: this.remoteKey,\n\t\t\t\t\t\t\t\towner: owner,\n\t\t\t\t\t\t\t\tname: repo,\n\t\t\t\t\t\t\t} satisfies GitLabRepositoryDescriptor,\n\t\t\t\t\t\t});\n\t\t\t\t\t} while (true);\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\t\treturn this._autolinks;\n\t}\n\n\toverride get icon(): string {\n\t\treturn 'gitlab';\n\t}\n\n\tget id(): RemoteProviderId {\n\t\treturn 'gitlab';\n\t}\n\n\tget gkProviderId(): GkProviderId {\n\t\treturn (!equalsIgnoreCase(this.domain, 'gitlab.com')\n\t\t\t? 'gitlabSelfHosted'\n\t\t\t: 'gitlab') satisfies Unbrand<GkProviderId> as Brand<GkProviderId>;\n\t}\n\n\tget name(): string {\n\t\treturn this.formatName('GitLab');\n\t}\n\n\t@memoize()\n\toverride get repoDesc(): GitLabRepositoryDescriptor {\n\t\tconst [owner, repo] = this.splitPath(this.path);\n\t\treturn { key: this.remoteKey, owner: owner, name: repo };\n\t}\n\n\toverride get supportedFeatures(): RemoteProviderSupportedFeatures {\n\t\treturn {\n\t\t\t...super.supportedFeatures,\n\t\t\tcreatePullRequestWithDetails: true,\n\t\t};\n\t}\n\n\tprivate static readonly fileRegex = /^\\/-\\/blob(.+)$/i;\n\tprivate static readonly rangeRegex = /^L(\\d+)(?:-(\\d+))?$/;\n\n\toverride parseRemoteFileUri(uri: Uri): ParsedRemoteFileUri | undefined {\n\t\tif (uri.authority !== this.domain) return undefined;\n\t\tif (!uri.path.startsWith(`/${this.path}/`)) return undefined;\n\n\t\tlet startLine;\n\t\tlet endLine;\n\t\tif (uri.fragment) {\n\t\t\tconst match = GitLabRemoteProvider.rangeRegex.exec(uri.fragment);\n\t\t\tif (match != null) {\n\t\t\t\tconst [, start, end] = match;\n\t\t\t\tif (start) {\n\t\t\t\t\tstartLine = parseInt(start, 10);\n\t\t\t\t\tif (end) {\n\t\t\t\t\t\tendLine = parseInt(end, 10);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst match = GitLabRemoteProvider.fileRegex.exec(uri.path.substring(this.path.length + 1));\n\t\tif (match == null) return undefined;\n\n\t\tconst [, path] = match;\n\n\t\treturn parseRefCandidates(path, startLine, endLine);\n\t}\n\n\tprotected getUrlForBranches(): string {\n\t\treturn this.encodeUrl(`${this.baseUrl}/-/branches`);\n\t}\n\n\tprotected getUrlForBranch(branch: string): string {\n\t\treturn this.encodeUrl(`${this.baseUrl}/-/tree/${branch}`);\n\t}\n\n\tprotected getUrlForCommit(sha: string): string {\n\t\treturn this.encodeUrl(`${this.baseUrl}/-/commit/${sha}`);\n\t}\n\n\tprotected override getUrlForComparison(base: string, head: string, notation: GitRevisionRangeNotation): string {\n\t\treturn this.encodeUrl(`${this.baseUrl}/-/compare/${base}${notation}${head}`);\n\t}\n\n\tprotected override async getUrlForCreatePullRequest(\n\t\tresource: CreatePullRequestRemoteResource,\n\t): Promise<string | undefined> {\n\t\tconst { base, head, details } = resource;\n\n\t\tconst query = new URLSearchParams({\n\t\t\tutf8: '\\u2713',\n\t\t\t'merge_request[source_branch]': head.branch,\n\t\t\t'merge_request[target_branch]': base.branch ?? '',\n\t\t});\n\n\t\tif (base.remote.url !== head.remote.url) {\n\t\t\tconst [owner, name] = splitNamespaceAndName(base.remote.path);\n\t\t\tconst repoInfo = await this.context?.getRepositoryInfo?.(this.id, { owner: owner, name: name });\n\t\t\tif (!repoInfo) return undefined;\n\n\t\t\tquery.set('merge_request[target_project_id]', repoInfo.id);\n\t\t}\n\n\t\tif (details?.title) {\n\t\t\tquery.set('merge_request[title]', details.title);\n\t\t}\n\t\tif (details?.description) {\n\t\t\tquery.set('merge_request[description]', details.description);\n\t\t}\n\n\t\treturn `${this.encodeUrl(`${this.getRepoBaseUrl(head.remote.path)}/-/merge_requests/new`)}?${query.toString()}`;\n\t}\n\n\tprotected getUrlForFile(fileName: string, branch?: string, sha?: string, range?: LineRange): string {\n\t\tlet line;\n\t\tif (range != null) {\n\t\t\tif (range.startLine === range.endLine) {\n\t\t\t\tline = `#L${range.startLine}`;\n\t\t\t} else {\n\t\t\t\tline = `#L${range.startLine}-${range.endLine}`;\n\t\t\t}\n\t\t} else {\n\t\t\tline = '';\n\t\t}\n\n\t\tif (sha) return `${this.encodeUrl(`${this.baseUrl}/-/blob/${sha}/${fileName}`)}${line}`;\n\t\tif (branch) return `${this.encodeUrl(`${this.baseUrl}/-/blob/${branch}/${fileName}`)}${line}`;\n\t\treturn `${this.encodeUrl(`${this.baseUrl}?path=${fileName}`)}${line}`;\n\t}\n}\n"],"mappings":";;;;;;AAuBA,MAAM,0BAA0B;AAChC,MAAM,iCAAiC;;AAGvC,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;EACJ,IAAI,SAAS,MAAM;GAClB,IAAI,MAAM,cAAc,MAAM,SAC7B,OAAO,KAAK,MAAM;QAElB,OAAO,KAAK,MAAM,UAAU,GAAG,MAAM;EAEvC,OACC,OAAO;EAGR,IAAI,KAAK,OAAO,GAAG,KAAK,UAAU,GAAG,KAAK,QAAQ,UAAU,IAAI,GAAG,UAAU,IAAI;EACjF,IAAI,QAAQ,OAAO,GAAG,KAAK,UAAU,GAAG,KAAK,QAAQ,UAAU,OAAO,GAAG,UAAU,IAAI;EACvF,OAAO,GAAG,KAAK,UAAU,GAAG,KAAK,QAAQ,QAAQ,UAAU,IAAI;CAChE;AACD;AAxGE,WAAA,CAAA,QAAQ,CAAA,GAAA,qBAAA,WAAA,YAAA,IAAA"}
|
package/dist/git/service.js
CHANGED
|
@@ -132,7 +132,10 @@ var GitService = class GitService {
|
|
|
132
132
|
const entry = {
|
|
133
133
|
provider,
|
|
134
134
|
canHandle,
|
|
135
|
-
announcements: watchService != null ? provider.onDidAnnounceChanges?.((e) => watchService.noteSelfWrite(e.repoPath, e.changes, e.refs, {
|
|
135
|
+
announcements: watchService != null ? provider.onDidAnnounceChanges?.((e) => watchService.noteSelfWrite(e.repoPath, e.changes, e.refs, {
|
|
136
|
+
configConfinedToRefs: e.configConfinedToRefs,
|
|
137
|
+
movedWorktrees: e.movedWorktrees
|
|
138
|
+
})) : void 0
|
|
136
139
|
};
|
|
137
140
|
this._providers.push(entry);
|
|
138
141
|
this._etag++;
|
package/dist/git/service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","names":[],"sources":["../../../git/src/service.ts"],"sourcesContent":["import type { UnifiedDisposable } from '@gitlens/utils/disposable.js';\nimport { createDisposable } from '@gitlens/utils/disposable.js';\nimport type { Event } from '@gitlens/utils/event.js';\nimport { Emitter } from '@gitlens/utils/event.js';\nimport { normalizePath } from '@gitlens/utils/path.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\nimport { getRepositoryKey } from '@gitlens/utils/uri.js';\nimport type { MergeTargetsChangeEvent } from './cache.js';\nimport type { GitProvider } from './providers/provider.js';\nimport type { RepositoryService, SubProviderForRepo } from './repositoryService.js';\nimport {\n\tclearGlobalRepositoryServiceResolver,\n\tcreateSubProviderProxyForRepo,\n\tsetGlobalRepositoryServiceResolver,\n} from './repositoryService.js';\nimport type { FileWatchingProvider } from './watching/provider.js';\nimport type { WatchPollingOptions } from './watching/watchService.js';\nimport { RepositoryWatchService } from './watching/watchService.js';\nimport type { WorktreeSummaryServiceOptions } from './watching/worktreeSummary.js';\nimport { WorktreeSummaryService } from './watching/worktreeSummary.js';\n\nexport interface ProvidersChangeEvent {\n\treadonly added: readonly GitProvider[];\n\treadonly removed: readonly GitProvider[];\n\treadonly etag: number;\n}\n\n/**\n * Result of {@link GitService.validateRepo}.\n *\n * - `valid: true, safe: true` — a usable git repository at `repoPath`; `gitDir` / `commonGitDir` / `superprojectPath` are populated when available\n * - `valid: true, safe: false` — git detected unsafe (dubious) ownership at the given path; no `repoPath` is surfaced (the raw call doesn't carry one back)\n * - `valid: false` — not a git repository, no registered provider can handle the path, or the routed provider doesn't implement `getRepositoryInfo`\n */\nexport type ValidateRepoResult =\n\t| {\n\t\t\tvalid: true;\n\t\t\tsafe: true;\n\t\t\trepoPath: string;\n\t\t\tgitDir?: string;\n\t\t\tcommonGitDir?: string;\n\t\t\tsuperprojectPath?: string;\n\t }\n\t| { valid: true; safe: false }\n\t| { valid: false };\n\ninterface RegisteredProvider {\n\tprovider: GitProvider;\n\tcanHandle: (repoPath: string) => boolean;\n\t/** Forwards the provider's write announcements to {@link GitService.watchService}, when there is one */\n\tannouncements?: UnifiedDisposable;\n}\n\ninterface MergeTargetsSource {\n\treadonly subscription: UnifiedDisposable;\n\trefCount: number;\n}\n\n/**\n * Entry point — provider router, repo-scoped proxy cache, and global configuration.\n *\n * Creating an instance wires up the module-level repository\n * resolver. Calling {@link dispose} tears it down.\n *\n * Consumers register providers with routing predicates, then call\n * {@link forRepo} to get a {@link RepositoryService} with sub-provider\n * proxies that auto-inject the repository path.\n *\n * The service has no discovery or repository tracking state — it trusts\n * the caller to pass valid repository paths. Discovery and lifecycle\n * (open/close, file watching, etc.) are application-level concerns.\n *\n * @example\n * ```typescript\n * const service = GitService.createSingleton();\n * service.register(cliProvider, (path) => true);\n *\n * const repo = service.forRepo('/home/user/repo');\n * const branches = await repo.branches.getBranches();\n *\n * service.dispose(); // cleans up module-level hooks\n * ```\n */\nexport class GitService implements UnifiedDisposable {\n\tprivate static _instance: GitService | undefined;\n\n\t/**\n\t * `options.watchPolling` opts the watch service into polling what `watchingProvider` reports it can't watch,\n\t * `options.readFile` lets it tell what a reported `.git/config` change changed (see `WatchServiceOptions.readFile`),\n\t * and with it `options.readDirectory` lets it drop the reports of ignored worktrees (see\n\t * `WatchServiceOptions.readDirectory`).\n\t * `options.verifyBaseRemeasure` is for tests only (see `WorktreeSummaryServiceOptions.verifyBaseRemeasure`)\n\t */\n\tstatic createSingleton(\n\t\twatchingProvider?: FileWatchingProvider,\n\t\toptions?: {\n\t\t\twatchPolling?: WatchPollingOptions;\n\t\t\treadFile?: (path: string) => Promise<Uint8Array>;\n\t\t\treadDirectory?: (path: string) => Promise<readonly (readonly [string, number])[]>;\n\t\t\tverifyBaseRemeasure?: WorktreeSummaryServiceOptions['verifyBaseRemeasure'];\n\t\t},\n\t): GitService {\n\t\tif (GitService._instance != null) {\n\t\t\tthrow new Error('GitService already exists — only one instance is allowed');\n\t\t}\n\n\t\tconst instance = new GitService(\n\t\t\twatchingProvider,\n\t\t\toptions?.watchPolling,\n\t\t\toptions?.readFile,\n\t\t\toptions?.readDirectory,\n\t\t\toptions?.verifyBaseRemeasure,\n\t\t);\n\t\tGitService._instance = instance;\n\t\treturn instance;\n\t}\n\n\tprivate readonly _onDidChangeProviders = new Emitter<ProvidersChangeEvent>();\n\tget onDidChangeProviders(): Event<ProvidersChangeEvent> {\n\t\treturn this._onDidChangeProviders.event;\n\t}\n\n\tprivate readonly _onDidChangeMergeTargets = new Emitter<MergeTargetsChangeEvent>();\n\t/**\n\t * Fires when a write changed a branch's merge-relevant `.git/gk/config` keys, for any registered provider that\n\t * reports it — never for activity timestamps. Core's own key write fires it once, as the write completes, naming\n\t * the branch. Once per change per repository (`repoPath` is its common path); see {@link MergeTargetsChangeEvent}.\n\t */\n\tget onDidChangeMergeTargets(): Event<MergeTargetsChangeEvent> {\n\t\treturn this._onDidChangeMergeTargets.event;\n\t}\n\n\t/** Keyed by the provider's event, so providers sharing one cache are forwarded once */\n\tprivate readonly _mergeTargetsSources = new Map<Event<MergeTargetsChangeEvent>, MergeTargetsSource>();\n\n\tprivate _etag = 0;\n\tprivate readonly _providers: RegisteredProvider[] = [];\n\tprivate readonly _serviceCache = new Map<string, RepositoryService>();\n\tprivate readonly _watchService: RepositoryWatchService | undefined;\n\tprivate readonly _summaries: WorktreeSummaryService | undefined;\n\n\tprivate constructor(\n\t\twatchingProvider?: FileWatchingProvider,\n\t\twatchPolling?: WatchPollingOptions,\n\t\treadFile?: (path: string) => Promise<Uint8Array>,\n\t\treadDirectory?: (path: string) => Promise<readonly (readonly [string, number])[]>,\n\t\tverifyBaseRemeasure?: WorktreeSummaryServiceOptions['verifyBaseRemeasure'],\n\t) {\n\t\tif (watchingProvider != null) {\n\t\t\tthis._watchService = new RepositoryWatchService({\n\t\t\t\twatchingProvider: watchingProvider,\n\t\t\t\tpolling: watchPolling,\n\t\t\t\treadFile: readFile,\n\t\t\t\treadDirectory: readDirectory,\n\t\t\t\tgetIgnoreFilter: (repoPath, gitDirPath) => {\n\t\t\t\t\treturn this.getProvider(repoPath)?.provider.getIgnoreFilter?.(repoPath, gitDirPath);\n\t\t\t\t},\n\t\t\t\tgetIgnoredDirectories: repoPath =>\n\t\t\t\t\tthis.getProvider(repoPath)?.provider.getIgnoredDirectories?.(repoPath) ?? Promise.resolve([]),\n\t\t\t\tgetIgnoredWorktreeRoots: repoPath =>\n\t\t\t\t\tthis.getProvider(repoPath)?.provider.getIgnoredWorktreeRoots?.(repoPath) ?? Promise.resolve([]),\n\t\t\t\tgetIgnoredWorktreeFolders: repoPath =>\n\t\t\t\t\tthis.getProvider(repoPath)?.provider.getIgnoredWorktreeFolders?.(repoPath) ?? [],\n\t\t\t});\n\t\t\tthis._summaries = new WorktreeSummaryService({\n\t\t\t\twatchService: this._watchService,\n\t\t\t\tgetRepository: repoPath => this.forRepo(repoPath),\n\t\t\t\tonDidChangeMergeTargets: this.onDidChangeMergeTargets,\n\t\t\t\tgetCommonPath: repoPath => this.getProvider(repoPath)?.provider.getCommonPath?.(repoPath),\n\t\t\t\t// The host's polling stat, when it configured polling, answers whether an unwatched index file moved\n\t\t\t\tstat: watchPolling?.stat,\n\t\t\t\tverifyBaseRemeasure: verifyBaseRemeasure,\n\t\t\t});\n\t\t}\n\n\t\tsetGlobalRepositoryServiceResolver(repoPath => this.forRepo(repoPath));\n\t}\n\n\t[Symbol.dispose](): void {\n\t\tthis.dispose();\n\t}\n\n\tdispose(): void {\n\t\tclearGlobalRepositoryServiceResolver();\n\t\tGitService._instance = undefined;\n\t\tthis._serviceCache.clear();\n\t\tthis._summaries?.dispose();\n\t\tthis._watchService?.dispose();\n\n\t\t// Don't dispose providers since they're owned by the caller, but do clear the array to release references\n\t\tfor (const entry of this._providers) {\n\t\t\tentry.announcements?.dispose();\n\t\t}\n\t\tthis._providers.length = 0;\n\n\t\tfor (const source of this._mergeTargetsSources.values()) {\n\t\t\tsource.subscription.dispose();\n\t\t}\n\t\tthis._mergeTargetsSources.clear();\n\n\t\tthis._onDidChangeProviders.dispose();\n\t\tthis._onDidChangeMergeTargets.dispose();\n\t}\n\n\t/** Monotonically increasing counter incremented on structural changes. */\n\tget etag(): number {\n\t\treturn this._etag;\n\t}\n\n\t/** Whether any providers are registered. */\n\tget hasProviders(): boolean {\n\t\treturn this._providers.length > 0;\n\t}\n\n\tget watchService(): RepositoryWatchService | undefined {\n\t\treturn this._watchService;\n\t}\n\n\t/** Cached, change-notifying per-worktree summaries, kept current by {@link watchService}; present when it is */\n\tget summaries(): WorktreeSummaryService | undefined {\n\t\treturn this._summaries;\n\t}\n\n\t/**\n\t * Registers a provider with a routing predicate.\n\t *\n\t * @returns A disposable that unregisters the provider.\n\t */\n\tregister(provider: GitProvider, canHandle: (repoPath: string) => boolean): UnifiedDisposable {\n\t\tconst watchService = this._watchService;\n\t\tconst entry: RegisteredProvider = {\n\t\t\tprovider: provider,\n\t\t\tcanHandle: canHandle,\n\t\t\tannouncements:\n\t\t\t\twatchService != null\n\t\t\t\t\t? provider.onDidAnnounceChanges?.(e =>\n\t\t\t\t\t\t\twatchService.noteSelfWrite(e.repoPath, e.changes, e.refs, {\n\t\t\t\t\t\t\t\tconfigConfinedToRefs: e.configConfinedToRefs,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t)\n\t\t\t\t\t: undefined,\n\t\t};\n\t\tthis._providers.push(entry);\n\t\tthis._etag++;\n\t\tthis.addMergeTargetsSource(provider);\n\n\t\tthis._onDidChangeProviders.fire({\n\t\t\tadded: [provider],\n\t\t\tremoved: [],\n\t\t\tetag: this._etag,\n\t\t});\n\n\t\t// Invalidate cached proxies since provider routing may have changed\n\t\tthis._serviceCache.clear();\n\n\t\treturn createDisposable(() => {\n\t\t\tconst idx = this._providers.indexOf(entry);\n\t\t\tif (idx !== -1) {\n\t\t\t\tthis._providers.splice(idx, 1);\n\t\t\t\tentry.announcements?.dispose();\n\t\t\t\tthis._etag++;\n\t\t\t\tthis.removeMergeTargetsSource(provider);\n\t\t\t\tthis._serviceCache.clear();\n\n\t\t\t\tthis._onDidChangeProviders.fire({\n\t\t\t\t\tadded: [],\n\t\t\t\t\tremoved: [provider],\n\t\t\t\t\tetag: this._etag,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate addMergeTargetsSource(provider: GitProvider): void {\n\t\tconst event = provider.onDidChangeMergeTargets;\n\t\tif (event == null) return;\n\n\t\tconst source = this._mergeTargetsSources.get(event);\n\t\tif (source != null) {\n\t\t\tsource.refCount++;\n\t\t\treturn;\n\t\t}\n\n\t\tthis._mergeTargetsSources.set(event, {\n\t\t\tsubscription: event(e => this._onDidChangeMergeTargets.fire(e)),\n\t\t\trefCount: 1,\n\t\t});\n\t}\n\n\tprivate removeMergeTargetsSource(provider: GitProvider): void {\n\t\tconst event = provider.onDidChangeMergeTargets;\n\t\tif (event == null) return;\n\n\t\tconst source = this._mergeTargetsSources.get(event);\n\t\tif (source == null || --source.refCount > 0) return;\n\n\t\tsource.subscription.dispose();\n\t\tthis._mergeTargetsSources.delete(event);\n\t}\n\n\t/** Returns the provider that can handle the given path, or undefined if none matches. */\n\tgetProvider(repoPath: string): { provider: GitProvider; path: string } | undefined {\n\t\trepoPath = normalizePath(repoPath);\n\t\tfor (const entry of this._providers) {\n\t\t\tif (entry.canHandle(repoPath)) {\n\t\t\t\treturn { provider: entry.provider, path: repoPath };\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/** Returns all registered providers. */\n\t*getProviders(): Iterable<GitProvider> {\n\t\tfor (const entry of this._providers) {\n\t\t\tyield entry.provider;\n\t\t}\n\t}\n\n\t/**\n\t * Routes a repo URI/path to a provider and returns a cached\n\t * {@link RepositoryService} with repo-scoped sub-provider proxies.\n\t * Returns undefined if no provider can handle the path.\n\t */\n\tforRepo(repoUri: Uri | string): RepositoryService | undefined {\n\t\tconst repoPath = getRepositoryKey(repoUri);\n\n\t\tlet repo = this._serviceCache.get(repoPath);\n\t\tif (repo != null) return repo;\n\n\t\tconst result = this.getProvider(repoPath);\n\t\tif (result == null) return undefined;\n\n\t\trepo = createRepositoryService(result.provider, repoPath, this._watchService);\n\t\tthis._serviceCache.set(repoPath, repo);\n\t\treturn repo;\n\t}\n\n\t/**\n\t * Evicts the cached {@link RepositoryService} for a closed or removed repository.\n\t * No-op if the path isn't cached.\n\t */\n\tcloseRepo(repoUri: Uri | string): void {\n\t\tconst repoPath = getRepositoryKey(repoUri);\n\t\tthis._serviceCache.delete(repoPath);\n\t}\n\n\t/**\n\t * Validates whether `pathOrUri` points to (or resides inside) a git repository,\n\t * and returns information about it when it does.\n\t *\n\t * Routes the path to a registered provider and delegates to its config sub-provider's\n\t * `getRepositoryInfo` implementation, then normalizes the raw result into a clean\n\t * discriminated union. For a simple yes/no check, use `(await validateRepo(path)).valid`.\n\t *\n\t * Returns `{ valid: false }` if no provider can handle the path or if the routed\n\t * provider does not implement `getRepositoryInfo`. Rejects when git gives no answer\n\t * (it ran past its time limit, was killed or couldn't start), which says nothing about the path.\n\t */\n\tasync validateRepo(pathOrUri: Uri | string): Promise<ValidateRepoResult> {\n\t\tconst key = getRepositoryKey(pathOrUri);\n\t\tconst routed = this.getProvider(key);\n\t\tif (routed == null) return { valid: false };\n\n\t\tconst info = await routed.provider.config.getRepositoryInfo?.(routed.path);\n\t\tif (info == null) return { valid: false };\n\n\t\tif (Array.isArray(info)) {\n\t\t\tif (info.length === 0) return { valid: false };\n\t\t\tif (info[0] === false) return { valid: true, safe: false };\n\t\t\treturn { valid: true, safe: true, repoPath: info[1] };\n\t\t}\n\n\t\treturn {\n\t\t\tvalid: true,\n\t\t\tsafe: true,\n\t\t\trepoPath: info.repoPath,\n\t\t\tgitDir: info.gitDir,\n\t\t\tcommonGitDir: info.commonGitDir,\n\t\t\tsuperprojectPath: info.superprojectPath,\n\t\t};\n\t}\n}\n\nfunction createRepositoryService(\n\tprovider: GitProvider,\n\trepoPath: string,\n\twatchService?: RepositoryWatchService,\n): RepositoryService {\n\tconst proxies = new Map<string, SubProviderForRepo<unknown>>();\n\n\tfunction getProxy<T extends object>(prop: string, subProvider: T | undefined): SubProviderForRepo<T> | undefined {\n\t\tif (subProvider == null) return undefined;\n\n\t\tlet proxy = proxies.get(prop);\n\t\tif (proxy == null) {\n\t\t\tproxy = createSubProviderProxyForRepo(subProvider, repoPath);\n\t\t\tproxies.set(prop, proxy);\n\t\t}\n\t\treturn proxy as SubProviderForRepo<T>;\n\t}\n\n\treturn {\n\t\tpath: repoPath,\n\t\tprovider: provider.descriptor,\n\n\t\tget etagWorkingTree(): number | undefined {\n\t\t\treturn watchService?.getSession(repoPath)?.etagWorkingTree;\n\t\t},\n\n\t\tgetAbsoluteUri: (relativePath: string): Uri => {\n\t\t\treturn provider.getAbsoluteUri(relativePath, repoPath);\n\t\t},\n\n\t\t// Required sub-providers\n\t\tget branches() {\n\t\t\tconst proxy = getProxy('branches', provider.branches);\n\t\t\tif (proxy == null) throw new Error('GitService: branches sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget commits() {\n\t\t\tconst proxy = getProxy('commits', provider.commits);\n\t\t\tif (proxy == null) throw new Error('GitService: commits sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget config() {\n\t\t\tconst proxy = getProxy('config', provider.config);\n\t\t\tif (proxy == null) throw new Error('GitService: config sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget contributors() {\n\t\t\tconst proxy = getProxy('contributors', provider.contributors);\n\t\t\tif (proxy == null) throw new Error('GitService: contributors sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget diff() {\n\t\t\tconst proxy = getProxy('diff', provider.diff);\n\t\t\tif (proxy == null) throw new Error('GitService: diff sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget graph() {\n\t\t\tconst proxy = getProxy('graph', provider.graph);\n\t\t\tif (proxy == null) throw new Error('GitService: graph sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget refs() {\n\t\t\tconst proxy = getProxy('refs', provider.refs);\n\t\t\tif (proxy == null) throw new Error('GitService: refs sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget remotes() {\n\t\t\tconst proxy = getProxy('remotes', provider.remotes);\n\t\t\tif (proxy == null) throw new Error('GitService: remotes sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget revision() {\n\t\t\tconst proxy = getProxy('revision', provider.revision);\n\t\t\tif (proxy == null) throw new Error('GitService: revision sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget status() {\n\t\t\tconst proxy = getProxy('status', provider.status);\n\t\t\tif (proxy == null) throw new Error('GitService: status sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget tags() {\n\t\t\tconst proxy = getProxy('tags', provider.tags);\n\t\t\tif (proxy == null) throw new Error('GitService: tags sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\n\t\t// Optional sub-providers\n\t\tget blame() {\n\t\t\treturn getProxy('blame', provider.blame);\n\t\t},\n\t\tget maintenance() {\n\t\t\treturn getProxy('maintenance', provider.maintenance);\n\t\t},\n\t\tget ops() {\n\t\t\treturn getProxy('ops', provider.ops);\n\t\t},\n\t\tget patch() {\n\t\t\treturn getProxy('patch', provider.patch);\n\t\t},\n\t\tget pausedOps() {\n\t\t\treturn getProxy('pausedOps', provider.pausedOps);\n\t\t},\n\t\tget staging() {\n\t\t\treturn getProxy('staging', provider.staging);\n\t\t},\n\t\tget stash() {\n\t\t\treturn getProxy('stash', provider.stash);\n\t\t},\n\t\tget worktrees() {\n\t\t\treturn getProxy('worktrees', provider.worktrees);\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFA,IAAa,aAAb,MAAa,WAAwC;CACpD,OAAe;;;;;;;;CASf,OAAO,gBACN,kBACA,SAMa;EACb,IAAI,WAAW,aAAa,MAC3B,MAAM,IAAI,MAAM,0DAA0D;EAG3E,MAAM,WAAW,IAAI,WACpB,kBACA,SAAS,cACT,SAAS,UACT,SAAS,eACT,SAAS,mBACV;EACA,WAAW,YAAY;EACvB,OAAO;CACR;CAEA,wBAAyC,IAAI,QAA8B;CAC3E,IAAI,uBAAoD;EACvD,OAAO,KAAK,sBAAsB;CACnC;CAEA,2BAA4C,IAAI,QAAiC;;;;;;CAMjF,IAAI,0BAA0D;EAC7D,OAAO,K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;GACX,OAAO,SAAS,SAAS,SAAS,KAAK;EACxC;EACA,IAAI,YAAY;GACf,OAAO,SAAS,aAAa,SAAS,SAAS;EAChD;EACA,IAAI,UAAU;GACb,OAAO,SAAS,WAAW,SAAS,OAAO;EAC5C;EACA,IAAI,QAAQ;GACX,OAAO,SAAS,SAAS,SAAS,KAAK;EACxC;EACA,IAAI,YAAY;GACf,OAAO,SAAS,aAAa,SAAS,SAAS;EAChD;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"service.js","names":[],"sources":["../../../git/src/service.ts"],"sourcesContent":["import type { UnifiedDisposable } from '@gitlens/utils/disposable.js';\nimport { createDisposable } from '@gitlens/utils/disposable.js';\nimport type { Event } from '@gitlens/utils/event.js';\nimport { Emitter } from '@gitlens/utils/event.js';\nimport { normalizePath } from '@gitlens/utils/path.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\nimport { getRepositoryKey } from '@gitlens/utils/uri.js';\nimport type { MergeTargetsChangeEvent } from './cache.js';\nimport type { GitProvider } from './providers/provider.js';\nimport type { RepositoryService, SubProviderForRepo } from './repositoryService.js';\nimport {\n\tclearGlobalRepositoryServiceResolver,\n\tcreateSubProviderProxyForRepo,\n\tsetGlobalRepositoryServiceResolver,\n} from './repositoryService.js';\nimport type { FileWatchingProvider } from './watching/provider.js';\nimport type { WatchPollingOptions } from './watching/watchService.js';\nimport { RepositoryWatchService } from './watching/watchService.js';\nimport type { WorktreeSummaryServiceOptions } from './watching/worktreeSummary.js';\nimport { WorktreeSummaryService } from './watching/worktreeSummary.js';\n\nexport interface ProvidersChangeEvent {\n\treadonly added: readonly GitProvider[];\n\treadonly removed: readonly GitProvider[];\n\treadonly etag: number;\n}\n\n/**\n * Result of {@link GitService.validateRepo}.\n *\n * - `valid: true, safe: true` — a usable git repository at `repoPath`; `gitDir` / `commonGitDir` / `superprojectPath` are populated when available\n * - `valid: true, safe: false` — git detected unsafe (dubious) ownership at the given path; no `repoPath` is surfaced (the raw call doesn't carry one back)\n * - `valid: false` — not a git repository, no registered provider can handle the path, or the routed provider doesn't implement `getRepositoryInfo`\n */\nexport type ValidateRepoResult =\n\t| {\n\t\t\tvalid: true;\n\t\t\tsafe: true;\n\t\t\trepoPath: string;\n\t\t\tgitDir?: string;\n\t\t\tcommonGitDir?: string;\n\t\t\tsuperprojectPath?: string;\n\t }\n\t| { valid: true; safe: false }\n\t| { valid: false };\n\ninterface RegisteredProvider {\n\tprovider: GitProvider;\n\tcanHandle: (repoPath: string) => boolean;\n\t/** Forwards the provider's write announcements to {@link GitService.watchService}, when there is one */\n\tannouncements?: UnifiedDisposable;\n}\n\ninterface MergeTargetsSource {\n\treadonly subscription: UnifiedDisposable;\n\trefCount: number;\n}\n\n/**\n * Entry point — provider router, repo-scoped proxy cache, and global configuration.\n *\n * Creating an instance wires up the module-level repository\n * resolver. Calling {@link dispose} tears it down.\n *\n * Consumers register providers with routing predicates, then call\n * {@link forRepo} to get a {@link RepositoryService} with sub-provider\n * proxies that auto-inject the repository path.\n *\n * The service has no discovery or repository tracking state — it trusts\n * the caller to pass valid repository paths. Discovery and lifecycle\n * (open/close, file watching, etc.) are application-level concerns.\n *\n * @example\n * ```typescript\n * const service = GitService.createSingleton();\n * service.register(cliProvider, (path) => true);\n *\n * const repo = service.forRepo('/home/user/repo');\n * const branches = await repo.branches.getBranches();\n *\n * service.dispose(); // cleans up module-level hooks\n * ```\n */\nexport class GitService implements UnifiedDisposable {\n\tprivate static _instance: GitService | undefined;\n\n\t/**\n\t * `options.watchPolling` opts the watch service into polling what `watchingProvider` reports it can't watch,\n\t * `options.readFile` lets it tell what a reported `.git/config` change changed (see `WatchServiceOptions.readFile`),\n\t * and with it `options.readDirectory` lets it drop the reports of ignored worktrees (see\n\t * `WatchServiceOptions.readDirectory`).\n\t * `options.verifyBaseRemeasure` is for tests only (see `WorktreeSummaryServiceOptions.verifyBaseRemeasure`)\n\t */\n\tstatic createSingleton(\n\t\twatchingProvider?: FileWatchingProvider,\n\t\toptions?: {\n\t\t\twatchPolling?: WatchPollingOptions;\n\t\t\treadFile?: (path: string) => Promise<Uint8Array>;\n\t\t\treadDirectory?: (path: string) => Promise<readonly (readonly [string, number])[]>;\n\t\t\tverifyBaseRemeasure?: WorktreeSummaryServiceOptions['verifyBaseRemeasure'];\n\t\t},\n\t): GitService {\n\t\tif (GitService._instance != null) {\n\t\t\tthrow new Error('GitService already exists — only one instance is allowed');\n\t\t}\n\n\t\tconst instance = new GitService(\n\t\t\twatchingProvider,\n\t\t\toptions?.watchPolling,\n\t\t\toptions?.readFile,\n\t\t\toptions?.readDirectory,\n\t\t\toptions?.verifyBaseRemeasure,\n\t\t);\n\t\tGitService._instance = instance;\n\t\treturn instance;\n\t}\n\n\tprivate readonly _onDidChangeProviders = new Emitter<ProvidersChangeEvent>();\n\tget onDidChangeProviders(): Event<ProvidersChangeEvent> {\n\t\treturn this._onDidChangeProviders.event;\n\t}\n\n\tprivate readonly _onDidChangeMergeTargets = new Emitter<MergeTargetsChangeEvent>();\n\t/**\n\t * Fires when a write changed a branch's merge-relevant `.git/gk/config` keys, for any registered provider that\n\t * reports it — never for activity timestamps. Core's own key write fires it once, as the write completes, naming\n\t * the branch. Once per change per repository (`repoPath` is its common path); see {@link MergeTargetsChangeEvent}.\n\t */\n\tget onDidChangeMergeTargets(): Event<MergeTargetsChangeEvent> {\n\t\treturn this._onDidChangeMergeTargets.event;\n\t}\n\n\t/** Keyed by the provider's event, so providers sharing one cache are forwarded once */\n\tprivate readonly _mergeTargetsSources = new Map<Event<MergeTargetsChangeEvent>, MergeTargetsSource>();\n\n\tprivate _etag = 0;\n\tprivate readonly _providers: RegisteredProvider[] = [];\n\tprivate readonly _serviceCache = new Map<string, RepositoryService>();\n\tprivate readonly _watchService: RepositoryWatchService | undefined;\n\tprivate readonly _summaries: WorktreeSummaryService | undefined;\n\n\tprivate constructor(\n\t\twatchingProvider?: FileWatchingProvider,\n\t\twatchPolling?: WatchPollingOptions,\n\t\treadFile?: (path: string) => Promise<Uint8Array>,\n\t\treadDirectory?: (path: string) => Promise<readonly (readonly [string, number])[]>,\n\t\tverifyBaseRemeasure?: WorktreeSummaryServiceOptions['verifyBaseRemeasure'],\n\t) {\n\t\tif (watchingProvider != null) {\n\t\t\tthis._watchService = new RepositoryWatchService({\n\t\t\t\twatchingProvider: watchingProvider,\n\t\t\t\tpolling: watchPolling,\n\t\t\t\treadFile: readFile,\n\t\t\t\treadDirectory: readDirectory,\n\t\t\t\tgetIgnoreFilter: (repoPath, gitDirPath) => {\n\t\t\t\t\treturn this.getProvider(repoPath)?.provider.getIgnoreFilter?.(repoPath, gitDirPath);\n\t\t\t\t},\n\t\t\t\tgetIgnoredDirectories: repoPath =>\n\t\t\t\t\tthis.getProvider(repoPath)?.provider.getIgnoredDirectories?.(repoPath) ?? Promise.resolve([]),\n\t\t\t\tgetIgnoredWorktreeRoots: repoPath =>\n\t\t\t\t\tthis.getProvider(repoPath)?.provider.getIgnoredWorktreeRoots?.(repoPath) ?? Promise.resolve([]),\n\t\t\t\tgetIgnoredWorktreeFolders: repoPath =>\n\t\t\t\t\tthis.getProvider(repoPath)?.provider.getIgnoredWorktreeFolders?.(repoPath) ?? [],\n\t\t\t});\n\t\t\tthis._summaries = new WorktreeSummaryService({\n\t\t\t\twatchService: this._watchService,\n\t\t\t\tgetRepository: repoPath => this.forRepo(repoPath),\n\t\t\t\tonDidChangeMergeTargets: this.onDidChangeMergeTargets,\n\t\t\t\tgetCommonPath: repoPath => this.getProvider(repoPath)?.provider.getCommonPath?.(repoPath),\n\t\t\t\t// The host's polling stat, when it configured polling, answers whether an unwatched index file moved\n\t\t\t\tstat: watchPolling?.stat,\n\t\t\t\tverifyBaseRemeasure: verifyBaseRemeasure,\n\t\t\t});\n\t\t}\n\n\t\tsetGlobalRepositoryServiceResolver(repoPath => this.forRepo(repoPath));\n\t}\n\n\t[Symbol.dispose](): void {\n\t\tthis.dispose();\n\t}\n\n\tdispose(): void {\n\t\tclearGlobalRepositoryServiceResolver();\n\t\tGitService._instance = undefined;\n\t\tthis._serviceCache.clear();\n\t\tthis._summaries?.dispose();\n\t\tthis._watchService?.dispose();\n\n\t\t// Don't dispose providers since they're owned by the caller, but do clear the array to release references\n\t\tfor (const entry of this._providers) {\n\t\t\tentry.announcements?.dispose();\n\t\t}\n\t\tthis._providers.length = 0;\n\n\t\tfor (const source of this._mergeTargetsSources.values()) {\n\t\t\tsource.subscription.dispose();\n\t\t}\n\t\tthis._mergeTargetsSources.clear();\n\n\t\tthis._onDidChangeProviders.dispose();\n\t\tthis._onDidChangeMergeTargets.dispose();\n\t}\n\n\t/** Monotonically increasing counter incremented on structural changes. */\n\tget etag(): number {\n\t\treturn this._etag;\n\t}\n\n\t/** Whether any providers are registered. */\n\tget hasProviders(): boolean {\n\t\treturn this._providers.length > 0;\n\t}\n\n\tget watchService(): RepositoryWatchService | undefined {\n\t\treturn this._watchService;\n\t}\n\n\t/** Cached, change-notifying per-worktree summaries, kept current by {@link watchService}; present when it is */\n\tget summaries(): WorktreeSummaryService | undefined {\n\t\treturn this._summaries;\n\t}\n\n\t/**\n\t * Registers a provider with a routing predicate.\n\t *\n\t * @returns A disposable that unregisters the provider.\n\t */\n\tregister(provider: GitProvider, canHandle: (repoPath: string) => boolean): UnifiedDisposable {\n\t\tconst watchService = this._watchService;\n\t\tconst entry: RegisteredProvider = {\n\t\t\tprovider: provider,\n\t\t\tcanHandle: canHandle,\n\t\t\tannouncements:\n\t\t\t\twatchService != null\n\t\t\t\t\t? provider.onDidAnnounceChanges?.(e =>\n\t\t\t\t\t\t\twatchService.noteSelfWrite(e.repoPath, e.changes, e.refs, {\n\t\t\t\t\t\t\t\tconfigConfinedToRefs: e.configConfinedToRefs,\n\t\t\t\t\t\t\t\tmovedWorktrees: e.movedWorktrees,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t)\n\t\t\t\t\t: undefined,\n\t\t};\n\t\tthis._providers.push(entry);\n\t\tthis._etag++;\n\t\tthis.addMergeTargetsSource(provider);\n\n\t\tthis._onDidChangeProviders.fire({\n\t\t\tadded: [provider],\n\t\t\tremoved: [],\n\t\t\tetag: this._etag,\n\t\t});\n\n\t\t// Invalidate cached proxies since provider routing may have changed\n\t\tthis._serviceCache.clear();\n\n\t\treturn createDisposable(() => {\n\t\t\tconst idx = this._providers.indexOf(entry);\n\t\t\tif (idx !== -1) {\n\t\t\t\tthis._providers.splice(idx, 1);\n\t\t\t\tentry.announcements?.dispose();\n\t\t\t\tthis._etag++;\n\t\t\t\tthis.removeMergeTargetsSource(provider);\n\t\t\t\tthis._serviceCache.clear();\n\n\t\t\t\tthis._onDidChangeProviders.fire({\n\t\t\t\t\tadded: [],\n\t\t\t\t\tremoved: [provider],\n\t\t\t\t\tetag: this._etag,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate addMergeTargetsSource(provider: GitProvider): void {\n\t\tconst event = provider.onDidChangeMergeTargets;\n\t\tif (event == null) return;\n\n\t\tconst source = this._mergeTargetsSources.get(event);\n\t\tif (source != null) {\n\t\t\tsource.refCount++;\n\t\t\treturn;\n\t\t}\n\n\t\tthis._mergeTargetsSources.set(event, {\n\t\t\tsubscription: event(e => this._onDidChangeMergeTargets.fire(e)),\n\t\t\trefCount: 1,\n\t\t});\n\t}\n\n\tprivate removeMergeTargetsSource(provider: GitProvider): void {\n\t\tconst event = provider.onDidChangeMergeTargets;\n\t\tif (event == null) return;\n\n\t\tconst source = this._mergeTargetsSources.get(event);\n\t\tif (source == null || --source.refCount > 0) return;\n\n\t\tsource.subscription.dispose();\n\t\tthis._mergeTargetsSources.delete(event);\n\t}\n\n\t/** Returns the provider that can handle the given path, or undefined if none matches. */\n\tgetProvider(repoPath: string): { provider: GitProvider; path: string } | undefined {\n\t\trepoPath = normalizePath(repoPath);\n\t\tfor (const entry of this._providers) {\n\t\t\tif (entry.canHandle(repoPath)) {\n\t\t\t\treturn { provider: entry.provider, path: repoPath };\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/** Returns all registered providers. */\n\t*getProviders(): Iterable<GitProvider> {\n\t\tfor (const entry of this._providers) {\n\t\t\tyield entry.provider;\n\t\t}\n\t}\n\n\t/**\n\t * Routes a repo URI/path to a provider and returns a cached\n\t * {@link RepositoryService} with repo-scoped sub-provider proxies.\n\t * Returns undefined if no provider can handle the path.\n\t */\n\tforRepo(repoUri: Uri | string): RepositoryService | undefined {\n\t\tconst repoPath = getRepositoryKey(repoUri);\n\n\t\tlet repo = this._serviceCache.get(repoPath);\n\t\tif (repo != null) return repo;\n\n\t\tconst result = this.getProvider(repoPath);\n\t\tif (result == null) return undefined;\n\n\t\trepo = createRepositoryService(result.provider, repoPath, this._watchService);\n\t\tthis._serviceCache.set(repoPath, repo);\n\t\treturn repo;\n\t}\n\n\t/**\n\t * Evicts the cached {@link RepositoryService} for a closed or removed repository.\n\t * No-op if the path isn't cached.\n\t */\n\tcloseRepo(repoUri: Uri | string): void {\n\t\tconst repoPath = getRepositoryKey(repoUri);\n\t\tthis._serviceCache.delete(repoPath);\n\t}\n\n\t/**\n\t * Validates whether `pathOrUri` points to (or resides inside) a git repository,\n\t * and returns information about it when it does.\n\t *\n\t * Routes the path to a registered provider and delegates to its config sub-provider's\n\t * `getRepositoryInfo` implementation, then normalizes the raw result into a clean\n\t * discriminated union. For a simple yes/no check, use `(await validateRepo(path)).valid`.\n\t *\n\t * Returns `{ valid: false }` if no provider can handle the path or if the routed\n\t * provider does not implement `getRepositoryInfo`. Rejects when git gives no answer\n\t * (it ran past its time limit, was killed or couldn't start), which says nothing about the path.\n\t */\n\tasync validateRepo(pathOrUri: Uri | string): Promise<ValidateRepoResult> {\n\t\tconst key = getRepositoryKey(pathOrUri);\n\t\tconst routed = this.getProvider(key);\n\t\tif (routed == null) return { valid: false };\n\n\t\tconst info = await routed.provider.config.getRepositoryInfo?.(routed.path);\n\t\tif (info == null) return { valid: false };\n\n\t\tif (Array.isArray(info)) {\n\t\t\tif (info.length === 0) return { valid: false };\n\t\t\tif (info[0] === false) return { valid: true, safe: false };\n\t\t\treturn { valid: true, safe: true, repoPath: info[1] };\n\t\t}\n\n\t\treturn {\n\t\t\tvalid: true,\n\t\t\tsafe: true,\n\t\t\trepoPath: info.repoPath,\n\t\t\tgitDir: info.gitDir,\n\t\t\tcommonGitDir: info.commonGitDir,\n\t\t\tsuperprojectPath: info.superprojectPath,\n\t\t};\n\t}\n}\n\nfunction createRepositoryService(\n\tprovider: GitProvider,\n\trepoPath: string,\n\twatchService?: RepositoryWatchService,\n): RepositoryService {\n\tconst proxies = new Map<string, SubProviderForRepo<unknown>>();\n\n\tfunction getProxy<T extends object>(prop: string, subProvider: T | undefined): SubProviderForRepo<T> | undefined {\n\t\tif (subProvider == null) return undefined;\n\n\t\tlet proxy = proxies.get(prop);\n\t\tif (proxy == null) {\n\t\t\tproxy = createSubProviderProxyForRepo(subProvider, repoPath);\n\t\t\tproxies.set(prop, proxy);\n\t\t}\n\t\treturn proxy as SubProviderForRepo<T>;\n\t}\n\n\treturn {\n\t\tpath: repoPath,\n\t\tprovider: provider.descriptor,\n\n\t\tget etagWorkingTree(): number | undefined {\n\t\t\treturn watchService?.getSession(repoPath)?.etagWorkingTree;\n\t\t},\n\n\t\tgetAbsoluteUri: (relativePath: string): Uri => {\n\t\t\treturn provider.getAbsoluteUri(relativePath, repoPath);\n\t\t},\n\n\t\t// Required sub-providers\n\t\tget branches() {\n\t\t\tconst proxy = getProxy('branches', provider.branches);\n\t\t\tif (proxy == null) throw new Error('GitService: branches sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget commits() {\n\t\t\tconst proxy = getProxy('commits', provider.commits);\n\t\t\tif (proxy == null) throw new Error('GitService: commits sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget config() {\n\t\t\tconst proxy = getProxy('config', provider.config);\n\t\t\tif (proxy == null) throw new Error('GitService: config sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget contributors() {\n\t\t\tconst proxy = getProxy('contributors', provider.contributors);\n\t\t\tif (proxy == null) throw new Error('GitService: contributors sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget diff() {\n\t\t\tconst proxy = getProxy('diff', provider.diff);\n\t\t\tif (proxy == null) throw new Error('GitService: diff sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget graph() {\n\t\t\tconst proxy = getProxy('graph', provider.graph);\n\t\t\tif (proxy == null) throw new Error('GitService: graph sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget refs() {\n\t\t\tconst proxy = getProxy('refs', provider.refs);\n\t\t\tif (proxy == null) throw new Error('GitService: refs sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget remotes() {\n\t\t\tconst proxy = getProxy('remotes', provider.remotes);\n\t\t\tif (proxy == null) throw new Error('GitService: remotes sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget revision() {\n\t\t\tconst proxy = getProxy('revision', provider.revision);\n\t\t\tif (proxy == null) throw new Error('GitService: revision sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget status() {\n\t\t\tconst proxy = getProxy('status', provider.status);\n\t\t\tif (proxy == null) throw new Error('GitService: status sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget tags() {\n\t\t\tconst proxy = getProxy('tags', provider.tags);\n\t\t\tif (proxy == null) throw new Error('GitService: tags sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\n\t\t// Optional sub-providers\n\t\tget blame() {\n\t\t\treturn getProxy('blame', provider.blame);\n\t\t},\n\t\tget maintenance() {\n\t\t\treturn getProxy('maintenance', provider.maintenance);\n\t\t},\n\t\tget ops() {\n\t\t\treturn getProxy('ops', provider.ops);\n\t\t},\n\t\tget patch() {\n\t\t\treturn getProxy('patch', provider.patch);\n\t\t},\n\t\tget pausedOps() {\n\t\t\treturn getProxy('pausedOps', provider.pausedOps);\n\t\t},\n\t\tget staging() {\n\t\t\treturn getProxy('staging', provider.staging);\n\t\t},\n\t\tget stash() {\n\t\t\treturn getProxy('stash', provider.stash);\n\t\t},\n\t\tget worktrees() {\n\t\t\treturn getProxy('worktrees', provider.worktrees);\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFA,IAAa,aAAb,MAAa,WAAwC;CACpD,OAAe;;;;;;;;CASf,OAAO,gBACN,kBACA,SAMa;EACb,IAAI,WAAW,aAAa,MAC3B,MAAM,IAAI,MAAM,0DAA0D;EAG3E,MAAM,WAAW,IAAI,WACpB,kBACA,SAAS,cACT,SAAS,UACT,SAAS,eACT,SAAS,mBACV;EACA,WAAW,YAAY;EACvB,OAAO;CACR;CAEA,wBAAyC,IAAI,QAA8B;CAC3E,IAAI,uBAAoD;EACvD,OAAO,KAAK,sBAAsB;CACnC;CAEA,2BAA4C,IAAI,QAAiC;;;;;;CAMjF,IAAI,0BAA0D;EAC7D,OAAO,KAAK,yBAAyB;CACtC;;CAGA,uCAAwC,IAAI,IAAwD;CAEpG,QAAgB;CAChB,aAAoD,CAAC;CACrD,gCAAiC,IAAI,IAA+B;CACpE;CACA;CAEA,YACC,kBACA,cACA,UACA,eACA,qBACC;EACD,IAAI,oBAAoB,MAAM;GAC7B,KAAK,gBAAgB,IAAI,uBAAuB;IAC7B;IAClB,SAAS;IACC;IACK;IACf,kBAAkB,UAAU,eAAe;KAC1C,OAAO,KAAK,YAAY,QAAQ,CAAC,EAAE,SAAS,kBAAkB,UAAU,UAAU;IACnF;IACA,wBAAuB,aACtB,KAAK,YAAY,QAAQ,CAAC,EAAE,SAAS,wBAAwB,QAAQ,KAAK,QAAQ,QAAQ,CAAC,CAAC;IAC7F,0BAAyB,aACxB,KAAK,YAAY,QAAQ,CAAC,EAAE,SAAS,0BAA0B,QAAQ,KAAK,QAAQ,QAAQ,CAAC,CAAC;IAC/F,4BAA2B,aAC1B,KAAK,YAAY,QAAQ,CAAC,EAAE,SAAS,4BAA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AAM,MAAM,IAAI,MAAM,iEAAiE;GACpG,OAAO;EACR;EACA,IAAI,WAAW;GACd,MAAM,QAAQ,SAAS,YAAY,SAAS,QAAQ;GACpD,IAAI,SAAS,MAAM,MAAM,IAAI,MAAM,kEAAkE;GACrG,OAAO;EACR;EACA,IAAI,SAAS;GACZ,MAAM,QAAQ,SAAS,UAAU,SAAS,MAAM;GAChD,IAAI,SAAS,MAAM,MAAM,IAAI,MAAM,gEAAgE;GACnG,OAAO;EACR;EACA,IAAI,OAAO;GACV,MAAM,QAAQ,SAAS,QAAQ,SAAS,IAAI;GAC5C,IAAI,SAAS,MAAM,MAAM,IAAI,MAAM,8DAA8D;GACjG,OAAO;EACR;EAGA,IAAI,QAAQ;GACX,OAAO,SAAS,SAAS,SAAS,KAAK;EACxC;EACA,IAAI,cAAc;GACjB,OAAO,SAAS,eAAe,SAAS,WAAW;EACpD;EACA,IAAI,MAAM;GACT,OAAO,SAAS,OAAO,SAAS,GAAG;EACpC;EACA,IAAI,QAAQ;GACX,OAAO,SAAS,SAAS,SAAS,KAAK;EACxC;EACA,IAAI,YAAY;GACf,OAAO,SAAS,aAAa,SAAS,SAAS;EAChD;EACA,IAAI,UAAU;GACb,OAAO,SAAS,WAAW,SAAS,OAAO;EAC5C;EACA,IAAI,QAAQ;GACX,OAAO,SAAS,SAAS,SAAS,KAAK;EACxC;EACA,IAAI,YAAY;GACf,OAAO,SAAS,aAAa,SAAS,SAAS;EAChD;CACD;AACD"}
|
|
@@ -3,5 +3,15 @@ import { Uri } from "../../utils/uri.js";
|
|
|
3
3
|
export declare function getRepositoryOrWorktreePath(uri: Uri): string;
|
|
4
4
|
export declare function getCommonRepositoryPath(commonUri: Uri): string;
|
|
5
5
|
export declare function getCommonRepositoryUri(commonUri: Uri): Uri;
|
|
6
|
+
/**
|
|
7
|
+
* A path relative to the common `.git` directory that is a linked worktree's admin entry, `worktrees/<id>`, or a file
|
|
8
|
+
* in it: its admin id, and the file's path within the entry (`undefined` for the entry itself)
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseWorktreeAdminPath(relativePath: string): {
|
|
11
|
+
readonly id: string;
|
|
12
|
+
readonly file: string | undefined;
|
|
13
|
+
} | undefined;
|
|
14
|
+
/** The admin id of the linked worktree whose git dir is `gitDirPath`: the `<id>` of `<commonGitDirPath>/worktrees/<id>` */
|
|
15
|
+
export declare function getWorktreeAdminId(gitDirPath: string, commonGitDirPath: string): string | undefined;
|
|
6
16
|
//#endregion
|
|
7
17
|
//# sourceMappingURL=repository.utils.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizePath } from "../../utils/path.js";
|
|
1
|
+
import { isDescendant, normalizePath, relative } from "../../utils/path.js";
|
|
2
2
|
//#region ../git/src/utils/repository.utils.ts
|
|
3
3
|
function getRepositoryOrWorktreePath(uri) {
|
|
4
4
|
return uri.scheme === "file" ? normalizePath(uri.fsPath) : uri.toString();
|
|
@@ -10,7 +10,30 @@ function getCommonRepositoryUri(commonUri) {
|
|
|
10
10
|
if (commonUri?.path.endsWith("/.git")) return commonUri.with({ path: commonUri.path.substring(0, commonUri.path.length - 5) });
|
|
11
11
|
return commonUri;
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* A path relative to the common `.git` directory that is a linked worktree's admin entry, `worktrees/<id>`, or a file
|
|
15
|
+
* in it: its admin id, and the file's path within the entry (`undefined` for the entry itself)
|
|
16
|
+
*/
|
|
17
|
+
function parseWorktreeAdminPath(relativePath) {
|
|
18
|
+
if (relativePath.length <= 10 || !relativePath.startsWith("worktrees/")) return void 0;
|
|
19
|
+
const idEnd = relativePath.indexOf("/", 10);
|
|
20
|
+
if (idEnd === -1) return {
|
|
21
|
+
id: relativePath.substring(10),
|
|
22
|
+
file: void 0
|
|
23
|
+
};
|
|
24
|
+
if (idEnd === 10) return void 0;
|
|
25
|
+
return {
|
|
26
|
+
id: relativePath.substring(10, idEnd),
|
|
27
|
+
file: relativePath.substring(idEnd + 1)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** The admin id of the linked worktree whose git dir is `gitDirPath`: the `<id>` of `<commonGitDirPath>/worktrees/<id>` */
|
|
31
|
+
function getWorktreeAdminId(gitDirPath, commonGitDirPath) {
|
|
32
|
+
if (!isDescendant(gitDirPath, commonGitDirPath)) return void 0;
|
|
33
|
+
const entry = parseWorktreeAdminPath(relative(commonGitDirPath, gitDirPath));
|
|
34
|
+
return entry != null && entry.file == null ? entry.id : void 0;
|
|
35
|
+
}
|
|
13
36
|
//#endregion
|
|
14
|
-
export { getCommonRepositoryPath, getCommonRepositoryUri, getRepositoryOrWorktreePath };
|
|
37
|
+
export { getCommonRepositoryPath, getCommonRepositoryUri, getRepositoryOrWorktreePath, getWorktreeAdminId, parseWorktreeAdminPath };
|
|
15
38
|
|
|
16
39
|
//# sourceMappingURL=repository.utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.utils.js","names":[],"sources":["../../../../git/src/utils/repository.utils.ts"],"sourcesContent":["import { normalizePath } from '@gitlens/utils/path.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\n\nexport function getRepositoryOrWorktreePath(uri: Uri): string {\n\treturn uri.scheme === 'file' ? normalizePath(uri.fsPath) : uri.toString();\n}\n\nexport function getCommonRepositoryPath(commonUri: Uri): string {\n\tconst uri = getCommonRepositoryUri(commonUri);\n\treturn getRepositoryOrWorktreePath(uri);\n}\n\nexport function getCommonRepositoryUri(commonUri: Uri): Uri {\n\tif (commonUri?.path.endsWith('/.git')) {\n\t\treturn commonUri.with({ path: commonUri.path.substring(0, commonUri.path.length - 5) });\n\t}\n\treturn commonUri;\n}\n"],"mappings":";;AAGA,SAAgB,4BAA4B,KAAkB;CAC7D,OAAO,IAAI,WAAW,SAAS,cAAc,IAAI,MAAM,IAAI,IAAI,SAAS;AACzE;AAEA,SAAgB,wBAAwB,WAAwB;CAE/D,OAAO,4BADK,uBAAuB,SACE,CAAC;AACvC;AAEA,SAAgB,uBAAuB,WAAqB;CAC3D,IAAI,WAAW,KAAK,SAAS,OAAO,GACnC,OAAO,UAAU,KAAK,EAAE,MAAM,UAAU,KAAK,UAAU,GAAG,UAAU,KAAK,SAAS,CAAC,EAAE,CAAC;CAEvF,OAAO;AACR"}
|
|
1
|
+
{"version":3,"file":"repository.utils.js","names":[],"sources":["../../../../git/src/utils/repository.utils.ts"],"sourcesContent":["import { isDescendant, normalizePath, relative } from '@gitlens/utils/path.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\n\nexport function getRepositoryOrWorktreePath(uri: Uri): string {\n\treturn uri.scheme === 'file' ? normalizePath(uri.fsPath) : uri.toString();\n}\n\nexport function getCommonRepositoryPath(commonUri: Uri): string {\n\tconst uri = getCommonRepositoryUri(commonUri);\n\treturn getRepositoryOrWorktreePath(uri);\n}\n\nexport function getCommonRepositoryUri(commonUri: Uri): Uri {\n\tif (commonUri?.path.endsWith('/.git')) {\n\t\treturn commonUri.with({ path: commonUri.path.substring(0, commonUri.path.length - 5) });\n\t}\n\treturn commonUri;\n}\n\n/**\n * A path relative to the common `.git` directory that is a linked worktree's admin entry, `worktrees/<id>`, or a file\n * in it: its admin id, and the file's path within the entry (`undefined` for the entry itself)\n */\nexport function parseWorktreeAdminPath(\n\trelativePath: string,\n): { readonly id: string; readonly file: string | undefined } | undefined {\n\tif (relativePath.length <= 10 || !relativePath.startsWith('worktrees/')) return undefined;\n\n\tconst idEnd = relativePath.indexOf('/', 10);\n\tif (idEnd === -1) return { id: relativePath.substring(10), file: undefined };\n\tif (idEnd === 10) return undefined;\n\n\treturn { id: relativePath.substring(10, idEnd), file: relativePath.substring(idEnd + 1) };\n}\n\n/** The admin id of the linked worktree whose git dir is `gitDirPath`: the `<id>` of `<commonGitDirPath>/worktrees/<id>` */\nexport function getWorktreeAdminId(gitDirPath: string, commonGitDirPath: string): string | undefined {\n\tif (!isDescendant(gitDirPath, commonGitDirPath)) return undefined;\n\n\tconst entry = parseWorktreeAdminPath(relative(commonGitDirPath, gitDirPath));\n\treturn entry != null && entry.file == null ? entry.id : undefined;\n}\n"],"mappings":";;AAGA,SAAgB,4BAA4B,KAAkB;CAC7D,OAAO,IAAI,WAAW,SAAS,cAAc,IAAI,MAAM,IAAI,IAAI,SAAS;AACzE;AAEA,SAAgB,wBAAwB,WAAwB;CAE/D,OAAO,4BADK,uBAAuB,SACE,CAAC;AACvC;AAEA,SAAgB,uBAAuB,WAAqB;CAC3D,IAAI,WAAW,KAAK,SAAS,OAAO,GACnC,OAAO,UAAU,KAAK,EAAE,MAAM,UAAU,KAAK,UAAU,GAAG,UAAU,KAAK,SAAS,CAAC,EAAE,CAAC;CAEvF,OAAO;AACR;;;;;AAMA,SAAgB,uBACf,cACyE;CACzE,IAAI,aAAa,UAAU,MAAM,CAAC,aAAa,WAAW,YAAY,GAAG,OAAO,KAAA;CAEhF,MAAM,QAAQ,aAAa,QAAQ,KAAK,EAAE;CAC1C,IAAI,UAAU,IAAI,OAAO;EAAE,IAAI,aAAa,UAAU,EAAE;EAAG,MAAM,KAAA;CAAU;CAC3E,IAAI,UAAU,IAAI,OAAO,KAAA;CAEzB,OAAO;EAAE,IAAI,aAAa,UAAU,IAAI,KAAK;EAAG,MAAM,aAAa,UAAU,QAAQ,CAAC;CAAE;AACzF;;AAGA,SAAgB,mBAAmB,YAAoB,kBAA8C;CACpG,IAAI,CAAC,aAAa,YAAY,gBAAgB,GAAG,OAAO,KAAA;CAExD,MAAM,QAAQ,uBAAuB,SAAS,kBAAkB,UAAU,CAAC;CAC3E,OAAO,SAAS,QAAQ,MAAM,QAAQ,OAAO,MAAM,KAAK,KAAA;AACzD"}
|
|
@@ -36,13 +36,16 @@ export declare class WatcherRepoChangeEvent {
|
|
|
36
36
|
private readonly _unnamedRefKinds;
|
|
37
37
|
private readonly _announced;
|
|
38
38
|
private readonly _configBranches;
|
|
39
|
+
private readonly _movedWorktrees;
|
|
39
40
|
constructor(
|
|
40
41
|
/** The repository path this event is for */
|
|
41
42
|
repoPath: string, changes: RepositoryChange[],
|
|
42
43
|
/** Which refs changed; when omitted, every ref kind in `changes` is unnamed (any ref of that kind may have moved) */
|
|
43
44
|
refs?: WatcherRefChanges,
|
|
44
45
|
/** The kinds of `changes` that come only from core's own announced writes (see {@link announced}) */
|
|
45
|
-
announced?: Iterable<RepositoryChange
|
|
46
|
+
announced?: Iterable<RepositoryChange>,
|
|
47
|
+
/** For a `worktreeHead` among `changes`, the worktrees moved outside core's writes (see {@link movedWorktrees}) */
|
|
48
|
+
movedWorktrees?: Iterable<string>);
|
|
46
49
|
get changes(): ReadonlySet<RepositoryChange>;
|
|
47
50
|
/**
|
|
48
51
|
* The kinds in {@link changes} that come only from core's own writes, which core already announced through
|
|
@@ -62,6 +65,12 @@ export declare class WatcherRepoChangeEvent {
|
|
|
62
65
|
* {@link refs}: an outside edit to a branch's tracking moves no ref.
|
|
63
66
|
*/
|
|
64
67
|
get configBranches(): ReadonlySet<string> | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* The admin ids (the `<id>` of `.git/worktrees/<id>`) of the linked worktrees whose HEAD moved other than by core's
|
|
70
|
+
* announced writes, which are all that an unannounced `worktreeHead` reports; `undefined` when `worktreeHead` didn't
|
|
71
|
+
* change, or any linked worktree's HEAD may have moved.
|
|
72
|
+
*/
|
|
73
|
+
get movedWorktrees(): ReadonlySet<string> | undefined;
|
|
65
74
|
/** Whether `config` changed only in the sections of {@link configBranches} */
|
|
66
75
|
get configConfined(): boolean;
|
|
67
76
|
/**
|
|
@@ -103,9 +112,10 @@ export declare class WatcherRepoChangeEvent {
|
|
|
103
112
|
/**
|
|
104
113
|
* Coalesce: return a new event with all changes and refs from both this and the given set. When `refs` is omitted,
|
|
105
114
|
* every ref kind in `changes` counts as unnamed. A kind in `changes` is no longer {@link announced}. `config` stays
|
|
106
|
-
* {@link configConfined}, to the branches of both, only when each side that changed it was confined
|
|
115
|
+
* {@link configConfined}, to the branches of both, only when each side that changed it was confined, and
|
|
116
|
+
* `worktreeHead` keeps {@link movedWorktrees}, those of both, only when each side that changed it named them.
|
|
107
117
|
*/
|
|
108
|
-
with(changes: RepositoryChange[], refs?: WatcherRefChanges): WatcherRepoChangeEvent;
|
|
118
|
+
with(changes: RepositoryChange[], refs?: WatcherRefChanges, movedWorktrees?: Iterable<string>): WatcherRepoChangeEvent;
|
|
109
119
|
}
|
|
110
120
|
/**
|
|
111
121
|
* Returns the name in `names` that covers `ref` — `ref` itself, or a ref directory above it (compared on `/`
|
|
@@ -30,7 +30,8 @@ var WatcherRepoChangeEvent = class WatcherRepoChangeEvent {
|
|
|
30
30
|
_unnamedRefKinds;
|
|
31
31
|
_announced;
|
|
32
32
|
_configBranches;
|
|
33
|
-
|
|
33
|
+
_movedWorktrees;
|
|
34
|
+
constructor(repoPath, changes, refs, announced, movedWorktrees) {
|
|
34
35
|
this.repoPath = repoPath;
|
|
35
36
|
this._changes = new Set(changes);
|
|
36
37
|
if (refs == null) {
|
|
@@ -42,6 +43,7 @@ var WatcherRepoChangeEvent = class WatcherRepoChangeEvent {
|
|
|
42
43
|
}
|
|
43
44
|
this._configBranches = refs?.configBranches != null && this._changes.has("config") ? new Set(refs.configBranches) : void 0;
|
|
44
45
|
this._announced = announced != null ? new Set(filter(announced, (c) => this._changes.has(c))) : /* @__PURE__ */ new Set();
|
|
46
|
+
this._movedWorktrees = movedWorktrees != null && this._changes.has("worktreeHead") ? new Set(movedWorktrees) : void 0;
|
|
45
47
|
}
|
|
46
48
|
get changes() {
|
|
47
49
|
return this._changes;
|
|
@@ -74,6 +76,14 @@ var WatcherRepoChangeEvent = class WatcherRepoChangeEvent {
|
|
|
74
76
|
get configBranches() {
|
|
75
77
|
return this._configBranches;
|
|
76
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* The admin ids (the `<id>` of `.git/worktrees/<id>`) of the linked worktrees whose HEAD moved other than by core's
|
|
81
|
+
* announced writes, which are all that an unannounced `worktreeHead` reports; `undefined` when `worktreeHead` didn't
|
|
82
|
+
* change, or any linked worktree's HEAD may have moved.
|
|
83
|
+
*/
|
|
84
|
+
get movedWorktrees() {
|
|
85
|
+
return this._movedWorktrees;
|
|
86
|
+
}
|
|
77
87
|
/** Whether `config` changed only in the sections of {@link configBranches} */
|
|
78
88
|
get configConfined() {
|
|
79
89
|
return this._configBranches != null;
|
|
@@ -146,9 +156,10 @@ var WatcherRepoChangeEvent = class WatcherRepoChangeEvent {
|
|
|
146
156
|
/**
|
|
147
157
|
* Coalesce: return a new event with all changes and refs from both this and the given set. When `refs` is omitted,
|
|
148
158
|
* every ref kind in `changes` counts as unnamed. A kind in `changes` is no longer {@link announced}. `config` stays
|
|
149
|
-
* {@link configConfined}, to the branches of both, only when each side that changed it was confined
|
|
159
|
+
* {@link configConfined}, to the branches of both, only when each side that changed it was confined, and
|
|
160
|
+
* `worktreeHead` keeps {@link movedWorktrees}, those of both, only when each side that changed it named them.
|
|
150
161
|
*/
|
|
151
|
-
with(changes, refs) {
|
|
162
|
+
with(changes, refs, movedWorktrees) {
|
|
152
163
|
const names = [...this._refs];
|
|
153
164
|
const unnamed = [...this._unnamedRefKinds];
|
|
154
165
|
if (refs == null) unnamed.push(...filter(changes, isRefChangeKind));
|
|
@@ -160,11 +171,15 @@ var WatcherRepoChangeEvent = class WatcherRepoChangeEvent {
|
|
|
160
171
|
const own = this._changes.has("config") ? this._configBranches : /* @__PURE__ */ new Set();
|
|
161
172
|
const other = changes.includes("config") ? refs?.configBranches : [];
|
|
162
173
|
if (own != null && other != null) configBranches = /* @__PURE__ */ new Set([...own, ...other]);
|
|
174
|
+
let moved;
|
|
175
|
+
const ownMoved = this._changes.has("worktreeHead") ? this._movedWorktrees : /* @__PURE__ */ new Set();
|
|
176
|
+
const otherMoved = changes.includes("worktreeHead") ? movedWorktrees : [];
|
|
177
|
+
if (ownMoved != null && otherMoved != null) moved = /* @__PURE__ */ new Set([...ownMoved, ...otherMoved]);
|
|
163
178
|
return new WatcherRepoChangeEvent(this.repoPath, [...this._changes, ...changes], {
|
|
164
179
|
names,
|
|
165
180
|
unnamed,
|
|
166
181
|
configBranches
|
|
167
|
-
}, filter(this._announced, (c) => !changes.includes(c)));
|
|
182
|
+
}, filter(this._announced, (c) => !changes.includes(c)), moved);
|
|
168
183
|
}
|
|
169
184
|
};
|
|
170
185
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changeEvent.js","names":[],"sources":["../../../../git/src/watching/changeEvent.ts"],"sourcesContent":["import { filter, some } from '@gitlens/utils/iterable.js';\nimport type { RepositoryChange } from '../models/repository.js';\n\n/** The {@link RepositoryChange} kinds that describe ref movement, which an event can attribute to named refs */\nexport type RefChangeKind = 'heads' | 'remotes' | 'tags' | 'stash';\n\nexport interface WatcherRefChanges {\n\t/** Full ref names whose files changed (`refs/heads/main`), plus per-worktree pseudo-refs (`HEAD`, `ORIG_HEAD`). A name may be a ref directory and then covers every ref beneath it. */\n\treadonly names?: Iterable<string>;\n\t/** Ref kinds that changed without a name (packed-refs rewrite, a ref namespace directory like `refs/remotes`, shallow/replace, an injected change): any ref of that kind may have moved. */\n\treadonly unnamed?: Iterable<RefChangeKind>;\n\t/**\n\t * The local branches (full `refs/heads/` names) whose `branch.<name>` sections are all that every `config` change\n\t * among the changes touched in `.git/config`. Omitted when any of them may have changed anything else.\n\t */\n\treadonly configBranches?: Iterable<string>;\n}\n\nexport function isRefChangeKind(change: RepositoryChange): change is RefChangeKind {\n\treturn change === 'heads' || change === 'remotes' || change === 'tags' || change === 'stash';\n}\n\n/**\n * The kind of ref a full ref name (or ref directory) belongs to. A pseudo-ref (no `refs/` prefix, e.g. `HEAD`,\n * `ORIG_HEAD`) counts as `heads`; a ref outside the watched namespaces (e.g. `refs/notes/x`) has no kind, and neither\n * has a namespace directory itself (`refs/remotes`), so a change reported for one names no ref: any ref of the kind it\n * holds may have moved.\n */\nexport function getRefChangeKind(ref: string): RefChangeKind | undefined {\n\tif (!ref.startsWith('refs/')) return 'heads';\n\tif (ref.startsWith('refs/heads/')) return 'heads';\n\tif (ref.startsWith('refs/remotes/')) return 'remotes';\n\tif (ref.startsWith('refs/tags/')) return 'tags';\n\tif (ref === 'refs/stash') return 'stash';\n\n\treturn undefined;\n}\n\n/**\n * An event describing changes to a repository, produced by the watching pipeline.\n *\n * Changes are coalesced within a debounce window — a single event may represent\n * multiple filesystem changes. Use {@link changed} to test for specific change types,\n * and {@link mayHaveChangedRef} to test whether a specific ref may have moved.\n */\nexport class WatcherRepoChangeEvent {\n\tprotected readonly _changes: Set<RepositoryChange>;\n\tprivate readonly _refs: Set<string>;\n\tprivate readonly _unnamedRefKinds: Set<RefChangeKind>;\n\tprivate readonly _announced: Set<RepositoryChange>;\n\tprivate readonly _configBranches: Set<string> | undefined;\n\n\tconstructor(\n\t\t/** The repository path this event is for */\n\t\tpublic readonly repoPath: string,\n\t\tchanges: RepositoryChange[],\n\t\t/** Which refs changed; when omitted, every ref kind in `changes` is unnamed (any ref of that kind may have moved) */\n\t\trefs?: WatcherRefChanges,\n\t\t/** The kinds of `changes` that come only from core's own announced writes (see {@link announced}) */\n\t\tannounced?: Iterable<RepositoryChange>,\n\t) {\n\t\tthis._changes = new Set(changes);\n\t\tif (refs == null) {\n\t\t\tthis._refs = new Set();\n\t\t\tthis._unnamedRefKinds = new Set(filter(changes, isRefChangeKind));\n\t\t} else {\n\t\t\tthis._refs = new Set(refs.names);\n\t\t\tthis._unnamedRefKinds = new Set(refs.unnamed);\n\t\t}\n\t\tthis._configBranches =\n\t\t\trefs?.configBranches != null && this._changes.has('config') ? new Set(refs.configBranches) : undefined;\n\t\tthis._announced = announced != null ? new Set(filter(announced, c => this._changes.has(c))) : new Set();\n\t}\n\n\tget changes(): ReadonlySet<RepositoryChange> {\n\t\treturn this._changes;\n\t}\n\n\t/**\n\t * The kinds in {@link changes} that come only from core's own writes, which core already announced through\n\t * `hooks.repository.onChanged` after evicting their caches. A host that handled that announcement can skip them;\n\t * a kind the watcher or an injected change also reported is not among them.\n\t */\n\tget announced(): ReadonlySet<RepositoryChange> {\n\t\treturn this._announced;\n\t}\n\n\t/** The kinds in {@link changes} that aren't {@link announced}: what a cache that core already evicted for its write still has to clear */\n\tgetUnannouncedChanges(): RepositoryChange[] {\n\t\treturn this._announced.size ? [...filter(this._changes, c => !this._announced.has(c))] : [...this._changes];\n\t}\n\n\t/** Full ref names (or ref directories, or pseudo-refs) known to have changed. See {@link WatcherRefChanges.names}. */\n\tget refs(): ReadonlySet<string> {\n\t\treturn this._refs;\n\t}\n\n\t/** Ref kinds that changed without a name — any ref of these kinds may have moved */\n\tget unnamedRefKinds(): ReadonlySet<RefChangeKind> {\n\t\treturn this._unnamedRefKinds;\n\t}\n\n\t/**\n\t * The local branches (full `refs/heads/` names) whose `branch.<name>` sections are the only part of `.git/config`\n\t * that changed; `undefined` when `config` didn't change, or any config change may be elsewhere. Independent of\n\t * {@link refs}: an outside edit to a branch's tracking moves no ref.\n\t */\n\tget configBranches(): ReadonlySet<string> | undefined {\n\t\treturn this._configBranches;\n\t}\n\n\t/** Whether `config` changed only in the sections of {@link configBranches} */\n\tget configConfined(): boolean {\n\t\treturn this._configBranches != null;\n\t}\n\n\t/**\n\t * Test whether `config` may have changed in a way that concerns a subscriber following `relevantRefs`.\n\t *\n\t * A branch's config section matters only to a checkout on that branch or one whose upstream or base is that branch,\n\t * and those follow `refs/heads/<name>` (or `HEAD`, which may be on any branch). So a {@link configConfined} change\n\t * concerns `relevantRefs` only when one of them is `HEAD` or one of {@link configBranches}; any other config change\n\t * concerns everyone.\n\t */\n\tmayHaveChangedConfig(relevantRefs: Iterable<string>): boolean {\n\t\tif (!this._changes.has('config')) return false;\n\t\tif (this._configBranches == null) return true;\n\n\t\tfor (const ref of relevantRefs) {\n\t\t\tif (ref === 'HEAD' || this._configBranches.has(ref)) return true;\n\t\t}\n\t\treturn false;\n\t}\n\n\ttoString(changesOnly: boolean = false): string {\n\t\tconst changeList = [...this._changes].join(', ');\n\t\tconst refCount = this._refs.size;\n\t\tif (changesOnly) return refCount ? `changes=${changeList}, refs=${refCount}` : `changes=${changeList}`;\n\n\t\treturn refCount\n\t\t\t? `{ repoPath: ${this.repoPath}, changes: ${changeList}, refs: ${refCount} }`\n\t\t\t: `{ repoPath: ${this.repoPath}, changes: ${changeList} }`;\n\t}\n\n\t/**\n\t * Test whether the given ref may have moved in this event.\n\t *\n\t * @param ref - A full ref name (`refs/heads/main`) or a pseudo-ref (`HEAD`).\n\t * @returns `false` when the ref's kind didn't change (or the ref is outside the watched kinds); `true` when its kind\n\t * changed without a name, or when the ref itself or a ref directory above it changed. `HEAD` is usually a symref\n\t * to the checked-out branch, so it may have moved whenever any `heads` ref did.\n\t */\n\tmayHaveChangedRef(ref: string): boolean {\n\t\tconst kind = getRefChangeKind(ref);\n\t\tif (kind == null || !this._changes.has(kind)) return false;\n\t\tif (this._unnamedRefKinds.has(kind) || ref === 'HEAD') return true;\n\n\t\treturn findCoveringRefName(this._refs, ref) != null;\n\t}\n\n\t/**\n\t * Test whether any of the specified change types are present in the event.\n\t *\n\t * @param affected - Change types to test for.\n\t * @returns `true` if any of the specified changes are present.\n\t */\n\tchanged(...affected: RepositoryChange[]): boolean {\n\t\treturn some(this._changes, c => affected.includes(c));\n\t}\n\n\t/**\n\t * Test whether the event contains ONLY the specified change types.\n\t *\n\t * `pausedOp` is treated as a union of `cherryPick`, `merge`, `rebase`,\n\t * and `revert` for convenience.\n\t *\n\t * @param affected - Change types to test for.\n\t * @returns `true` if the event contains only the specified changes.\n\t */\n\tchangedExclusive(...affected: RepositoryChange[]): boolean {\n\t\tlet changes = this._changes;\n\n\t\t// When checking for specific paused operation types, also accept the union type\n\t\tif (\n\t\t\taffected.includes('cherryPick') ||\n\t\t\taffected.includes('merge') ||\n\t\t\taffected.includes('rebase') ||\n\t\t\taffected.includes('revert')\n\t\t) {\n\t\t\tif (!affected.includes('pausedOp')) {\n\t\t\t\taffected = [...affected, 'pausedOp'];\n\t\t\t}\n\t\t} else if (affected.includes('pausedOp')) {\n\t\t\t// When checking for the union type exclusively, ignore specific subtypes\n\t\t\tchanges = new Set(changes);\n\t\t\tchanges.delete('cherryPick');\n\t\t\tchanges.delete('merge');\n\t\t\tchanges.delete('rebase');\n\t\t\tchanges.delete('revert');\n\t\t}\n\n\t\tconst intersection = [...filter(changes, c => affected.includes(c))];\n\t\treturn intersection.length === changes.size;\n\t}\n\n\t/**\n\t * Coalesce: return a new event with all changes and refs from both this and the given set. When `refs` is omitted,\n\t * every ref kind in `changes` counts as unnamed. A kind in `changes` is no longer {@link announced}. `config` stays\n\t * {@link configConfined}, to the branches of both, only when each side that changed it was confined.\n\t */\n\twith(changes: RepositoryChange[], refs?: WatcherRefChanges): WatcherRepoChangeEvent {\n\t\tconst names = [...this._refs];\n\t\tconst unnamed = [...this._unnamedRefKinds];\n\t\tif (refs == null) {\n\t\t\tunnamed.push(...filter(changes, isRefChangeKind));\n\t\t} else {\n\t\t\tif (refs.names != null) {\n\t\t\t\tnames.push(...refs.names);\n\t\t\t}\n\t\t\tif (refs.unnamed != null) {\n\t\t\t\tunnamed.push(...refs.unnamed);\n\t\t\t}\n\t\t}\n\n\t\tlet configBranches: Set<string> | undefined;\n\t\tconst own = this._changes.has('config') ? this._configBranches : new Set<string>();\n\t\tconst other = changes.includes('config') ? refs?.configBranches : [];\n\t\tif (own != null && other != null) {\n\t\t\tconfigBranches = new Set([...own, ...other]);\n\t\t}\n\n\t\treturn new WatcherRepoChangeEvent(\n\t\t\tthis.repoPath,\n\t\t\t[...this._changes, ...changes],\n\t\t\t{ names: names, unnamed: unnamed, configBranches: configBranches },\n\t\t\tfilter(this._announced, c => !changes.includes(c)),\n\t\t);\n\t}\n}\n\n/**\n * Returns the name in `names` that covers `ref` — `ref` itself, or a ref directory above it (compared on `/`\n * boundaries, so `refs/heads/fe` doesn't cover `refs/heads/feature`) — or `undefined` if none does.\n */\nexport function findCoveringRefName(names: ReadonlySet<string>, ref: string): string | undefined {\n\tif (names.size === 0) return undefined;\n\tif (names.has(ref)) return ref;\n\n\tlet index = ref.lastIndexOf('/');\n\twhile (index > 0) {\n\t\tconst dir = ref.substring(0, index);\n\t\tif (names.has(dir)) return dir;\n\n\t\tindex = ref.lastIndexOf('/', index - 1);\n\t}\n\treturn undefined;\n}\n\n/**\n * An event describing working tree file changes, produced by the working tree pipeline.\n *\n * Paths have already been filtered through the gitignore filter and noise filter.\n */\nexport interface WorkingTreeChangeEvent {\n\treadonly repoPath: string;\n\t/**\n\t * Absolute paths of changed files or directories (post-gitignore filtering). A directory stands for everything\n\t * beneath it. Partial when {@link incomplete}.\n\t */\n\treadonly paths: ReadonlySet<string>;\n\t/**\n\t * `true` when more paths changed than the accumulator retains, so {@link paths} is a partial set and a\n\t * miss does NOT mean the file is unchanged. Consumers testing membership must treat this as a match.\n\t */\n\treadonly incomplete: boolean;\n}\n"],"mappings":";;AAkBA,SAAgB,gBAAgB,QAAmD;CAClF,OAAO,WAAW,WAAW,WAAW,aAAa,WAAW,UAAU,WAAW;AACtF;;;;;;;AAQA,SAAgB,iBAAiB,KAAwC;CACxE,IAAI,CAAC,IAAI,WAAW,OAAO,GAAG,OAAO;CACrC,IAAI,IAAI,WAAW,aAAa,GAAG,OAAO;CAC1C,IAAI,IAAI,WAAW,eAAe,GAAG,OAAO;CAC5C,IAAI,IAAI,WAAW,YAAY,GAAG,OAAO;CACzC,IAAI,QAAQ,cAAc,OAAO;AAGlC;;;;;;;;AASA,IAAa,yBAAb,MAAa,uBAAuB;CASlB;CARjB;CACA;CACA;CACA;CACA;CAEA,YAEC,UACA,SAEA,MAEA,WACC;EANe,KAAA,WAAA;EAOhB,KAAK,WAAW,IAAI,IAAI,OAAO;EAC/B,IAAI,QAAQ,MAAM;GACjB,KAAK,wBAAQ,IAAI,IAAI;GACrB,KAAK,mBAAmB,IAAI,IAAI,OAAO,SAAS,eAAe,CAAC;EACjE,OAAO;GACN,KAAK,QAAQ,IAAI,IAAI,KAAK,KAAK;GAC/B,KAAK,mBAAmB,IAAI,IAAI,KAAK,OAAO;EAC7C;EACA,KAAK,kBACJ,M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,IAAI,IAAY;EACjF,MAAM,QAAQ,QAAQ,SAAS,QAAQ,IAAI,MAAM,iBAAiB,CAAC;EACnE,IAAI,OAAO,QAAQ,SAAS,MAC3B,iCAAiB,IAAI,IAAI,CAAC,GAAG,KAAK,GAAG,KAAK,CAAC;EAG5C,OAAO,IAAI,uBACV,KAAK,UACL,CAAC,GAAG,KAAK,UAAU,GAAG,OAAO,GAC7B;GAAS;GAAgB;GAAyB;EAAe,GACjE,OAAO,KAAK,aAAY,MAAK,CAAC,QAAQ,SAAS,CAAC,CAAC,CAClD;CACD;AACD;;;;;AAMA,SAAgB,oBAAoB,OAA4B,KAAiC;CAChG,IAAI,MAAM,SAAS,GAAG,OAAO,KAAA;CAC7B,IAAI,MAAM,IAAI,GAAG,GAAG,OAAO;CAE3B,IAAI,QAAQ,IAAI,YAAY,GAAG;CAC/B,OAAO,QAAQ,GAAG;EACjB,MAAM,MAAM,IAAI,UAAU,GAAG,KAAK;EAClC,IAAI,MAAM,IAAI,GAAG,GAAG,OAAO;EAE3B,QAAQ,IAAI,YAAY,KAAK,QAAQ,CAAC;CACvC;AAED"}
|
|
1
|
+
{"version":3,"file":"changeEvent.js","names":[],"sources":["../../../../git/src/watching/changeEvent.ts"],"sourcesContent":["import { filter, some } from '@gitlens/utils/iterable.js';\nimport type { RepositoryChange } from '../models/repository.js';\n\n/** The {@link RepositoryChange} kinds that describe ref movement, which an event can attribute to named refs */\nexport type RefChangeKind = 'heads' | 'remotes' | 'tags' | 'stash';\n\nexport interface WatcherRefChanges {\n\t/** Full ref names whose files changed (`refs/heads/main`), plus per-worktree pseudo-refs (`HEAD`, `ORIG_HEAD`). A name may be a ref directory and then covers every ref beneath it. */\n\treadonly names?: Iterable<string>;\n\t/** Ref kinds that changed without a name (packed-refs rewrite, a ref namespace directory like `refs/remotes`, shallow/replace, an injected change): any ref of that kind may have moved. */\n\treadonly unnamed?: Iterable<RefChangeKind>;\n\t/**\n\t * The local branches (full `refs/heads/` names) whose `branch.<name>` sections are all that every `config` change\n\t * among the changes touched in `.git/config`. Omitted when any of them may have changed anything else.\n\t */\n\treadonly configBranches?: Iterable<string>;\n}\n\nexport function isRefChangeKind(change: RepositoryChange): change is RefChangeKind {\n\treturn change === 'heads' || change === 'remotes' || change === 'tags' || change === 'stash';\n}\n\n/**\n * The kind of ref a full ref name (or ref directory) belongs to. A pseudo-ref (no `refs/` prefix, e.g. `HEAD`,\n * `ORIG_HEAD`) counts as `heads`; a ref outside the watched namespaces (e.g. `refs/notes/x`) has no kind, and neither\n * has a namespace directory itself (`refs/remotes`), so a change reported for one names no ref: any ref of the kind it\n * holds may have moved.\n */\nexport function getRefChangeKind(ref: string): RefChangeKind | undefined {\n\tif (!ref.startsWith('refs/')) return 'heads';\n\tif (ref.startsWith('refs/heads/')) return 'heads';\n\tif (ref.startsWith('refs/remotes/')) return 'remotes';\n\tif (ref.startsWith('refs/tags/')) return 'tags';\n\tif (ref === 'refs/stash') return 'stash';\n\n\treturn undefined;\n}\n\n/**\n * An event describing changes to a repository, produced by the watching pipeline.\n *\n * Changes are coalesced within a debounce window — a single event may represent\n * multiple filesystem changes. Use {@link changed} to test for specific change types,\n * and {@link mayHaveChangedRef} to test whether a specific ref may have moved.\n */\nexport class WatcherRepoChangeEvent {\n\tprotected readonly _changes: Set<RepositoryChange>;\n\tprivate readonly _refs: Set<string>;\n\tprivate readonly _unnamedRefKinds: Set<RefChangeKind>;\n\tprivate readonly _announced: Set<RepositoryChange>;\n\tprivate readonly _configBranches: Set<string> | undefined;\n\tprivate readonly _movedWorktrees: Set<string> | undefined;\n\n\tconstructor(\n\t\t/** The repository path this event is for */\n\t\tpublic readonly repoPath: string,\n\t\tchanges: RepositoryChange[],\n\t\t/** Which refs changed; when omitted, every ref kind in `changes` is unnamed (any ref of that kind may have moved) */\n\t\trefs?: WatcherRefChanges,\n\t\t/** The kinds of `changes` that come only from core's own announced writes (see {@link announced}) */\n\t\tannounced?: Iterable<RepositoryChange>,\n\t\t/** For a `worktreeHead` among `changes`, the worktrees moved outside core's writes (see {@link movedWorktrees}) */\n\t\tmovedWorktrees?: Iterable<string>,\n\t) {\n\t\tthis._changes = new Set(changes);\n\t\tif (refs == null) {\n\t\t\tthis._refs = new Set();\n\t\t\tthis._unnamedRefKinds = new Set(filter(changes, isRefChangeKind));\n\t\t} else {\n\t\t\tthis._refs = new Set(refs.names);\n\t\t\tthis._unnamedRefKinds = new Set(refs.unnamed);\n\t\t}\n\t\tthis._configBranches =\n\t\t\trefs?.configBranches != null && this._changes.has('config') ? new Set(refs.configBranches) : undefined;\n\t\tthis._announced = announced != null ? new Set(filter(announced, c => this._changes.has(c))) : new Set();\n\t\tthis._movedWorktrees =\n\t\t\tmovedWorktrees != null && this._changes.has('worktreeHead') ? new Set(movedWorktrees) : undefined;\n\t}\n\n\tget changes(): ReadonlySet<RepositoryChange> {\n\t\treturn this._changes;\n\t}\n\n\t/**\n\t * The kinds in {@link changes} that come only from core's own writes, which core already announced through\n\t * `hooks.repository.onChanged` after evicting their caches. A host that handled that announcement can skip them;\n\t * a kind the watcher or an injected change also reported is not among them.\n\t */\n\tget announced(): ReadonlySet<RepositoryChange> {\n\t\treturn this._announced;\n\t}\n\n\t/** The kinds in {@link changes} that aren't {@link announced}: what a cache that core already evicted for its write still has to clear */\n\tgetUnannouncedChanges(): RepositoryChange[] {\n\t\treturn this._announced.size ? [...filter(this._changes, c => !this._announced.has(c))] : [...this._changes];\n\t}\n\n\t/** Full ref names (or ref directories, or pseudo-refs) known to have changed. See {@link WatcherRefChanges.names}. */\n\tget refs(): ReadonlySet<string> {\n\t\treturn this._refs;\n\t}\n\n\t/** Ref kinds that changed without a name — any ref of these kinds may have moved */\n\tget unnamedRefKinds(): ReadonlySet<RefChangeKind> {\n\t\treturn this._unnamedRefKinds;\n\t}\n\n\t/**\n\t * The local branches (full `refs/heads/` names) whose `branch.<name>` sections are the only part of `.git/config`\n\t * that changed; `undefined` when `config` didn't change, or any config change may be elsewhere. Independent of\n\t * {@link refs}: an outside edit to a branch's tracking moves no ref.\n\t */\n\tget configBranches(): ReadonlySet<string> | undefined {\n\t\treturn this._configBranches;\n\t}\n\n\t/**\n\t * The admin ids (the `<id>` of `.git/worktrees/<id>`) of the linked worktrees whose HEAD moved other than by core's\n\t * announced writes, which are all that an unannounced `worktreeHead` reports; `undefined` when `worktreeHead` didn't\n\t * change, or any linked worktree's HEAD may have moved.\n\t */\n\tget movedWorktrees(): ReadonlySet<string> | undefined {\n\t\treturn this._movedWorktrees;\n\t}\n\n\t/** Whether `config` changed only in the sections of {@link configBranches} */\n\tget configConfined(): boolean {\n\t\treturn this._configBranches != null;\n\t}\n\n\t/**\n\t * Test whether `config` may have changed in a way that concerns a subscriber following `relevantRefs`.\n\t *\n\t * A branch's config section matters only to a checkout on that branch or one whose upstream or base is that branch,\n\t * and those follow `refs/heads/<name>` (or `HEAD`, which may be on any branch). So a {@link configConfined} change\n\t * concerns `relevantRefs` only when one of them is `HEAD` or one of {@link configBranches}; any other config change\n\t * concerns everyone.\n\t */\n\tmayHaveChangedConfig(relevantRefs: Iterable<string>): boolean {\n\t\tif (!this._changes.has('config')) return false;\n\t\tif (this._configBranches == null) return true;\n\n\t\tfor (const ref of relevantRefs) {\n\t\t\tif (ref === 'HEAD' || this._configBranches.has(ref)) return true;\n\t\t}\n\t\treturn false;\n\t}\n\n\ttoString(changesOnly: boolean = false): string {\n\t\tconst changeList = [...this._changes].join(', ');\n\t\tconst refCount = this._refs.size;\n\t\tif (changesOnly) return refCount ? `changes=${changeList}, refs=${refCount}` : `changes=${changeList}`;\n\n\t\treturn refCount\n\t\t\t? `{ repoPath: ${this.repoPath}, changes: ${changeList}, refs: ${refCount} }`\n\t\t\t: `{ repoPath: ${this.repoPath}, changes: ${changeList} }`;\n\t}\n\n\t/**\n\t * Test whether the given ref may have moved in this event.\n\t *\n\t * @param ref - A full ref name (`refs/heads/main`) or a pseudo-ref (`HEAD`).\n\t * @returns `false` when the ref's kind didn't change (or the ref is outside the watched kinds); `true` when its kind\n\t * changed without a name, or when the ref itself or a ref directory above it changed. `HEAD` is usually a symref\n\t * to the checked-out branch, so it may have moved whenever any `heads` ref did.\n\t */\n\tmayHaveChangedRef(ref: string): boolean {\n\t\tconst kind = getRefChangeKind(ref);\n\t\tif (kind == null || !this._changes.has(kind)) return false;\n\t\tif (this._unnamedRefKinds.has(kind) || ref === 'HEAD') return true;\n\n\t\treturn findCoveringRefName(this._refs, ref) != null;\n\t}\n\n\t/**\n\t * Test whether any of the specified change types are present in the event.\n\t *\n\t * @param affected - Change types to test for.\n\t * @returns `true` if any of the specified changes are present.\n\t */\n\tchanged(...affected: RepositoryChange[]): boolean {\n\t\treturn some(this._changes, c => affected.includes(c));\n\t}\n\n\t/**\n\t * Test whether the event contains ONLY the specified change types.\n\t *\n\t * `pausedOp` is treated as a union of `cherryPick`, `merge`, `rebase`,\n\t * and `revert` for convenience.\n\t *\n\t * @param affected - Change types to test for.\n\t * @returns `true` if the event contains only the specified changes.\n\t */\n\tchangedExclusive(...affected: RepositoryChange[]): boolean {\n\t\tlet changes = this._changes;\n\n\t\t// When checking for specific paused operation types, also accept the union type\n\t\tif (\n\t\t\taffected.includes('cherryPick') ||\n\t\t\taffected.includes('merge') ||\n\t\t\taffected.includes('rebase') ||\n\t\t\taffected.includes('revert')\n\t\t) {\n\t\t\tif (!affected.includes('pausedOp')) {\n\t\t\t\taffected = [...affected, 'pausedOp'];\n\t\t\t}\n\t\t} else if (affected.includes('pausedOp')) {\n\t\t\t// When checking for the union type exclusively, ignore specific subtypes\n\t\t\tchanges = new Set(changes);\n\t\t\tchanges.delete('cherryPick');\n\t\t\tchanges.delete('merge');\n\t\t\tchanges.delete('rebase');\n\t\t\tchanges.delete('revert');\n\t\t}\n\n\t\tconst intersection = [...filter(changes, c => affected.includes(c))];\n\t\treturn intersection.length === changes.size;\n\t}\n\n\t/**\n\t * Coalesce: return a new event with all changes and refs from both this and the given set. When `refs` is omitted,\n\t * every ref kind in `changes` counts as unnamed. A kind in `changes` is no longer {@link announced}. `config` stays\n\t * {@link configConfined}, to the branches of both, only when each side that changed it was confined, and\n\t * `worktreeHead` keeps {@link movedWorktrees}, those of both, only when each side that changed it named them.\n\t */\n\twith(\n\t\tchanges: RepositoryChange[],\n\t\trefs?: WatcherRefChanges,\n\t\tmovedWorktrees?: Iterable<string>,\n\t): WatcherRepoChangeEvent {\n\t\tconst names = [...this._refs];\n\t\tconst unnamed = [...this._unnamedRefKinds];\n\t\tif (refs == null) {\n\t\t\tunnamed.push(...filter(changes, isRefChangeKind));\n\t\t} else {\n\t\t\tif (refs.names != null) {\n\t\t\t\tnames.push(...refs.names);\n\t\t\t}\n\t\t\tif (refs.unnamed != null) {\n\t\t\t\tunnamed.push(...refs.unnamed);\n\t\t\t}\n\t\t}\n\n\t\tlet configBranches: Set<string> | undefined;\n\t\tconst own = this._changes.has('config') ? this._configBranches : new Set<string>();\n\t\tconst other = changes.includes('config') ? refs?.configBranches : [];\n\t\tif (own != null && other != null) {\n\t\t\tconfigBranches = new Set([...own, ...other]);\n\t\t}\n\n\t\tlet moved: Set<string> | undefined;\n\t\tconst ownMoved = this._changes.has('worktreeHead') ? this._movedWorktrees : new Set<string>();\n\t\tconst otherMoved = changes.includes('worktreeHead') ? movedWorktrees : [];\n\t\tif (ownMoved != null && otherMoved != null) {\n\t\t\tmoved = new Set([...ownMoved, ...otherMoved]);\n\t\t}\n\n\t\treturn new WatcherRepoChangeEvent(\n\t\t\tthis.repoPath,\n\t\t\t[...this._changes, ...changes],\n\t\t\t{ names: names, unnamed: unnamed, configBranches: configBranches },\n\t\t\tfilter(this._announced, c => !changes.includes(c)),\n\t\t\tmoved,\n\t\t);\n\t}\n}\n\n/**\n * Returns the name in `names` that covers `ref` — `ref` itself, or a ref directory above it (compared on `/`\n * boundaries, so `refs/heads/fe` doesn't cover `refs/heads/feature`) — or `undefined` if none does.\n */\nexport function findCoveringRefName(names: ReadonlySet<string>, ref: string): string | undefined {\n\tif (names.size === 0) return undefined;\n\tif (names.has(ref)) return ref;\n\n\tlet index = ref.lastIndexOf('/');\n\twhile (index > 0) {\n\t\tconst dir = ref.substring(0, index);\n\t\tif (names.has(dir)) return dir;\n\n\t\tindex = ref.lastIndexOf('/', index - 1);\n\t}\n\treturn undefined;\n}\n\n/**\n * An event describing working tree file changes, produced by the working tree pipeline.\n *\n * Paths have already been filtered through the gitignore filter and noise filter.\n */\nexport interface WorkingTreeChangeEvent {\n\treadonly repoPath: string;\n\t/**\n\t * Absolute paths of changed files or directories (post-gitignore filtering). A directory stands for everything\n\t * beneath it. Partial when {@link incomplete}.\n\t */\n\treadonly paths: ReadonlySet<string>;\n\t/**\n\t * `true` when more paths changed than the accumulator retains, so {@link paths} is a partial set and a\n\t * miss does NOT mean the file is unchanged. Consumers testing membership must treat this as a match.\n\t */\n\treadonly incomplete: boolean;\n}\n"],"mappings":";;AAkBA,SAAgB,gBAAgB,QAAmD;CAClF,OAAO,WAAW,WAAW,WAAW,aAAa,WAAW,UAAU,WAAW;AACtF;;;;;;;AAQA,SAAgB,iBAAiB,KAAwC;CACxE,IAAI,CAAC,IAAI,WAAW,OAAO,GAAG,OAAO;CACrC,IAAI,IAAI,WAAW,aAAa,GAAG,OAAO;CAC1C,IAAI,IAAI,WAAW,eAAe,GAAG,OAAO;CAC5C,IAAI,IAAI,WAAW,YAAY,GAAG,OAAO;CACzC,IAAI,QAAQ,cAAc,OAAO;AAGlC;;;;;;;;AASA,IAAa,yBAAb,MAAa,uBAAuB;CAUlB;CATjB;CACA;CACA;CACA;CACA;CACA;CAEA,YAEC,UACA,SAEA,MAEA,WAEA,gBACC;EARe,KAAA,WAAA;EAShB,KAAK,WAAW,IAAI,IAAI,OAAO;EAC/B,IAAI,QAAQ,MAAM;GACjB,KAAK,wBAAQ,IAAI,IAAI;GACrB,KAAK,mBAAmB,IAAI,IAAI,OAAO,SAAS,eAAe,CAAC;EACjE,OAAO;GACN,KAAK,QAAQ,IAAI,IAAI,KAAK,KAAK;GAC/B,KAAK,mBAAmB,IAAI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,KAAK,SAAS,MACjB,MAAM,KAAK,GAAG,KAAK,KAAK;GAEzB,IAAI,KAAK,WAAW,MACnB,QAAQ,KAAK,GAAG,KAAK,OAAO;EAE9B;EAEA,IAAI;EACJ,MAAM,MAAM,KAAK,SAAS,IAAI,QAAQ,IAAI,KAAK,kCAAkB,IAAI,IAAY;EACjF,MAAM,QAAQ,QAAQ,SAAS,QAAQ,IAAI,MAAM,iBAAiB,CAAC;EACnE,IAAI,OAAO,QAAQ,SAAS,MAC3B,iCAAiB,IAAI,IAAI,CAAC,GAAG,KAAK,GAAG,KAAK,CAAC;EAG5C,IAAI;EACJ,MAAM,WAAW,KAAK,SAAS,IAAI,cAAc,IAAI,KAAK,kCAAkB,IAAI,IAAY;EAC5F,MAAM,aAAa,QAAQ,SAAS,cAAc,IAAI,iBAAiB,CAAC;EACxE,IAAI,YAAY,QAAQ,cAAc,MACrC,wBAAQ,IAAI,IAAI,CAAC,GAAG,UAAU,GAAG,UAAU,CAAC;EAG7C,OAAO,IAAI,uBACV,KAAK,UACL,CAAC,GAAG,KAAK,UAAU,GAAG,OAAO,GAC7B;GAAS;GAAgB;GAAyB;EAAe,GACjE,OAAO,KAAK,aAAY,MAAK,CAAC,QAAQ,SAAS,CAAC,CAAC,GACjD,KACD;CACD;AACD;;;;;AAMA,SAAgB,oBAAoB,OAA4B,KAAiC;CAChG,IAAI,MAAM,SAAS,GAAG,OAAO,KAAA;CAC7B,IAAI,MAAM,IAAI,GAAG,GAAG,OAAO;CAE3B,IAAI,QAAQ,IAAI,YAAY,GAAG;CAC/B,OAAO,QAAQ,GAAG;EACjB,MAAM,MAAM,IAAI,UAAU,GAAG,KAAK;EAClC,IAAI,MAAM,IAAI,GAAG,GAAG,OAAO;EAE3B,QAAQ,IAAI,YAAY,KAAK,QAAQ,CAAC;CACvC;AAED"}
|
|
@@ -14,9 +14,11 @@ export interface WatchGroupHooks {
|
|
|
14
14
|
* is unknown. `overflow` marks the every-kind rescan of a watcher that dropped events, which no single write can
|
|
15
15
|
* account for. `configBranches`, with a `config` change, are the local branches (full ref names) whose
|
|
16
16
|
* `branch.<name>` sections are all that changed in the shared `.git/config`; without it, the config change may be
|
|
17
|
-
* anywhere.
|
|
17
|
+
* anywhere. `movedWorktree`, with a `worktreeHead` change, is the admin id (the `<id>` of `worktrees/<id>`) of the
|
|
18
|
+
* linked worktree whose `HEAD` file changed, or whose admin entry was created or removed; without it, any linked
|
|
19
|
+
* worktree's HEAD may have moved.
|
|
18
20
|
*/
|
|
19
|
-
readonly onRepoChanged: (repoPath: string, changes: RepositoryChange[], ref?: string | false, overflow?: boolean, configBranches?: ReadonlySet<string
|
|
21
|
+
readonly onRepoChanged: (repoPath: string, changes: RepositoryChange[], ref?: string | false, overflow?: boolean, configBranches?: ReadonlySet<string>, movedWorktree?: string) => void;
|
|
20
22
|
readonly onFetchHeadChanged?: (repoPath: string) => void;
|
|
21
23
|
readonly onIgnoresChanged?: (repoPath: string) => void;
|
|
22
24
|
/** The refs whose loose files a poll stats for this session, read at each poll */
|