@gitkraken/core-gitlens 0.62.0 → 0.64.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 +22 -1
- package/dist/git/cache.d.ts +1 -0
- package/dist/git/cache.js +11 -0
- package/dist/git/cache.js.map +1 -1
- package/dist/git/errors.d.ts +15 -0
- package/dist/git/errors.js +9 -1
- package/dist/git/errors.js.map +1 -1
- package/dist/git/models/pullRequest.d.ts +3 -0
- package/dist/git/models/pullRequest.js.map +1 -1
- package/dist/git/providers/operations.d.ts +4 -3
- package/dist/git/providers/staging.d.ts +16 -8
- package/dist/git/run.types.d.ts +6 -0
- package/dist/git/utils/hiddenRefs.utils.d.ts +15 -0
- package/dist/git/utils/hiddenRefs.utils.js +68 -2
- package/dist/git/utils/hiddenRefs.utils.js.map +1 -1
- package/dist/git/utils/pullRequest.utils.d.ts +3 -6
- package/dist/git/utils/pullRequest.utils.js +6 -7
- package/dist/git/utils/pullRequest.utils.js.map +1 -1
- package/dist/git/watching/gitIgnoreFilter.d.ts +12 -5
- package/dist/git/watching/gitIgnoreFilter.js +26 -32
- package/dist/git/watching/gitIgnoreFilter.js.map +1 -1
- package/dist/git/watching/provider.d.ts +18 -3
- package/dist/git/watching/watchGroup.d.ts +7 -2
- package/dist/git/watching/watchGroup.js +51 -3
- package/dist/git/watching/watchGroup.js.map +1 -1
- package/dist/git/watching/watchService.d.ts +6 -3
- package/dist/git/watching/watchService.js +94 -64
- package/dist/git/watching/watchService.js.map +1 -1
- package/dist/git-cli/cliGitProvider.d.ts +2 -0
- package/dist/git-cli/cliGitProvider.js +85 -24
- package/dist/git-cli/cliGitProvider.js.map +1 -1
- package/dist/git-cli/exec/git.js +4 -4
- package/dist/git-cli/exec/git.js.map +1 -1
- package/dist/git-cli/exec/indexLock.d.ts +7 -5
- package/dist/git-cli/exec/indexLock.js +19 -15
- package/dist/git-cli/exec/indexLock.js.map +1 -1
- package/dist/git-cli/providers/config.d.ts +1 -0
- package/dist/git-cli/providers/config.js +13 -3
- package/dist/git-cli/providers/config.js.map +1 -1
- package/dist/git-cli/providers/staging.d.ts +8 -8
- package/dist/git-cli/providers/staging.js +119 -24
- package/dist/git-cli/providers/staging.js.map +1 -1
- package/dist/plus/git-github/api/config.d.ts +5 -0
- package/dist/plus/git-github/api/config.js.map +1 -1
- package/dist/plus/git-github/api/github.js +24 -4
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/models.d.ts +12 -0
- package/dist/plus/git-github/models.js +8 -3
- package/dist/plus/git-github/models.js.map +1 -1
- package/dist/plus/integrations/context.d.ts +5 -0
- package/dist/plus/integrations/extensionManager.d.ts +6 -0
- package/dist/plus/integrations/extensionManager.js +10 -0
- package/dist/plus/integrations/extensionManager.js.map +1 -0
- package/dist/plus/integrations/index.d.ts +5 -63
- package/dist/plus/integrations/index.js +4 -53
- package/dist/plus/integrations/index.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +14 -2
- package/dist/plus/integrations/integrationService.js +48 -12
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +10 -0
- package/dist/plus/integrations/managerContext.d.ts +69 -0
- package/dist/plus/integrations/managerContext.js +59 -0
- package/dist/plus/integrations/managerContext.js.map +1 -0
- package/dist/plus/integrations/models/gitlabMergeRequestWrites.d.ts +167 -0
- package/dist/plus/integrations/models/gitlabMergeRequestWrites.js +0 -0
- package/dist/plus/integrations/providers/github.js +6 -2
- package/dist/plus/integrations/providers/github.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/gitlab.d.ts +2 -2
- package/dist/plus/integrations/providers/gitlab/gitlab.js +3 -3
- package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/issueWrites.d.ts +4 -13
- package/dist/plus/integrations/providers/gitlab/issueWrites.js +33 -136
- package/dist/plus/integrations/providers/gitlab/issueWrites.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/mergeRequestWrites.d.ts +30 -0
- package/dist/plus/integrations/providers/gitlab/mergeRequestWrites.js +569 -0
- package/dist/plus/integrations/providers/gitlab/mergeRequestWrites.js.map +1 -0
- package/dist/plus/integrations/providers/gitlab/writeErrors.d.ts +12 -0
- package/dist/plus/integrations/providers/gitlab/writeErrors.js +101 -0
- package/dist/plus/integrations/providers/gitlab/writeErrors.js.map +1 -0
- package/dist/plus/integrations/providers/gitlab/writeTransport.d.ts +47 -0
- package/dist/plus/integrations/providers/gitlab/writeTransport.js +135 -0
- package/dist/plus/integrations/providers/gitlab/writeTransport.js.map +1 -0
- package/dist/plus/integrations/providers/gitlab.d.ts +6 -1
- package/dist/plus/integrations/providers/gitlab.js +9 -1
- package/dist/plus/integrations/providers/gitlab.js.map +1 -1
- package/dist/plus/integrations/reads/etag.d.ts +5 -0
- package/dist/plus/integrations/reads/etag.js +2 -0
- package/dist/plus/integrations/reads/etag.js.map +1 -1
- package/dist/plus/integrations/reads/sweeps.js +1 -1
- package/dist/utils/env/node/exec.d.ts +2 -0
- package/dist/utils/env/node/exec.js +2 -0
- package/dist/utils/env/node/exec.js.map +1 -1
- package/docs/integrations.md +86 -9
- package/package.json +1 -1
- package/dist/plus/integrations/providers/gitlab/issueWriteErrors.d.ts +0 -11
- package/dist/plus/integrations/providers/gitlab/issueWriteErrors.js +0 -73
- package/dist/plus/integrations/providers/gitlab/issueWriteErrors.js.map +0 -1
|
@@ -6,7 +6,9 @@ import { mixinAsyncDisposable } from "../../utils/disposable.js";
|
|
|
6
6
|
import { toFsPath } from "../../utils/uri.js";
|
|
7
7
|
import { joinPaths } from "../../utils/path.js";
|
|
8
8
|
import __decorate from "../../_virtual/@oxc-project+runtime/helpers/esm/decorate.js";
|
|
9
|
-
import {
|
|
9
|
+
import { StageError } from "../../git/errors.js";
|
|
10
|
+
import { isIndexLockHeldError } from "../exec/indexLock.js";
|
|
11
|
+
import { GitError, maxGitCliLength } from "../exec/git.js";
|
|
10
12
|
import * as l10n from "@vscode/l10n";
|
|
11
13
|
import { promises } from "fs";
|
|
12
14
|
import { tmpdir } from "os";
|
|
@@ -70,61 +72,131 @@ var StagingGitSubProvider = class {
|
|
|
70
72
|
throw ex;
|
|
71
73
|
}
|
|
72
74
|
}
|
|
73
|
-
async stageFile(repoPath, pathOrUri) {
|
|
74
|
-
const
|
|
75
|
+
async stageFile(repoPath, pathOrUri, runOptions) {
|
|
76
|
+
const args = [
|
|
77
|
+
"add",
|
|
78
|
+
"-A",
|
|
79
|
+
"--",
|
|
80
|
+
toFsPath(pathOrUri)
|
|
81
|
+
];
|
|
75
82
|
try {
|
|
76
|
-
await this.git.run({
|
|
83
|
+
await this.git.run({
|
|
84
|
+
cwd: repoPath,
|
|
85
|
+
...runOptions
|
|
86
|
+
}, ...args);
|
|
87
|
+
} catch (ex) {
|
|
88
|
+
throw toStageError(ex, "stage", repoPath, args);
|
|
77
89
|
} finally {
|
|
78
90
|
this.announceIndexChanged(repoPath);
|
|
79
91
|
}
|
|
80
92
|
}
|
|
81
|
-
async stageFiles(repoPath, pathsOrUris, options) {
|
|
93
|
+
async stageFiles(repoPath, pathsOrUris, options, runOptions) {
|
|
82
94
|
const paths = pathsOrUris.map(toFsPath);
|
|
83
95
|
if (!paths.length) return;
|
|
84
96
|
const avgPathLength = countStringLength(paths) / paths.length;
|
|
85
97
|
const batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));
|
|
98
|
+
const env = options?.index != null ? {
|
|
99
|
+
...runOptions?.env,
|
|
100
|
+
...options.index.env
|
|
101
|
+
} : runOptions?.env;
|
|
86
102
|
const batches = chunk(paths, batchSize);
|
|
103
|
+
let args = [];
|
|
87
104
|
try {
|
|
88
|
-
for (const batch of batches)
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
105
|
+
for (const batch of batches) {
|
|
106
|
+
args = [
|
|
107
|
+
"add",
|
|
108
|
+
options?.intentToAdd ? "-N" : "-A",
|
|
109
|
+
"--",
|
|
110
|
+
...batch
|
|
111
|
+
];
|
|
112
|
+
await this.git.run({
|
|
113
|
+
cwd: repoPath,
|
|
114
|
+
...runOptions,
|
|
115
|
+
env
|
|
116
|
+
}, ...args);
|
|
117
|
+
}
|
|
118
|
+
} catch (ex) {
|
|
119
|
+
throw toStageError(ex, "stage", repoPath, args);
|
|
92
120
|
} finally {
|
|
93
121
|
if (options?.index == null) this.announceIndexChanged(repoPath);
|
|
94
122
|
}
|
|
95
123
|
}
|
|
96
|
-
async stageDirectory(repoPath, directoryOrUri) {
|
|
97
|
-
const
|
|
124
|
+
async stageDirectory(repoPath, directoryOrUri, runOptions) {
|
|
125
|
+
const args = [
|
|
126
|
+
"add",
|
|
127
|
+
"-A",
|
|
128
|
+
"--",
|
|
129
|
+
toFsPath(directoryOrUri)
|
|
130
|
+
];
|
|
98
131
|
try {
|
|
99
|
-
await this.git.run({
|
|
132
|
+
await this.git.run({
|
|
133
|
+
cwd: repoPath,
|
|
134
|
+
...runOptions
|
|
135
|
+
}, ...args);
|
|
136
|
+
} catch (ex) {
|
|
137
|
+
throw toStageError(ex, "stage", repoPath, args);
|
|
100
138
|
} finally {
|
|
101
139
|
this.announceIndexChanged(repoPath);
|
|
102
140
|
}
|
|
103
141
|
}
|
|
104
|
-
async unstageFile(repoPath, pathOrUri) {
|
|
105
|
-
const
|
|
142
|
+
async unstageFile(repoPath, pathOrUri, runOptions) {
|
|
143
|
+
const args = [
|
|
144
|
+
"reset",
|
|
145
|
+
"-q",
|
|
146
|
+
"--",
|
|
147
|
+
toFsPath(pathOrUri)
|
|
148
|
+
];
|
|
106
149
|
try {
|
|
107
|
-
await this.git.run({
|
|
150
|
+
await this.git.run({
|
|
151
|
+
cwd: repoPath,
|
|
152
|
+
...runOptions
|
|
153
|
+
}, ...args);
|
|
154
|
+
} catch (ex) {
|
|
155
|
+
throw toStageError(ex, "unstage", repoPath, args);
|
|
108
156
|
} finally {
|
|
109
157
|
this.announceIndexChanged(repoPath);
|
|
110
158
|
}
|
|
111
159
|
}
|
|
112
|
-
async unstageFiles(repoPath, pathsOrUris) {
|
|
160
|
+
async unstageFiles(repoPath, pathsOrUris, runOptions) {
|
|
113
161
|
const paths = pathsOrUris.map(toFsPath);
|
|
114
162
|
if (!paths.length) return;
|
|
115
163
|
const avgPathLength = countStringLength(paths) / paths.length;
|
|
116
164
|
const batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));
|
|
117
165
|
const batches = chunk(paths, batchSize);
|
|
166
|
+
let args = [];
|
|
118
167
|
try {
|
|
119
|
-
for (const batch of batches)
|
|
168
|
+
for (const batch of batches) {
|
|
169
|
+
args = [
|
|
170
|
+
"reset",
|
|
171
|
+
"-q",
|
|
172
|
+
"--",
|
|
173
|
+
...batch
|
|
174
|
+
];
|
|
175
|
+
await this.git.run({
|
|
176
|
+
cwd: repoPath,
|
|
177
|
+
...runOptions
|
|
178
|
+
}, ...args);
|
|
179
|
+
}
|
|
180
|
+
} catch (ex) {
|
|
181
|
+
throw toStageError(ex, "unstage", repoPath, args);
|
|
120
182
|
} finally {
|
|
121
183
|
this.announceIndexChanged(repoPath);
|
|
122
184
|
}
|
|
123
185
|
}
|
|
124
|
-
async unstageDirectory(repoPath, directoryOrUri) {
|
|
125
|
-
const
|
|
186
|
+
async unstageDirectory(repoPath, directoryOrUri, runOptions) {
|
|
187
|
+
const args = [
|
|
188
|
+
"reset",
|
|
189
|
+
"-q",
|
|
190
|
+
"--",
|
|
191
|
+
toFsPath(directoryOrUri)
|
|
192
|
+
];
|
|
126
193
|
try {
|
|
127
|
-
await this.git.run({
|
|
194
|
+
await this.git.run({
|
|
195
|
+
cwd: repoPath,
|
|
196
|
+
...runOptions
|
|
197
|
+
}, ...args);
|
|
198
|
+
} catch (ex) {
|
|
199
|
+
throw toStageError(ex, "unstage", repoPath, args);
|
|
128
200
|
} finally {
|
|
129
201
|
this.announceIndexChanged(repoPath);
|
|
130
202
|
}
|
|
@@ -154,16 +226,28 @@ var StagingGitSubProvider = class {
|
|
|
154
226
|
this.announceIndexChanged(repoPath);
|
|
155
227
|
}
|
|
156
228
|
}
|
|
157
|
-
async stageAll(repoPath) {
|
|
229
|
+
async stageAll(repoPath, runOptions) {
|
|
230
|
+
const args = ["add", "-A"];
|
|
158
231
|
try {
|
|
159
|
-
await this.git.run({
|
|
232
|
+
await this.git.run({
|
|
233
|
+
cwd: repoPath,
|
|
234
|
+
...runOptions
|
|
235
|
+
}, ...args);
|
|
236
|
+
} catch (ex) {
|
|
237
|
+
throw toStageError(ex, "stage", repoPath, args);
|
|
160
238
|
} finally {
|
|
161
239
|
this.announceIndexChanged(repoPath);
|
|
162
240
|
}
|
|
163
241
|
}
|
|
164
|
-
async unstageAll(repoPath) {
|
|
242
|
+
async unstageAll(repoPath, runOptions) {
|
|
243
|
+
const args = ["reset", "-q"];
|
|
165
244
|
try {
|
|
166
|
-
await this.git.run({
|
|
245
|
+
await this.git.run({
|
|
246
|
+
cwd: repoPath,
|
|
247
|
+
...runOptions
|
|
248
|
+
}, ...args);
|
|
249
|
+
} catch (ex) {
|
|
250
|
+
throw toStageError(ex, "unstage", repoPath, args);
|
|
167
251
|
} finally {
|
|
168
252
|
this.announceIndexChanged(repoPath);
|
|
169
253
|
}
|
|
@@ -218,6 +302,17 @@ __decorate([debug()], StagingGitSubProvider.prototype, "removeFiles", null);
|
|
|
218
302
|
__decorate([debug()], StagingGitSubProvider.prototype, "stageAll", null);
|
|
219
303
|
__decorate([debug()], StagingGitSubProvider.prototype, "unstageAll", null);
|
|
220
304
|
__decorate([debug()], StagingGitSubProvider.prototype, "clean", null);
|
|
305
|
+
function toStageError(ex, action, repoPath, args) {
|
|
306
|
+
if (!(ex instanceof GitError) || !isIndexLockHeldError(ex.original)) return ex;
|
|
307
|
+
return new StageError({
|
|
308
|
+
reason: "indexLocked",
|
|
309
|
+
action,
|
|
310
|
+
gitCommand: {
|
|
311
|
+
repoPath,
|
|
312
|
+
args
|
|
313
|
+
}
|
|
314
|
+
}, ex);
|
|
315
|
+
}
|
|
221
316
|
//#endregion
|
|
222
317
|
export { StagingGitSubProvider };
|
|
223
318
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"staging.js","names":["fs"],"sources":["../../../../git-cli/src/providers/staging.ts"],"sourcesContent":["import { promises as fs } from 'fs';\nimport { tmpdir } from 'os';\nimport * as l10n from '@vscode/l10n';\nimport type { Cache } from '@gitlens/git/cache.js';\nimport type { GitServiceContext } from '@gitlens/git/context.js';\nimport type { GitOperationRunOptions } from '@gitlens/git/providers/operations.js';\nimport type { DisposableTemporaryGitIndex, GitStagingSubProvider } from '@gitlens/git/providers/staging.js';\nimport { countStringLength } from '@gitlens/utils/array.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport { mixinAsyncDisposable } from '@gitlens/utils/disposable.js';\nimport { chunk } from '@gitlens/utils/iterable.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { joinPaths } from '@gitlens/utils/path.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\nimport { toFsPath } from '@gitlens/utils/uri.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport type { Git } from '../exec/git.js';\nimport { maxGitCliLength } from '../exec/git.js';\n\nexport class StagingGitSubProvider implements GitStagingSubProvider {\n\tconstructor(\n\t\tprivate readonly context: GitServiceContext,\n\t\tprivate readonly git: Git,\n\t\tprivate readonly cache: Cache,\n\t\tprivate readonly provider: CliGitProviderInternal,\n\t) {}\n\n\t@debug()\n\tasync createTemporaryIndex(\n\t\trepoPath: string,\n\t\tfrom: 'empty' | 'current' | 'ref',\n\t\tref?: string,\n\t): Promise<DisposableTemporaryGitIndex> {\n\t\tconst scope = getScopedLogger();\n\n\t\t// Create a temporary index file\n\t\tconst tempDir = await fs.mkdtemp(joinPaths(tmpdir(), 'gl-'));\n\t\tconst tempIndex = joinPaths(tempDir, 'index');\n\n\t\tasync function dispose() {\n\t\t\t// Delete the temporary index file\n\t\t\ttry {\n\t\t\t\tawait fs.rm(tempDir, { recursive: true });\n\t\t\t} catch {\n\t\t\t\t// ignore cleanup errors\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\t// Tell Git to use our soon to be created index file\n\t\t\tconst env = { GIT_INDEX_FILE: tempIndex };\n\n\t\t\tswitch (from) {\n\t\t\t\tcase 'empty':\n\t\t\t\t\t// Leave the temp index empty\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'current': {\n\t\t\t\t\t// Copy the current index to preserve staged state\n\t\t\t\t\tconst gitDir = await this.provider.config.getGitDir?.(repoPath);\n\t\t\t\t\tif (gitDir == null) throw new Error(l10n.t('Unable to determine git directory for {0}', repoPath));\n\n\t\t\t\t\tconst currentIndex = joinPaths(gitDir.uri.fsPath, 'index');\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait fs.copyFile(currentIndex, tempIndex);\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\t// A repo that has never staged anything has no index file yet; git reads a missing\n\t\t\t\t\t\t// `GIT_INDEX_FILE` as an empty index, which is what 'current' means there. Any other\n\t\t\t\t\t\t// failure is real — don't silently hand back an index claiming everything is deleted.\n\t\t\t\t\t\tif ((ex as NodeJS.ErrnoException)?.code !== 'ENOENT') throw ex;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 'ref': {\n\t\t\t\t\tif (ref == null) throw new Error(l10n.t(\"ref is required when from is 'ref'\"));\n\n\t\t\t\t\t// Create the temp index file from a base ref/sha\n\t\t\t\t\tconst newIndexResult = await this.git.run(\n\t\t\t\t\t\t{ cwd: repoPath, env: env },\n\t\t\t\t\t\t'ls-tree',\n\t\t\t\t\t\t'-z',\n\t\t\t\t\t\t'-r',\n\t\t\t\t\t\t'--full-name',\n\t\t\t\t\t\tref,\n\t\t\t\t\t);\n\n\t\t\t\t\tif (newIndexResult.stdout.trim()) {\n\t\t\t\t\t\t// Write the tree to our temp index\n\t\t\t\t\t\tawait this.git.run(\n\t\t\t\t\t\t\t{ cwd: repoPath, env: env, stdin: newIndexResult.stdout },\n\t\t\t\t\t\t\t'update-index',\n\t\t\t\t\t\t\t'-z',\n\t\t\t\t\t\t\t'--index-info',\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn mixinAsyncDisposable({ path: tempIndex, env: { GIT_INDEX_FILE: tempIndex } }, dispose);\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\n\t\t\tvoid dispose();\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t@debug()\n\tasync stageFile(repoPath: string, pathOrUri: string | Uri): Promise<void> {\n\t\tconst path = toFsPath(pathOrUri);\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, 'add', '-A', '--', path);\n\t\t} finally {\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync stageFiles(\n\t\trepoPath: string,\n\t\tpathsOrUris: (string | Uri)[],\n\t\toptions?: { intentToAdd?: boolean; index?: DisposableTemporaryGitIndex },\n\t): Promise<void> {\n\t\tconst paths = pathsOrUris.map(toFsPath);\n\t\tif (!paths.length) return;\n\n\t\t// Calculate a safe batch size based on average path length\n\t\tconst avgPathLength = countStringLength(paths) / paths.length;\n\t\tconst batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));\n\n\t\t// Process files in batches (will be a single batch if under the limit)\n\t\tconst batches = chunk(paths, batchSize);\n\t\ttry {\n\t\t\tfor (const batch of batches) {\n\t\t\t\tawait this.git.run(\n\t\t\t\t\t{ cwd: repoPath, env: options?.index?.env },\n\t\t\t\t\t'add',\n\t\t\t\t\toptions?.intentToAdd ? '-N' : '-A',\n\t\t\t\t\t'--',\n\t\t\t\t\t...batch,\n\t\t\t\t);\n\t\t\t}\n\t\t} finally {\n\t\t\t// Announced even when a later batch fails, since the earlier ones already changed the index. A\n\t\t\t// temporary index (used for partial-stage previews / diff building) is not the repository's real\n\t\t\t// index — firing repo-change hooks for it would invalidate status caches for a mutation nothing\n\t\t\t// else can observe.\n\t\t\tif (options?.index == null) {\n\t\t\t\tthis.announceIndexChanged(repoPath);\n\t\t\t}\n\t\t}\n\t}\n\n\t@debug()\n\tasync stageDirectory(repoPath: string, directoryOrUri: string | Uri): Promise<void> {\n\t\tconst path = toFsPath(directoryOrUri);\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, 'add', '-A', '--', path);\n\t\t} finally {\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync unstageFile(repoPath: string, pathOrUri: string | Uri): Promise<void> {\n\t\tconst path = toFsPath(pathOrUri);\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, 'reset', '-q', '--', path);\n\t\t} finally {\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync unstageFiles(repoPath: string, pathsOrUris: (string | Uri)[]): Promise<void> {\n\t\tconst paths = pathsOrUris.map(toFsPath);\n\t\tif (!paths.length) return;\n\n\t\t// Calculate a safe batch size based on average path length\n\t\tconst avgPathLength = countStringLength(paths) / paths.length;\n\t\tconst batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));\n\n\t\t// Process files in batches (will be a single batch if under the limit)\n\t\tconst batches = chunk(paths, batchSize);\n\t\ttry {\n\t\t\tfor (const batch of batches) {\n\t\t\t\tawait this.git.run({ cwd: repoPath }, 'reset', '-q', '--', ...batch);\n\t\t\t}\n\t\t} finally {\n\t\t\t// Even when a later batch fails, the earlier ones already changed the index\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync unstageDirectory(repoPath: string, directoryOrUri: string | Uri): Promise<void> {\n\t\tconst path = toFsPath(directoryOrUri);\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, 'reset', '-q', '--', path);\n\t\t} finally {\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync removeFile(repoPath: string, pathOrUri: string | Uri, options?: { force?: boolean }): Promise<void> {\n\t\tconst args = ['rm'];\n\t\tif (options?.force) {\n\t\t\targs.push('-f');\n\t\t}\n\t\targs.push('--', toFsPath(pathOrUri));\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t} finally {\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync removeFiles(repoPath: string, pathsOrUris: (string | Uri)[], options?: { force?: boolean }): Promise<void> {\n\t\tconst paths = pathsOrUris.map(toFsPath);\n\t\tif (!paths.length) return;\n\n\t\tconst args: string[] = ['rm'];\n\t\tif (options?.force) {\n\t\t\targs.push('-f');\n\t\t}\n\t\targs.push('--');\n\n\t\t// Calculate a safe batch size based on average path length\n\t\tconst avgPathLength = countStringLength(paths) / paths.length;\n\t\tconst batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));\n\n\t\t// Process files in batches (will be a single batch if under the limit)\n\t\tconst batches = chunk(paths, batchSize);\n\t\ttry {\n\t\t\tfor (const batch of batches) {\n\t\t\t\tawait this.git.run({ cwd: repoPath }, ...args, ...batch);\n\t\t\t}\n\t\t} finally {\n\t\t\t// Even when a later batch fails, the earlier ones already changed the index\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync stageAll(repoPath: string): Promise<void> {\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, 'add', '-A');\n\t\t} finally {\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync unstageAll(repoPath: string): Promise<void> {\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, 'reset', '-q');\n\t\t} finally {\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync clean(\n\t\trepoPath: string,\n\t\toptions?: {\n\t\t\tpaths?: (string | Uri)[];\n\t\t\tdirectories?: boolean;\n\t\t\tforce?: boolean;\n\t\t\tignored?: boolean;\n\t\t},\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst args = ['clean'];\n\t\tif (options?.force ?? true) {\n\t\t\targs.push('-f');\n\t\t}\n\t\tif (options?.directories) {\n\t\t\targs.push('-d');\n\t\t}\n\t\tif (options?.ignored) {\n\t\t\targs.push('-x');\n\t\t}\n\n\t\tif (options?.paths == null) {\n\t\t\ttry {\n\t\t\t\tawait this.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...args);\n\t\t\t} finally {\n\t\t\t\t// A clean that failed or was cancelled partway may already have removed files\n\t\t\t\tthis.announceIndexChanged(repoPath);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst paths = options.paths.map(toFsPath);\n\t\tif (!paths.length) return;\n\n\t\t// Calculate a safe batch size based on average path length\n\t\tconst avgPathLength = countStringLength(paths) / paths.length;\n\t\tconst batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));\n\n\t\t// Process paths in batches (will be a single batch if under the limit)\n\t\tconst batches = chunk(paths, batchSize);\n\t\ttry {\n\t\t\tfor (const batch of batches) {\n\t\t\t\tawait this.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...args, '--', ...batch);\n\t\t\t}\n\t\t} finally {\n\t\t\t// Even when a later batch fails, the earlier ones already removed files\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t/** What every index or working-tree mutation announces, so cached status is re-read and hosts are told. */\n\tprivate announceIndexChanged(repoPath: string): void {\n\t\t// `diff` and `tracking` too, as a watcher-observed index change clears them: a file's working-vs-index\n\t\t// diff and whether it is tracked both change when it is staged, unstaged or removed\n\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'status', 'diff', 'tracking');\n\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['index']);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAmBA,IAAa,wBAAb,MAA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;EACnC;CACD;;CAGA,qBAA6B,UAAwB;EAGpD,KAAK,QAAQ,OAAO,OAAO,UAAU,UAAU,UAAU,QAAQ,UAAU;EAC3E,KAAK,QAAQ,OAAO,YAAY,YAAY,UAAU,CAAC,OAAO,CAAC;CAChE;AACD;AAvSE,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,wBAAA,IAAA;AAiFN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,aAAA,IAAA;AAUN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,cAAA,IAAA;AAoCN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,kBAAA,IAAA;AAUN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,eAAA,IAAA;AAUN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,gBAAA,IAAA;AAqBN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,oBAAA,IAAA;AAUN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,cAAA,IAAA;AAcN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,eAAA,IAAA;AA2BN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,YAAA,IAAA;AASN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,cAAA,IAAA;AASN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,SAAA,IAAA"}
|
|
1
|
+
{"version":3,"file":"staging.js","names":["fs"],"sources":["../../../../git-cli/src/providers/staging.ts"],"sourcesContent":["import { promises as fs } from 'fs';\nimport { tmpdir } from 'os';\nimport * as l10n from '@vscode/l10n';\nimport type { Cache } from '@gitlens/git/cache.js';\nimport type { GitServiceContext } from '@gitlens/git/context.js';\nimport { StageError } from '@gitlens/git/errors.js';\nimport type { GitOperationRunOptions } from '@gitlens/git/providers/operations.js';\nimport type { DisposableTemporaryGitIndex, GitStagingSubProvider } from '@gitlens/git/providers/staging.js';\nimport { countStringLength } from '@gitlens/utils/array.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport { mixinAsyncDisposable } from '@gitlens/utils/disposable.js';\nimport { chunk } from '@gitlens/utils/iterable.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { joinPaths } from '@gitlens/utils/path.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\nimport { toFsPath } from '@gitlens/utils/uri.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport type { Git } from '../exec/git.js';\nimport { GitError, maxGitCliLength } from '../exec/git.js';\nimport { isIndexLockHeldError } from '../exec/indexLock.js';\n\nexport class StagingGitSubProvider implements GitStagingSubProvider {\n\tconstructor(\n\t\tprivate readonly context: GitServiceContext,\n\t\tprivate readonly git: Git,\n\t\tprivate readonly cache: Cache,\n\t\tprivate readonly provider: CliGitProviderInternal,\n\t) {}\n\n\t@debug()\n\tasync createTemporaryIndex(\n\t\trepoPath: string,\n\t\tfrom: 'empty' | 'current' | 'ref',\n\t\tref?: string,\n\t): Promise<DisposableTemporaryGitIndex> {\n\t\tconst scope = getScopedLogger();\n\n\t\t// Create a temporary index file\n\t\tconst tempDir = await fs.mkdtemp(joinPaths(tmpdir(), 'gl-'));\n\t\tconst tempIndex = joinPaths(tempDir, 'index');\n\n\t\tasync function dispose() {\n\t\t\t// Delete the temporary index file\n\t\t\ttry {\n\t\t\t\tawait fs.rm(tempDir, { recursive: true });\n\t\t\t} catch {\n\t\t\t\t// ignore cleanup errors\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\t// Tell Git to use our soon to be created index file\n\t\t\tconst env = { GIT_INDEX_FILE: tempIndex };\n\n\t\t\tswitch (from) {\n\t\t\t\tcase 'empty':\n\t\t\t\t\t// Leave the temp index empty\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'current': {\n\t\t\t\t\t// Copy the current index to preserve staged state\n\t\t\t\t\tconst gitDir = await this.provider.config.getGitDir?.(repoPath);\n\t\t\t\t\tif (gitDir == null) throw new Error(l10n.t('Unable to determine git directory for {0}', repoPath));\n\n\t\t\t\t\tconst currentIndex = joinPaths(gitDir.uri.fsPath, 'index');\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait fs.copyFile(currentIndex, tempIndex);\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\t// A repo that has never staged anything has no index file yet; git reads a missing\n\t\t\t\t\t\t// `GIT_INDEX_FILE` as an empty index, which is what 'current' means there. Any other\n\t\t\t\t\t\t// failure is real — don't silently hand back an index claiming everything is deleted.\n\t\t\t\t\t\tif ((ex as NodeJS.ErrnoException)?.code !== 'ENOENT') throw ex;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 'ref': {\n\t\t\t\t\tif (ref == null) throw new Error(l10n.t(\"ref is required when from is 'ref'\"));\n\n\t\t\t\t\t// Create the temp index file from a base ref/sha\n\t\t\t\t\tconst newIndexResult = await this.git.run(\n\t\t\t\t\t\t{ cwd: repoPath, env: env },\n\t\t\t\t\t\t'ls-tree',\n\t\t\t\t\t\t'-z',\n\t\t\t\t\t\t'-r',\n\t\t\t\t\t\t'--full-name',\n\t\t\t\t\t\tref,\n\t\t\t\t\t);\n\n\t\t\t\t\tif (newIndexResult.stdout.trim()) {\n\t\t\t\t\t\t// Write the tree to our temp index\n\t\t\t\t\t\tawait this.git.run(\n\t\t\t\t\t\t\t{ cwd: repoPath, env: env, stdin: newIndexResult.stdout },\n\t\t\t\t\t\t\t'update-index',\n\t\t\t\t\t\t\t'-z',\n\t\t\t\t\t\t\t'--index-info',\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn mixinAsyncDisposable({ path: tempIndex, env: { GIT_INDEX_FILE: tempIndex } }, dispose);\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\n\t\t\tvoid dispose();\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t@debug()\n\tasync stageFile(repoPath: string, pathOrUri: string | Uri, runOptions?: GitOperationRunOptions): Promise<void> {\n\t\tconst args = ['add', '-A', '--', toFsPath(pathOrUri)];\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath, ...runOptions }, ...args);\n\t\t} catch (ex) {\n\t\t\tthrow toStageError(ex, 'stage', repoPath, args);\n\t\t} finally {\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync stageFiles(\n\t\trepoPath: string,\n\t\tpathsOrUris: (string | Uri)[],\n\t\toptions?: { intentToAdd?: boolean; index?: DisposableTemporaryGitIndex },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst paths = pathsOrUris.map(toFsPath);\n\t\tif (!paths.length) return;\n\n\t\tconst avgPathLength = countStringLength(paths) / paths.length;\n\t\tconst batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));\n\n\t\tconst env = options?.index != null ? { ...runOptions?.env, ...options.index.env } : runOptions?.env;\n\t\tconst batches = chunk(paths, batchSize);\n\t\tlet args: string[] = [];\n\t\ttry {\n\t\t\tfor (const batch of batches) {\n\t\t\t\targs = ['add', options?.intentToAdd ? '-N' : '-A', '--', ...batch];\n\t\t\t\tawait this.git.run({ cwd: repoPath, ...runOptions, env: env }, ...args);\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tthrow toStageError(ex, 'stage', repoPath, args);\n\t\t} finally {\n\t\t\t// KEEP: announce even if a later batch fails (earlier ones staged), never for a temporary index\n\t\t\tif (options?.index == null) {\n\t\t\t\tthis.announceIndexChanged(repoPath);\n\t\t\t}\n\t\t}\n\t}\n\n\t@debug()\n\tasync stageDirectory(\n\t\trepoPath: string,\n\t\tdirectoryOrUri: string | Uri,\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst args = ['add', '-A', '--', toFsPath(directoryOrUri)];\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath, ...runOptions }, ...args);\n\t\t} catch (ex) {\n\t\t\tthrow toStageError(ex, 'stage', repoPath, args);\n\t\t} finally {\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync unstageFile(repoPath: string, pathOrUri: string | Uri, runOptions?: GitOperationRunOptions): Promise<void> {\n\t\tconst args = ['reset', '-q', '--', toFsPath(pathOrUri)];\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath, ...runOptions }, ...args);\n\t\t} catch (ex) {\n\t\t\tthrow toStageError(ex, 'unstage', repoPath, args);\n\t\t} finally {\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync unstageFiles(\n\t\trepoPath: string,\n\t\tpathsOrUris: (string | Uri)[],\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst paths = pathsOrUris.map(toFsPath);\n\t\tif (!paths.length) return;\n\n\t\tconst avgPathLength = countStringLength(paths) / paths.length;\n\t\tconst batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));\n\n\t\tconst batches = chunk(paths, batchSize);\n\t\tlet args: string[] = [];\n\t\ttry {\n\t\t\tfor (const batch of batches) {\n\t\t\t\targs = ['reset', '-q', '--', ...batch];\n\t\t\t\tawait this.git.run({ cwd: repoPath, ...runOptions }, ...args);\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tthrow toStageError(ex, 'unstage', repoPath, args);\n\t\t} finally {\n\t\t\t// KEEP: announce even when a later batch fails — the earlier ones already changed the index\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync unstageDirectory(\n\t\trepoPath: string,\n\t\tdirectoryOrUri: string | Uri,\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst args = ['reset', '-q', '--', toFsPath(directoryOrUri)];\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath, ...runOptions }, ...args);\n\t\t} catch (ex) {\n\t\t\tthrow toStageError(ex, 'unstage', repoPath, args);\n\t\t} finally {\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync removeFile(repoPath: string, pathOrUri: string | Uri, options?: { force?: boolean }): Promise<void> {\n\t\tconst args = ['rm'];\n\t\tif (options?.force) {\n\t\t\targs.push('-f');\n\t\t}\n\t\targs.push('--', toFsPath(pathOrUri));\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t} finally {\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync removeFiles(repoPath: string, pathsOrUris: (string | Uri)[], options?: { force?: boolean }): Promise<void> {\n\t\tconst paths = pathsOrUris.map(toFsPath);\n\t\tif (!paths.length) return;\n\n\t\tconst args: string[] = ['rm'];\n\t\tif (options?.force) {\n\t\t\targs.push('-f');\n\t\t}\n\t\targs.push('--');\n\n\t\t// Calculate a safe batch size based on average path length\n\t\tconst avgPathLength = countStringLength(paths) / paths.length;\n\t\tconst batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));\n\n\t\t// Process files in batches (will be a single batch if under the limit)\n\t\tconst batches = chunk(paths, batchSize);\n\t\ttry {\n\t\t\tfor (const batch of batches) {\n\t\t\t\tawait this.git.run({ cwd: repoPath }, ...args, ...batch);\n\t\t\t}\n\t\t} finally {\n\t\t\t// Even when a later batch fails, the earlier ones already changed the index\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync stageAll(repoPath: string, runOptions?: GitOperationRunOptions): Promise<void> {\n\t\tconst args = ['add', '-A'];\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath, ...runOptions }, ...args);\n\t\t} catch (ex) {\n\t\t\tthrow toStageError(ex, 'stage', repoPath, args);\n\t\t} finally {\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync unstageAll(repoPath: string, runOptions?: GitOperationRunOptions): Promise<void> {\n\t\tconst args = ['reset', '-q'];\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath, ...runOptions }, ...args);\n\t\t} catch (ex) {\n\t\t\tthrow toStageError(ex, 'unstage', repoPath, args);\n\t\t} finally {\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync clean(\n\t\trepoPath: string,\n\t\toptions?: {\n\t\t\tpaths?: (string | Uri)[];\n\t\t\tdirectories?: boolean;\n\t\t\tforce?: boolean;\n\t\t\tignored?: boolean;\n\t\t},\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst args = ['clean'];\n\t\tif (options?.force ?? true) {\n\t\t\targs.push('-f');\n\t\t}\n\t\tif (options?.directories) {\n\t\t\targs.push('-d');\n\t\t}\n\t\tif (options?.ignored) {\n\t\t\targs.push('-x');\n\t\t}\n\n\t\tif (options?.paths == null) {\n\t\t\ttry {\n\t\t\t\tawait this.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...args);\n\t\t\t} finally {\n\t\t\t\t// A clean that failed or was cancelled partway may already have removed files\n\t\t\t\tthis.announceIndexChanged(repoPath);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst paths = options.paths.map(toFsPath);\n\t\tif (!paths.length) return;\n\n\t\t// Calculate a safe batch size based on average path length\n\t\tconst avgPathLength = countStringLength(paths) / paths.length;\n\t\tconst batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));\n\n\t\t// Process paths in batches (will be a single batch if under the limit)\n\t\tconst batches = chunk(paths, batchSize);\n\t\ttry {\n\t\t\tfor (const batch of batches) {\n\t\t\t\tawait this.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...args, '--', ...batch);\n\t\t\t}\n\t\t} finally {\n\t\t\t// Even when a later batch fails, the earlier ones already removed files\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t/** What every index or working-tree mutation announces, so cached status is re-read and hosts are told. */\n\tprivate announceIndexChanged(repoPath: string): void {\n\t\t// `diff` and `tracking` too, as a watcher-observed index change clears them: a file's working-vs-index\n\t\t// diff and whether it is tracked both change when it is staged, unstaged or removed\n\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'status', 'diff', 'tracking');\n\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['index']);\n\t}\n}\n\nfunction toStageError(ex: unknown, action: 'stage' | 'unstage', repoPath: string, args: readonly string[]): unknown {\n\tif (!(ex instanceof GitError) || !isIndexLockHeldError(ex.original)) return ex;\n\n\treturn new StageError(\n\t\t{ reason: 'indexLocked', action: action, gitCommand: { repoPath: repoPath, args: args } },\n\t\tex,\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,IAAa,wBAAb,MAAoE;CAEjD;CACA;CACA;CACA;CAJlB,YACC,SACA,KACA,OACA,UACC;EAJgB,KAAA,UAAA;EACA,KAAA,MAAA;EACA,KAAA,QAAA;EACA,KAAA,WAAA;CACf;CAEH,MACM,qBACL,UACA,MACA,KACuC;EACvC,MAAM,QAAQ,gBAAgB;EAG9B,MAAM,UAAU,MAAMA,SAAG,QAAQ,UAAU,OAAO,GAAG,KAAK,CAAC;EAC3D,MAAM,YAAY,UAAU,SAAS,OAAO;EAE5C,eAAe,UAAU;GAExB,IAAI;IACH,MAAMA,SAAG,GAAG,SAAS,EAAE,WAAW,KAAK,CAAC;GACzC,QAAQ,CAER;EACD;EAEA,IAAI;GAEH,MAAM,MAAM,EAAE,gBAAgB,UAAU;GAExC,QAAQ,MAAR;IACC,KAAK,SAEJ;IACD,KAAK,WAAW;KAEf,MAAM,SAAS,MAAM,KAAK,SAAS,OAAO,YAAY,QAAQ;KAC9D,IAAI,UAAU,MAAM,MAAM,IAAI,MAAM,KAAK,EAAE,6CAA6C,QAAQ,CAAC;KAEjG,MAAM,eAAe,UAAU,OAAO,IAAI,QAAQ,OAAO;KACzD,I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,UAAkB,MAAkC;CACnH,IAAI,EAAE,cAAc,aAAa,CAAC,qBAAqB,GAAG,QAAQ,GAAG,OAAO;CAE5E,OAAO,IAAI,WACV;EAAE,QAAQ;EAAuB;EAAQ,YAAY;GAAY;GAAgB;EAAK;CAAE,GACxF,EACD;AACD"}
|
|
@@ -70,9 +70,14 @@ export interface GitHubApiConfig {
|
|
|
70
70
|
* request read, and makes a queued pull request's etag change with every queue state change. A read's own
|
|
71
71
|
* `mergeQueue` option, where it takes one, overrides this. Read on every query build, so a change applies from
|
|
72
72
|
* the next read.
|
|
73
|
+
*
|
|
74
|
+
* `stackMergedLayers: true` makes GitHub.com pull request reads, and the etag cheap check, select a stack's merged
|
|
75
|
+
* layers (`PullRequestStackInfo.mergedLayers`). Off (omitted) by default: it costs a GitHub rate-limit point per
|
|
76
|
+
* 100 pull requests read.
|
|
73
77
|
*/
|
|
74
78
|
getPullRequestReadOptions?(): {
|
|
75
79
|
readonly mergeQueue?: boolean;
|
|
80
|
+
readonly stackMergedLayers?: boolean;
|
|
76
81
|
};
|
|
77
82
|
}
|
|
78
83
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","names":[],"sources":["../../../../../plus/git-github/src/api/config.ts"],"sourcesContent":["import type { AuthenticationError } from '@gitlens/git/errors.js';\nimport type { Provider } from '@gitlens/git/models/remoteProvider.js';\n\n/**\n * VS Code-free configuration interface for {@link GitHubApi}.\n *\n * The extension creates an instance by wiring VS Code-specific values\n * (settings, proxy agent, SSL wrapper, UI dialogs) into these callbacks.\n * The package never imports anything from VS Code.\n */\nexport interface GitHubApiConfig {\n\t/** Whether we're running in a web worker (vscode.dev) vs Node.js desktop. */\n\treadonly isWeb: boolean;\n\n\t/** The `fetch` implementation to use for HTTP requests. */\n\treadonly fetch: (url: string, init?: any) => Promise<Response>;\n\n\t/**\n\t * Wraps an async operation so that TLS certificate validation\n\t * is disabled when the provider's `getIgnoreSSLErrors()` returns `'force'`.\n\t */\n\twrapForForcedInsecureSSL<T>(ignoreSSLErrors: boolean | 'force', fn: () => Promise<T>): Promise<T>;\n\n\t/**\n\t * Fires when proxy/SSL configuration changes, so the API can reset\n\t * its HTTP caches (proxy agent, default request instances, etc.).\n\t */\n\tonConfigChanged?(listener: () => void): { dispose(): void };\n\n\t/**\n\t * Called when authentication fails (401/403) and reauthentication might help.\n\t *\n\t * The extension shows a dialog and calls `provider.reauthenticate()` if\n\t * the user confirms. Returns `true` if the user chose to reauthenticate,\n\t * allowing the package to reset caches and fire `onDidReauthenticate`.\n\t */\n\tonAuthenticationFailure?(error: AuthenticationError, provider: Provider | undefined): Promise<boolean>;\n\n\t/**\n\t * Called on server errors (500/502/503) or timeouts.\n\t * The extension decides how to present this (notification, status bar, etc.).\n\t */\n\tonRequestError?(provider: Provider | undefined, message: string): void;\n\n\t/**\n\t * Called for debug-mode error display (only when `Logger.isDebugging`).\n\t * The extension may show an error notification or log it.\n\t */\n\tonDebugError?(message: string): void;\n\n\t// These are passed through config because they come from VS Code settings.\n\t// The code in GitHubApi's searchMyPullRequests has \"Hack\" comments noting\n\t// these should eventually be passed through method options instead.\n\n\t/**\n\t * Returns the Launchpad search query limit (max PRs to fetch).\n\t * Defaults to 100 if not provided.\n\t */\n\tgetLaunchpadQueryLimit?(): number;\n\n\t/**\n\t * Returns repositories to exclude from Launchpad search queries.\n\t * Format: `owner/repo` strings.\n\t */\n\tgetLaunchpadIgnoredRepositories?(): string[];\n\n\t/**\n\t * Returns organizations to include in Launchpad search queries.\n\t * When non-empty, only these orgs are searched.\n\t */\n\tgetLaunchpadIncludedOrganizations?(): string[];\n\n\t/**\n\t * Returns organizations to exclude from Launchpad search queries.\n\t * Only used when `getLaunchpadIncludedOrganizations` returns empty.\n\t */\n\tgetLaunchpadIgnoredOrganizations?(): string[];\n\n\t/**\n\t * Pull request read knobs. `mergeQueue: true` makes GitHub.com pull request reads select merge-queue data (the\n\t * queue entry, whether the base branch requires a queue, and the latest queue removal) and the etag cheap check\n\t * select its queue state. Off (omitted) by default: the selection costs a GitHub rate-limit request per pull\n\t * request read, and makes a queued pull request's etag change with every queue state change. A read's own\n\t * `mergeQueue` option, where it takes one, overrides this. Read on every query build, so a change applies from\n\t * the next read.\n\t */\n\tgetPullRequestReadOptions?(): { readonly mergeQueue?: boolean };\n}\n\n/**\n * The maximum number of results GitHub's search will serve for ONE query, however it is paged. A search whose\n * `issueCount` exceeds this cannot be read in full: the items past the ceiling are UNREACHABLE, not merely\n * unfetched — no budget, no retry and no cursor returns them.\n *\n * It lives in this leaf module rather than beside the search that detects it because the facade's\n * provider-agnostic metadata table reports the same ceiling to consumers, and the two must be one number: a\n * duplicated literal drifts silently, and drift here means quoting a limit the client doesn't enforce. Importing\n * it from `github.ts` would have pulled that module — and its octokit dependencies — eagerly into the graph of\n * one of the most widely imported modules in the integrations package, for the sake of a single integer.\n */\nexport const githubSearchResultLimit = 1000;\n"],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"config.js","names":[],"sources":["../../../../../plus/git-github/src/api/config.ts"],"sourcesContent":["import type { AuthenticationError } from '@gitlens/git/errors.js';\nimport type { Provider } from '@gitlens/git/models/remoteProvider.js';\n\n/**\n * VS Code-free configuration interface for {@link GitHubApi}.\n *\n * The extension creates an instance by wiring VS Code-specific values\n * (settings, proxy agent, SSL wrapper, UI dialogs) into these callbacks.\n * The package never imports anything from VS Code.\n */\nexport interface GitHubApiConfig {\n\t/** Whether we're running in a web worker (vscode.dev) vs Node.js desktop. */\n\treadonly isWeb: boolean;\n\n\t/** The `fetch` implementation to use for HTTP requests. */\n\treadonly fetch: (url: string, init?: any) => Promise<Response>;\n\n\t/**\n\t * Wraps an async operation so that TLS certificate validation\n\t * is disabled when the provider's `getIgnoreSSLErrors()` returns `'force'`.\n\t */\n\twrapForForcedInsecureSSL<T>(ignoreSSLErrors: boolean | 'force', fn: () => Promise<T>): Promise<T>;\n\n\t/**\n\t * Fires when proxy/SSL configuration changes, so the API can reset\n\t * its HTTP caches (proxy agent, default request instances, etc.).\n\t */\n\tonConfigChanged?(listener: () => void): { dispose(): void };\n\n\t/**\n\t * Called when authentication fails (401/403) and reauthentication might help.\n\t *\n\t * The extension shows a dialog and calls `provider.reauthenticate()` if\n\t * the user confirms. Returns `true` if the user chose to reauthenticate,\n\t * allowing the package to reset caches and fire `onDidReauthenticate`.\n\t */\n\tonAuthenticationFailure?(error: AuthenticationError, provider: Provider | undefined): Promise<boolean>;\n\n\t/**\n\t * Called on server errors (500/502/503) or timeouts.\n\t * The extension decides how to present this (notification, status bar, etc.).\n\t */\n\tonRequestError?(provider: Provider | undefined, message: string): void;\n\n\t/**\n\t * Called for debug-mode error display (only when `Logger.isDebugging`).\n\t * The extension may show an error notification or log it.\n\t */\n\tonDebugError?(message: string): void;\n\n\t// These are passed through config because they come from VS Code settings.\n\t// The code in GitHubApi's searchMyPullRequests has \"Hack\" comments noting\n\t// these should eventually be passed through method options instead.\n\n\t/**\n\t * Returns the Launchpad search query limit (max PRs to fetch).\n\t * Defaults to 100 if not provided.\n\t */\n\tgetLaunchpadQueryLimit?(): number;\n\n\t/**\n\t * Returns repositories to exclude from Launchpad search queries.\n\t * Format: `owner/repo` strings.\n\t */\n\tgetLaunchpadIgnoredRepositories?(): string[];\n\n\t/**\n\t * Returns organizations to include in Launchpad search queries.\n\t * When non-empty, only these orgs are searched.\n\t */\n\tgetLaunchpadIncludedOrganizations?(): string[];\n\n\t/**\n\t * Returns organizations to exclude from Launchpad search queries.\n\t * Only used when `getLaunchpadIncludedOrganizations` returns empty.\n\t */\n\tgetLaunchpadIgnoredOrganizations?(): string[];\n\n\t/**\n\t * Pull request read knobs. `mergeQueue: true` makes GitHub.com pull request reads select merge-queue data (the\n\t * queue entry, whether the base branch requires a queue, and the latest queue removal) and the etag cheap check\n\t * select its queue state. Off (omitted) by default: the selection costs a GitHub rate-limit request per pull\n\t * request read, and makes a queued pull request's etag change with every queue state change. A read's own\n\t * `mergeQueue` option, where it takes one, overrides this. Read on every query build, so a change applies from\n\t * the next read.\n\t *\n\t * `stackMergedLayers: true` makes GitHub.com pull request reads, and the etag cheap check, select a stack's merged\n\t * layers (`PullRequestStackInfo.mergedLayers`). Off (omitted) by default: it costs a GitHub rate-limit point per\n\t * 100 pull requests read.\n\t */\n\tgetPullRequestReadOptions?(): { readonly mergeQueue?: boolean; readonly stackMergedLayers?: boolean };\n}\n\n/**\n * The maximum number of results GitHub's search will serve for ONE query, however it is paged. A search whose\n * `issueCount` exceeds this cannot be read in full: the items past the ceiling are UNREACHABLE, not merely\n * unfetched — no budget, no retry and no cursor returns them.\n *\n * It lives in this leaf module rather than beside the search that detects it because the facade's\n * provider-agnostic metadata table reports the same ceiling to consumers, and the two must be one number: a\n * duplicated literal drifts silently, and drift here means quoting a limit the client doesn't enforce. Importing\n * it from `github.ts` would have pulled that module — and its octokit dependencies — eagerly into the graph of\n * one of the most widely imported modules in the integrations package, for the sake of a single integer.\n */\nexport const githubSearchResultLimit = 1000;\n"],"mappings":";;;;;;;;;;;;AAwGA,MAAa,0BAA0B"}
|
|
@@ -160,6 +160,20 @@ stackEntry {
|
|
|
160
160
|
function gqlPullRequestStackFragmentFor(options) {
|
|
161
161
|
return isGitHubDotCom(options) ? gqlPullRequestStackFragment : "";
|
|
162
162
|
}
|
|
163
|
+
const gqlPullRequestStackMergedLayersFragment = `
|
|
164
|
+
stack {
|
|
165
|
+
entries(first: 100) {
|
|
166
|
+
nodes {
|
|
167
|
+
pullRequest {
|
|
168
|
+
merged
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
`;
|
|
174
|
+
function gqlPullRequestStackMergedLayersFragmentFor(options, config) {
|
|
175
|
+
return isGitHubDotCom(options) && config.getPullRequestReadOptions?.()?.stackMergedLayers === true ? gqlPullRequestStackMergedLayersFragment : "";
|
|
176
|
+
}
|
|
163
177
|
/** A `MergeQueueEntry`'s selection, shared by the per-pull-request fragment and the per-branch queue read so both
|
|
164
178
|
* answer the one `GitHubMergeQueueEntry` shape `fromGitHubMergeQueueEntry` maps. */
|
|
165
179
|
const gqlMergeQueueEntryFields = `
|
|
@@ -471,6 +485,7 @@ function gqlCommitAssociatedPullRequests(options, config) {
|
|
|
471
485
|
nodes {
|
|
472
486
|
${gqlPullRequestLiteFragment}
|
|
473
487
|
${gqlPullRequestStackFragmentFor(options)}
|
|
488
|
+
${gqlPullRequestStackMergedLayersFragmentFor(options, config)}
|
|
474
489
|
${gqlPullRequestMergeQueueFragmentFor(options, config)}
|
|
475
490
|
}
|
|
476
491
|
}`;
|
|
@@ -757,6 +772,7 @@ var GitHubApi = class {
|
|
|
757
772
|
pullRequest(number: $number) {
|
|
758
773
|
${gqlPullRequestLiteFragment}
|
|
759
774
|
${gqlPullRequestStackFragmentFor(options)}
|
|
775
|
+
${gqlPullRequestStackMergedLayersFragmentFor(options, this.config)}
|
|
760
776
|
${gqlPullRequestMergeQueueFragmentFor(options, this.config)}
|
|
761
777
|
}
|
|
762
778
|
}
|
|
@@ -791,6 +807,7 @@ var GitHubApi = class {
|
|
|
791
807
|
nodes {
|
|
792
808
|
${gqlPullRequestLiteFragment}
|
|
793
809
|
${gqlPullRequestStackFragmentFor(options)}
|
|
810
|
+
${gqlPullRequestStackMergedLayersFragmentFor(options, this.config)}
|
|
794
811
|
${gqlPullRequestMergeQueueFragmentFor(options, this.config)}
|
|
795
812
|
}
|
|
796
813
|
}
|
|
@@ -2351,6 +2368,7 @@ var GitHubApi = class {
|
|
|
2351
2368
|
...on PullRequest {
|
|
2352
2369
|
${options?.summary ? gqlPullRequestLiteFragment : gqlPullRequestFragment}
|
|
2353
2370
|
${gqlPullRequestStackFragmentFor(options)}
|
|
2371
|
+
${gqlPullRequestStackMergedLayersFragmentFor(options, this.config)}
|
|
2354
2372
|
${gqlPullRequestMergeQueueFragmentFor(options, this.config)}
|
|
2355
2373
|
}
|
|
2356
2374
|
}
|
|
@@ -2678,7 +2696,7 @@ var GitHubApi = class {
|
|
|
2678
2696
|
async getPullRequestsBatch(provider, token, coordinates, options, cancellation) {
|
|
2679
2697
|
const scope = getScopedLogger();
|
|
2680
2698
|
if (coordinates.length === 0) return [];
|
|
2681
|
-
const stackFragment = gqlPullRequestStackFragmentFor(options)
|
|
2699
|
+
const stackFragment = `${gqlPullRequestStackFragmentFor(options)}${gqlPullRequestStackMergedLayersFragmentFor(options, this.config)}`;
|
|
2682
2700
|
const mergeQueueFragment = gqlPullRequestMergeQueueFragmentFor(options, this.config);
|
|
2683
2701
|
const checkRuns = options?.checkRuns === true ? {
|
|
2684
2702
|
kind: "row",
|
|
@@ -2810,6 +2828,7 @@ var GitHubApi = class {
|
|
|
2810
2828
|
if (coordinates.length === 0) return [];
|
|
2811
2829
|
const includeFragments = Array.from(new Set(options?.etagIncludes), (include) => gqlPullRequestEtagIncludeFragments[include]);
|
|
2812
2830
|
const mergeQueueFragment = gqlPullRequestEtagMergeQueueFragmentFor(options, this.config);
|
|
2831
|
+
const stackMergedLayersFragment = gqlPullRequestStackMergedLayersFragmentFor(options, this.config);
|
|
2813
2832
|
const checkRuns = options?.checkRuns === true;
|
|
2814
2833
|
const query = `query getPullRequestsEtagFieldsBatch(
|
|
2815
2834
|
${coordinates.map((_, i) => `$o${i}: String!\n\t\t\t\t$n${i}: String!\n\t\t\t\t$k${i}: Int!`).join("\n ")}
|
|
@@ -2818,6 +2837,7 @@ var GitHubApi = class {
|
|
|
2818
2837
|
pullRequest(number: $k${i}) {
|
|
2819
2838
|
${gqlPullRequestEtagFragment}
|
|
2820
2839
|
${mergeQueueFragment}
|
|
2840
|
+
${stackMergedLayersFragment}
|
|
2821
2841
|
${includeFragments.join("")}${checkRuns ? gqlPullRequestCheckRunsFragment(etagCheckContextsFragment, i) : ""}
|
|
2822
2842
|
}
|
|
2823
2843
|
}`).join("\n ")}
|
|
@@ -2948,7 +2968,7 @@ var GitHubApi = class {
|
|
|
2948
2968
|
async getPullRequestsForBranches(provider, token, queries, options, cancellation) {
|
|
2949
2969
|
const scope = getScopedLogger();
|
|
2950
2970
|
if (queries.length === 0) return [];
|
|
2951
|
-
const stackFragment = gqlPullRequestStackFragmentFor(options)
|
|
2971
|
+
const stackFragment = `${gqlPullRequestStackFragmentFor(options)}${gqlPullRequestStackMergedLayersFragmentFor(options, this.config)}`;
|
|
2952
2972
|
const mergeQueueFragment = gqlPullRequestMergeQueueFragmentFor(options, this.config);
|
|
2953
2973
|
const checkRuns = options.checkRuns === true ? {
|
|
2954
2974
|
kind: "row",
|
|
@@ -3403,7 +3423,7 @@ var GitHubApi = class {
|
|
|
3403
3423
|
const facetBudget = Math.max(1, Math.floor(budget / activeFacets.length));
|
|
3404
3424
|
const requestedPageSize = Math.min(facetBudget, Math.max(1, Math.trunc(options?.pageSize ?? facetBudget)));
|
|
3405
3425
|
const includeVar = (alias) => `include${alias.charAt(0).toUpperCase()}${alias.slice(1)}`;
|
|
3406
|
-
const stackFragment = gqlPullRequestStackFragmentFor(options)
|
|
3426
|
+
const stackFragment = `${gqlPullRequestStackFragmentFor(options)}${gqlPullRequestStackMergedLayersFragmentFor(options, this.config)}`;
|
|
3407
3427
|
const mergeQueueFragment = gqlPullRequestMergeQueueFragmentFor(options, this.config);
|
|
3408
3428
|
const params = facets.flatMap((f) => [
|
|
3409
3429
|
`$${f.alias}Search: String!`,
|
|
@@ -3537,7 +3557,7 @@ var GitHubApi = class {
|
|
|
3537
3557
|
qualifier: toGitHubSearchStateQualifier(include)
|
|
3538
3558
|
}];
|
|
3539
3559
|
try {
|
|
3540
|
-
const stackFragment = gqlPullRequestStackFragmentFor(options)
|
|
3560
|
+
const stackFragment = `${gqlPullRequestStackFragmentFor(options)}${gqlPullRequestStackMergedLayersFragmentFor(options, this.config)}`;
|
|
3541
3561
|
const mergeQueueFragment = gqlPullRequestMergeQueueFragmentFor(options, this.config);
|
|
3542
3562
|
const params = stateSearches.map(({ alias }) => alias === "search" ? "$searchQuery: String!" : `$${alias}SearchQuery: String!`);
|
|
3543
3563
|
const fields = stateSearches.map(({ alias }) => {
|