type-git 0.8.2 → 0.8.3
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/README.md +3 -0
- package/dist/adapters/bun/index.cjs +8 -8
- package/dist/adapters/bun/index.d.cts +2 -2
- package/dist/adapters/bun/index.d.ts +2 -2
- package/dist/adapters/bun/index.js +2 -2
- package/dist/adapters/deno/index.cjs +8 -8
- package/dist/adapters/deno/index.d.cts +2 -2
- package/dist/adapters/deno/index.d.ts +2 -2
- package/dist/adapters/deno/index.js +2 -2
- package/dist/adapters/node/index.cjs +4 -4
- package/dist/adapters/node/index.d.cts +2 -2
- package/dist/adapters/node/index.d.ts +2 -2
- package/dist/adapters/node/index.js +3 -3
- package/dist/{chunk-RR5Q2UP2.js → chunk-HCQGGKTC.js} +43 -12
- package/dist/{chunk-4K65HJ37.cjs → chunk-I77B22ZE.cjs} +7 -7
- package/dist/{chunk-YCSKHC3M.js → chunk-MS6E5USB.js} +1 -1
- package/dist/{chunk-RWKMVYO5.cjs → chunk-QHIS7LHW.cjs} +53 -3
- package/dist/{chunk-SKN5H7RX.cjs → chunk-SNC324NL.cjs} +965 -934
- package/dist/{chunk-SXHFNCJZ.js → chunk-V4ZRQG3O.js} +53 -3
- package/dist/{client.d-C8wHgA_S.d.ts → client.d-ClMefrEh.d.ts} +2 -2
- package/dist/{client.d-DVs3pi2e.d.cts → client.d-Jwli7Qfw.d.cts} +2 -2
- package/dist/{git.d-CJUJ4264.d.cts → git.d-BTNkPofF.d.cts} +53 -3
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/strict/index.cjs +99 -99
- package/dist/strict/index.d.cts +1 -1
- package/dist/strict/index.js +1 -1
- package/docs/adapters.md +40 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -175,6 +175,9 @@ const result = await repo.raw(['rev-parse', 'HEAD']);
|
|
|
175
175
|
|
|
176
176
|
// Send data on stdin instead of putting it in argv
|
|
177
177
|
const { stdout: blobId } = await repo.raw(['hash-object', '-w', '--stdin'], { stdin: 'hello' });
|
|
178
|
+
|
|
179
|
+
// raw() returns a non-zero exit in exitCode; throwOnNonZero throws the typed GitError instead
|
|
180
|
+
const { stdout: head } = await repo.raw(['rev-parse', 'HEAD'], { throwOnNonZero: true });
|
|
178
181
|
```
|
|
179
182
|
|
|
180
183
|
### Audit Mode
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
require('../../chunk-
|
|
8
|
+
var _chunkSNC324NLcjs = require('../../chunk-SNC324NL.cjs');
|
|
9
|
+
require('../../chunk-QHIS7LHW.cjs');
|
|
10
10
|
|
|
11
11
|
// src/adapters/bun/exec.ts
|
|
12
12
|
function resolveChildEnv(env, inheritEnv) {
|
|
@@ -117,7 +117,7 @@ var BunExecAdapter = class {
|
|
|
117
117
|
let stderr = "";
|
|
118
118
|
if (binary) {
|
|
119
119
|
[stdout, stderr] = await Promise.all([
|
|
120
|
-
proc.stdout ?
|
|
120
|
+
proc.stdout ? _chunkSNC324NLcjs.readBytes.call(void 0, proc.stdout) : Promise.resolve(new Uint8Array(0)),
|
|
121
121
|
proc.stderr ? readStream(proc.stderr, _optionalChain([handlers, 'optionalAccess', _4 => _4.onStderr])) : Promise.resolve("")
|
|
122
122
|
]);
|
|
123
123
|
} else if (_optionalChain([handlers, 'optionalAccess', _5 => _5.onStdout]) || _optionalChain([handlers, 'optionalAccess', _6 => _6.onStderr])) {
|
|
@@ -294,7 +294,7 @@ var BunFsAdapter = (_class = class {constructor() { _class.prototype.__init.call
|
|
|
294
294
|
},
|
|
295
295
|
sleep: (ms) => Bun.sleep(ms)
|
|
296
296
|
};
|
|
297
|
-
await
|
|
297
|
+
await _chunkSNC324NLcjs.runTailPolling.call(void 0, { adapter, signal, pollInterval, onLine });
|
|
298
298
|
}
|
|
299
299
|
async deleteFile(filePath) {
|
|
300
300
|
const tempDir = this.tempFileDirs.get(filePath);
|
|
@@ -349,7 +349,7 @@ var BunFsAdapter = (_class = class {constructor() { _class.prototype.__init.call
|
|
|
349
349
|
},
|
|
350
350
|
sleep: (ms) => Bun.sleep(ms)
|
|
351
351
|
};
|
|
352
|
-
return
|
|
352
|
+
return _chunkSNC324NLcjs.createTailPolling.call(void 0, { adapter, signal, pollInterval });
|
|
353
353
|
}
|
|
354
354
|
}, _class);
|
|
355
355
|
|
|
@@ -360,13 +360,13 @@ function createBunAdapters() {
|
|
|
360
360
|
fs: new BunFsAdapter()
|
|
361
361
|
};
|
|
362
362
|
}
|
|
363
|
-
var TypeGit = class _TypeGit extends
|
|
363
|
+
var TypeGit = class _TypeGit extends _chunkSNC324NLcjs.GitClient {
|
|
364
364
|
static async create(options) {
|
|
365
|
-
return new _TypeGit(await
|
|
365
|
+
return new _TypeGit(await _chunkSNC324NLcjs.createGit.call(void 0, { ...options, adapters: createBunAdapters() }));
|
|
366
366
|
}
|
|
367
367
|
constructor(optionsOrGit) {
|
|
368
368
|
super(
|
|
369
|
-
optionsOrGit && "open" in optionsOrGit ? optionsOrGit :
|
|
369
|
+
optionsOrGit && "open" in optionsOrGit ? optionsOrGit : _chunkSNC324NLcjs.createGitSync.call(void 0, { ...optionsOrGit, adapters: createBunAdapters() })
|
|
370
370
|
);
|
|
371
371
|
}
|
|
372
372
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as ExecAdapter, S as SpawnOptions, a as StreamHandler, b as SpawnResult, c as SpawnHandle, F as FsAdapter, T as TailOptions, d as TailHandle, R as RuntimeAdapters, C as CreateGitOptions, G as GitClient } from '../../client.d-
|
|
2
|
-
import { C as Capabilities, G as Git } from '../../git.d-
|
|
1
|
+
import { E as ExecAdapter, S as SpawnOptions, a as StreamHandler, b as SpawnResult, c as SpawnHandle, F as FsAdapter, T as TailOptions, d as TailHandle, R as RuntimeAdapters, C as CreateGitOptions, G as GitClient } from '../../client.d-Jwli7Qfw.cjs';
|
|
2
|
+
import { C as Capabilities, G as Git } from '../../git.d-BTNkPofF.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Bun ExecAdapter implementation
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as ExecAdapter, S as SpawnOptions, a as StreamHandler, b as SpawnResult, c as SpawnHandle, F as FsAdapter, T as TailOptions, d as TailHandle, R as RuntimeAdapters, C as CreateGitOptions, G as GitClient } from '../../client.d-
|
|
2
|
-
import { C as Capabilities, G as Git } from '../../git.d-
|
|
1
|
+
import { E as ExecAdapter, S as SpawnOptions, a as StreamHandler, b as SpawnResult, c as SpawnHandle, F as FsAdapter, T as TailOptions, d as TailHandle, R as RuntimeAdapters, C as CreateGitOptions, G as GitClient } from '../../client.d-ClMefrEh.js';
|
|
2
|
+
import { C as Capabilities, G as Git } from '../../git.d-BTNkPofF.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Bun ExecAdapter implementation
|
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
createTailPolling,
|
|
6
6
|
readBytes,
|
|
7
7
|
runTailPolling
|
|
8
|
-
} from "../../chunk-
|
|
9
|
-
import "../../chunk-
|
|
8
|
+
} from "../../chunk-HCQGGKTC.js";
|
|
9
|
+
import "../../chunk-V4ZRQG3O.js";
|
|
10
10
|
|
|
11
11
|
// src/adapters/bun/exec.ts
|
|
12
12
|
function resolveChildEnv(env, inheritEnv) {
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
require('../../chunk-
|
|
8
|
+
var _chunkSNC324NLcjs = require('../../chunk-SNC324NL.cjs');
|
|
9
|
+
require('../../chunk-QHIS7LHW.cjs');
|
|
10
10
|
|
|
11
11
|
// src/adapters/deno/exec.ts
|
|
12
12
|
function resolveChildEnvOptions(env, inheritEnv) {
|
|
@@ -141,7 +141,7 @@ var DenoExecAdapter = class {
|
|
|
141
141
|
let stderr = "";
|
|
142
142
|
if (binary) {
|
|
143
143
|
[stdout, stderr] = await Promise.all([
|
|
144
|
-
child.stdout ?
|
|
144
|
+
child.stdout ? _chunkSNC324NLcjs.readBytes.call(void 0, child.stdout) : Promise.resolve(new Uint8Array(0)),
|
|
145
145
|
child.stderr ? readStream(child.stderr, _optionalChain([handlers, 'optionalAccess', _4 => _4.onStderr])) : Promise.resolve("")
|
|
146
146
|
]);
|
|
147
147
|
} else if (_optionalChain([handlers, 'optionalAccess', _5 => _5.onStdout]) || _optionalChain([handlers, 'optionalAccess', _6 => _6.onStderr])) {
|
|
@@ -357,7 +357,7 @@ var DenoFsAdapter = (_class = class {constructor() { _class.prototype.__init.cal
|
|
|
357
357
|
},
|
|
358
358
|
sleep: (ms) => delay(ms)
|
|
359
359
|
};
|
|
360
|
-
await
|
|
360
|
+
await _chunkSNC324NLcjs.runTailPolling.call(void 0, { adapter, signal, pollInterval, onLine });
|
|
361
361
|
}
|
|
362
362
|
async deleteFile(filePath) {
|
|
363
363
|
const tempDir = this.tempFileDirs.get(filePath);
|
|
@@ -443,7 +443,7 @@ var DenoFsAdapter = (_class = class {constructor() { _class.prototype.__init.cal
|
|
|
443
443
|
},
|
|
444
444
|
sleep: (ms) => delay(ms)
|
|
445
445
|
};
|
|
446
|
-
return
|
|
446
|
+
return _chunkSNC324NLcjs.createTailPolling.call(void 0, { adapter, signal, pollInterval });
|
|
447
447
|
}
|
|
448
448
|
}, _class);
|
|
449
449
|
|
|
@@ -454,13 +454,13 @@ function createDenoAdapters() {
|
|
|
454
454
|
fs: new DenoFsAdapter()
|
|
455
455
|
};
|
|
456
456
|
}
|
|
457
|
-
var TypeGit = class _TypeGit extends
|
|
457
|
+
var TypeGit = class _TypeGit extends _chunkSNC324NLcjs.GitClient {
|
|
458
458
|
static async create(options) {
|
|
459
|
-
return new _TypeGit(await
|
|
459
|
+
return new _TypeGit(await _chunkSNC324NLcjs.createGit.call(void 0, { ...options, adapters: createDenoAdapters() }));
|
|
460
460
|
}
|
|
461
461
|
constructor(optionsOrGit) {
|
|
462
462
|
super(
|
|
463
|
-
optionsOrGit && "open" in optionsOrGit ? optionsOrGit :
|
|
463
|
+
optionsOrGit && "open" in optionsOrGit ? optionsOrGit : _chunkSNC324NLcjs.createGitSync.call(void 0, { ...optionsOrGit, adapters: createDenoAdapters() })
|
|
464
464
|
);
|
|
465
465
|
}
|
|
466
466
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as ExecAdapter, S as SpawnOptions, a as StreamHandler, b as SpawnResult, c as SpawnHandle, F as FsAdapter, T as TailOptions, d as TailHandle, R as RuntimeAdapters, C as CreateGitOptions, G as GitClient } from '../../client.d-
|
|
2
|
-
import { C as Capabilities, G as Git } from '../../git.d-
|
|
1
|
+
import { E as ExecAdapter, S as SpawnOptions, a as StreamHandler, b as SpawnResult, c as SpawnHandle, F as FsAdapter, T as TailOptions, d as TailHandle, R as RuntimeAdapters, C as CreateGitOptions, G as GitClient } from '../../client.d-Jwli7Qfw.cjs';
|
|
2
|
+
import { C as Capabilities, G as Git } from '../../git.d-BTNkPofF.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Deno ExecAdapter implementation
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as ExecAdapter, S as SpawnOptions, a as StreamHandler, b as SpawnResult, c as SpawnHandle, F as FsAdapter, T as TailOptions, d as TailHandle, R as RuntimeAdapters, C as CreateGitOptions, G as GitClient } from '../../client.d-
|
|
2
|
-
import { C as Capabilities, G as Git } from '../../git.d-
|
|
1
|
+
import { E as ExecAdapter, S as SpawnOptions, a as StreamHandler, b as SpawnResult, c as SpawnHandle, F as FsAdapter, T as TailOptions, d as TailHandle, R as RuntimeAdapters, C as CreateGitOptions, G as GitClient } from '../../client.d-ClMefrEh.js';
|
|
2
|
+
import { C as Capabilities, G as Git } from '../../git.d-BTNkPofF.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Deno ExecAdapter implementation
|
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
createTailPolling,
|
|
6
6
|
readBytes,
|
|
7
7
|
runTailPolling
|
|
8
|
-
} from "../../chunk-
|
|
9
|
-
import "../../chunk-
|
|
8
|
+
} from "../../chunk-HCQGGKTC.js";
|
|
9
|
+
import "../../chunk-V4ZRQG3O.js";
|
|
10
10
|
|
|
11
11
|
// src/adapters/deno/exec.ts
|
|
12
12
|
function resolveChildEnvOptions(env, inheritEnv) {
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
7
|
-
require('../../chunk-
|
|
8
|
-
require('../../chunk-
|
|
6
|
+
var _chunkI77B22ZEcjs = require('../../chunk-I77B22ZE.cjs');
|
|
7
|
+
require('../../chunk-SNC324NL.cjs');
|
|
8
|
+
require('../../chunk-QHIS7LHW.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
exports.NodeExecAdapter =
|
|
14
|
+
exports.NodeExecAdapter = _chunkI77B22ZEcjs.NodeExecAdapter; exports.NodeFsAdapter = _chunkI77B22ZEcjs.NodeFsAdapter; exports.TypeGit = _chunkI77B22ZEcjs.TypeGit; exports.createNodeAdapters = _chunkI77B22ZEcjs.createNodeAdapters;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as ExecAdapter, S as SpawnOptions, a as StreamHandler, b as SpawnResult, c as SpawnHandle, F as FsAdapter, T as TailOptions, d as TailHandle, R as RuntimeAdapters, C as CreateGitOptions, G as GitClient } from '../../client.d-
|
|
2
|
-
import { C as Capabilities, G as Git } from '../../git.d-
|
|
1
|
+
import { E as ExecAdapter, S as SpawnOptions, a as StreamHandler, b as SpawnResult, c as SpawnHandle, F as FsAdapter, T as TailOptions, d as TailHandle, R as RuntimeAdapters, C as CreateGitOptions, G as GitClient } from '../../client.d-Jwli7Qfw.cjs';
|
|
2
|
+
import { C as Capabilities, G as Git } from '../../git.d-BTNkPofF.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Options for {@link NodeExecAdapter}.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as ExecAdapter, S as SpawnOptions, a as StreamHandler, b as SpawnResult, c as SpawnHandle, F as FsAdapter, T as TailOptions, d as TailHandle, R as RuntimeAdapters, C as CreateGitOptions, G as GitClient } from '../../client.d-
|
|
2
|
-
import { C as Capabilities, G as Git } from '../../git.d-
|
|
1
|
+
import { E as ExecAdapter, S as SpawnOptions, a as StreamHandler, b as SpawnResult, c as SpawnHandle, F as FsAdapter, T as TailOptions, d as TailHandle, R as RuntimeAdapters, C as CreateGitOptions, G as GitClient } from '../../client.d-ClMefrEh.js';
|
|
2
|
+
import { C as Capabilities, G as Git } from '../../git.d-BTNkPofF.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Options for {@link NodeExecAdapter}.
|
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
NodeFsAdapter,
|
|
4
4
|
TypeGit,
|
|
5
5
|
createNodeAdapters
|
|
6
|
-
} from "../../chunk-
|
|
7
|
-
import "../../chunk-
|
|
8
|
-
import "../../chunk-
|
|
6
|
+
} from "../../chunk-MS6E5USB.js";
|
|
7
|
+
import "../../chunk-HCQGGKTC.js";
|
|
8
|
+
import "../../chunk-V4ZRQG3O.js";
|
|
9
9
|
export {
|
|
10
10
|
NodeExecAdapter,
|
|
11
11
|
NodeFsAdapter,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
validatePathInput,
|
|
20
20
|
validateRevParseQuery,
|
|
21
21
|
validateRevParseRefOpts
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-V4ZRQG3O.js";
|
|
23
23
|
|
|
24
24
|
// src/core/clone-config.ts
|
|
25
25
|
var HTTP_VARIABLES = [
|
|
@@ -717,6 +717,16 @@ async function push(runner, context, opts) {
|
|
|
717
717
|
});
|
|
718
718
|
}
|
|
719
719
|
|
|
720
|
+
// src/impl/raw-opts.ts
|
|
721
|
+
function splitRawOpts(opts) {
|
|
722
|
+
const throwOnNonZero = opts?.throwOnNonZero;
|
|
723
|
+
if (throwOnNonZero !== void 0 && typeof throwOnNonZero !== "boolean") {
|
|
724
|
+
const got = throwOnNonZero === null ? "null" : typeof throwOnNonZero;
|
|
725
|
+
throw new GitArgumentError(`throwOnNonZero must be a boolean, got ${got}`);
|
|
726
|
+
}
|
|
727
|
+
return { throwOnNonZero: throwOnNonZero === true, runOpts: opts ?? {} };
|
|
728
|
+
}
|
|
729
|
+
|
|
720
730
|
// src/impl/bare-repo-impl.ts
|
|
721
731
|
var REMOTE_LINE_PATTERN = /^(\S+)\t(.+?)\s+\((fetch|push)\)$/;
|
|
722
732
|
var PRUNED_REF_PATTERN = /\* \[pruned\] (.+)/;
|
|
@@ -953,8 +963,9 @@ var BareRepoImpl = class {
|
|
|
953
963
|
return { type: "bare", gitDir: this.gitDir };
|
|
954
964
|
}
|
|
955
965
|
/** Execute a raw Git command without typed argument validation. */
|
|
956
|
-
raw(argv, opts) {
|
|
957
|
-
|
|
966
|
+
async raw(argv, opts) {
|
|
967
|
+
const { throwOnNonZero, runOpts } = splitRawOpts(opts);
|
|
968
|
+
return throwOnNonZero ? await this.runner.runOrThrow(this.context, argv, runOpts) : await this.runner.run(this.context, argv, runOpts);
|
|
958
969
|
}
|
|
959
970
|
/**
|
|
960
971
|
* Check if this repository is a worktree repository (has working directory)
|
|
@@ -1603,7 +1614,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
1603
1614
|
}
|
|
1604
1615
|
/** Execute a raw Git command without typed argument validation. */
|
|
1605
1616
|
async raw(argv, opts) {
|
|
1606
|
-
|
|
1617
|
+
const { throwOnNonZero, runOpts } = splitRawOpts(opts);
|
|
1618
|
+
return throwOnNonZero ? await this.runner.runOrThrow(this.context, argv, runOpts) : await this.runner.run(this.context, argv, runOpts);
|
|
1607
1619
|
}
|
|
1608
1620
|
/**
|
|
1609
1621
|
* Check if this repository is a worktree repository (has working directory)
|
|
@@ -5397,6 +5409,26 @@ async function assertDataOnlySubmoduleConfigs(runner, fs, workdir, label, expect
|
|
|
5397
5409
|
await assertDataOnlySubmoduleConfigs(runner, fs, subdir, sublabel, subdir);
|
|
5398
5410
|
}
|
|
5399
5411
|
}
|
|
5412
|
+
var FATAL_LINE_PATTERN = /^fatal: [^\r\n]*/m;
|
|
5413
|
+
function notARepository(path, worktreeArgv, worktreeResult, bareResult) {
|
|
5414
|
+
const cause = worktreeResult.stderr.match(FATAL_LINE_PATTERN)?.[0];
|
|
5415
|
+
return new GitError(
|
|
5416
|
+
"NonZeroExit",
|
|
5417
|
+
`Not a git repository: ${path}${cause === void 0 ? "" : ` (${cause})`}`,
|
|
5418
|
+
{
|
|
5419
|
+
gitDir: path,
|
|
5420
|
+
exitCode: bareResult.exitCode,
|
|
5421
|
+
...bareResult.signal ? { signal: bareResult.signal } : {},
|
|
5422
|
+
stderr: bareResult.stderr,
|
|
5423
|
+
firstProbe: {
|
|
5424
|
+
argv: ["-C", path, ...worktreeArgv],
|
|
5425
|
+
exitCode: worktreeResult.exitCode,
|
|
5426
|
+
...worktreeResult.signal ? { signal: worktreeResult.signal } : {},
|
|
5427
|
+
stderr: worktreeResult.stderr
|
|
5428
|
+
}
|
|
5429
|
+
}
|
|
5430
|
+
);
|
|
5431
|
+
}
|
|
5400
5432
|
function gitDirRefusal(path, exitCode, stderr) {
|
|
5401
5433
|
return new GitError(
|
|
5402
5434
|
"NonZeroExit",
|
|
@@ -5485,21 +5517,19 @@ var GitImpl = class {
|
|
|
5485
5517
|
}
|
|
5486
5518
|
const repoRunner = opts ? this.runner.withOptions(toCliRunnerOptions(opts)) : this.runner;
|
|
5487
5519
|
const untrusted = opts?.untrusted === true;
|
|
5488
|
-
const
|
|
5520
|
+
const worktreeArgv = [
|
|
5489
5521
|
"rev-parse",
|
|
5490
5522
|
"--is-bare-repository",
|
|
5491
5523
|
...untrusted ? ["--is-inside-git-dir"] : []
|
|
5492
|
-
]
|
|
5524
|
+
];
|
|
5525
|
+
const result = await repoRunner.run({ type: "worktree", workdir: path }, worktreeArgv);
|
|
5493
5526
|
if (result.exitCode !== 0) {
|
|
5494
5527
|
const bareResult = await repoRunner.run({ type: "bare", gitDir: path }, [
|
|
5495
5528
|
"rev-parse",
|
|
5496
5529
|
"--is-bare-repository"
|
|
5497
5530
|
]);
|
|
5498
5531
|
if (bareResult.exitCode !== 0) {
|
|
5499
|
-
throw
|
|
5500
|
-
exitCode: bareResult.exitCode,
|
|
5501
|
-
stderr: bareResult.stderr
|
|
5502
|
-
});
|
|
5532
|
+
throw notARepository(path, worktreeArgv, result, bareResult);
|
|
5503
5533
|
}
|
|
5504
5534
|
if (bareResult.stdout.trim() === "true") {
|
|
5505
5535
|
if (opts?.untrusted === true) {
|
|
@@ -5685,8 +5715,9 @@ var GitImpl = class {
|
|
|
5685
5715
|
return compareVersions(version, "2.28.0") >= 0;
|
|
5686
5716
|
}
|
|
5687
5717
|
/** Execute a raw Git command without typed argument validation. */
|
|
5688
|
-
raw(argv, opts) {
|
|
5689
|
-
|
|
5718
|
+
async raw(argv, opts) {
|
|
5719
|
+
const { throwOnNonZero, runOpts } = splitRawOpts(opts);
|
|
5720
|
+
return throwOnNonZero ? await this.runner.runOrThrow({ type: "global" }, argv, runOpts) : await this.runner.run({ type: "global" }, argv, runOpts);
|
|
5690
5721
|
}
|
|
5691
5722
|
// ==========================================================================
|
|
5692
5723
|
// Global Config Operations
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkSNC324NLcjs = require('./chunk-SNC324NL.cjs');
|
|
9
9
|
|
|
10
10
|
// src/adapters/node/exec.ts
|
|
11
11
|
var _child_process = require('child_process');
|
|
@@ -134,7 +134,7 @@ var NodeExecAdapter = class {
|
|
|
134
134
|
exitSignal = sig;
|
|
135
135
|
}
|
|
136
136
|
resolve({
|
|
137
|
-
stdout: binary ?
|
|
137
|
+
stdout: binary ? _chunkSNC324NLcjs.joinBytes.call(void 0, stdoutChunks) : stdout,
|
|
138
138
|
stderr,
|
|
139
139
|
exitCode: _nullishCoalesce(code, () => ( -1)),
|
|
140
140
|
signal: exitSignal,
|
|
@@ -273,7 +273,7 @@ var NodeFsAdapter = (_class = class {constructor() { _class.prototype.__init.cal
|
|
|
273
273
|
sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms))
|
|
274
274
|
};
|
|
275
275
|
try {
|
|
276
|
-
await
|
|
276
|
+
await _chunkSNC324NLcjs.runTailPolling.call(void 0, { adapter, signal, pollInterval, onLine });
|
|
277
277
|
} finally {
|
|
278
278
|
if (state.file) {
|
|
279
279
|
await state.file.close();
|
|
@@ -341,7 +341,7 @@ var NodeFsAdapter = (_class = class {constructor() { _class.prototype.__init.cal
|
|
|
341
341
|
},
|
|
342
342
|
sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms))
|
|
343
343
|
};
|
|
344
|
-
const polling =
|
|
344
|
+
const polling = _chunkSNC324NLcjs.createTailPolling.call(void 0, { adapter, signal, pollInterval });
|
|
345
345
|
const closeFileHandle = async () => {
|
|
346
346
|
if (state.file) {
|
|
347
347
|
await state.file.close().catch(() => {
|
|
@@ -379,18 +379,18 @@ function splitOptions(options) {
|
|
|
379
379
|
adapters: createNodeAdapters(windowsHide === void 0 ? void 0 : { windowsHide })
|
|
380
380
|
};
|
|
381
381
|
}
|
|
382
|
-
var TypeGit = class _TypeGit extends
|
|
382
|
+
var TypeGit = class _TypeGit extends _chunkSNC324NLcjs.GitClient {
|
|
383
383
|
/**
|
|
384
384
|
* Create a client after checking the installed Git version. Node adapter options such as
|
|
385
385
|
* `windowsHide` are passed to the execution adapter.
|
|
386
386
|
*/
|
|
387
387
|
static async create(options) {
|
|
388
|
-
return new _TypeGit(await
|
|
388
|
+
return new _TypeGit(await _chunkSNC324NLcjs.createGit.call(void 0, splitOptions(options)));
|
|
389
389
|
}
|
|
390
390
|
/** Wrap an existing Git instance, or create one from options without the version check. */
|
|
391
391
|
constructor(optionsOrGit) {
|
|
392
392
|
super(
|
|
393
|
-
optionsOrGit && "open" in optionsOrGit ? optionsOrGit :
|
|
393
|
+
optionsOrGit && "open" in optionsOrGit ? optionsOrGit : _chunkSNC324NLcjs.createGitSync.call(void 0, splitOptions(optionsOrGit))
|
|
394
394
|
);
|
|
395
395
|
}
|
|
396
396
|
};
|
|
@@ -5312,6 +5312,52 @@ function validateInput(name, input, command = name) {
|
|
|
5312
5312
|
var FATAL_ERROR_PATTERN = /fatal:\s*(.+)/i;
|
|
5313
5313
|
var ERROR_PATTERN = /error:\s*(.+)/i;
|
|
5314
5314
|
var LINE_SEPARATOR_PATTERN = /\r|\n/;
|
|
5315
|
+
var WINDOWS_ROOTED_PATH_PATTERN = /^(?:[\\/]|[A-Za-z]:[\\/])/;
|
|
5316
|
+
function isRootedPath(path, platform = _process2.default.platform) {
|
|
5317
|
+
return platform === "win32" ? WINDOWS_ROOTED_PATH_PATTERN.test(path) : path.startsWith("/");
|
|
5318
|
+
}
|
|
5319
|
+
function spawnCwd(context, companion) {
|
|
5320
|
+
const directory = context.type === "worktree" ? context.workdir : context.type === "bare" ? context.gitDir : void 0;
|
|
5321
|
+
if (directory === void 0) {
|
|
5322
|
+
return void 0;
|
|
5323
|
+
}
|
|
5324
|
+
return companion || isRootedPath(directory) ? directory : void 0;
|
|
5325
|
+
}
|
|
5326
|
+
var WINDOWS_SEPARATOR_PATTERN = /[\\/]/;
|
|
5327
|
+
var WINDOWS_DRIVE_PATTERN = /^[A-Za-z]:/;
|
|
5328
|
+
function anchorToCaller(path) {
|
|
5329
|
+
const windows = _process2.default.platform === "win32";
|
|
5330
|
+
if (path === "") {
|
|
5331
|
+
return _process2.default.cwd();
|
|
5332
|
+
}
|
|
5333
|
+
if (isRootedPath(path) || windows && WINDOWS_DRIVE_PATTERN.test(path)) {
|
|
5334
|
+
return path;
|
|
5335
|
+
}
|
|
5336
|
+
return `${_process2.default.cwd()}${windows ? "\\" : "/"}${path}`;
|
|
5337
|
+
}
|
|
5338
|
+
var WINDOWS_QUOTED_PATTERN = /^".*"$/;
|
|
5339
|
+
function pathKeyOf(env) {
|
|
5340
|
+
return _process2.default.platform === "win32" ? _nullishCoalesce(Object.keys(env).find((key) => key.toLowerCase() === "path"), () => ( "PATH")) : "PATH";
|
|
5341
|
+
}
|
|
5342
|
+
function anchorSearchPath(env) {
|
|
5343
|
+
const windows = _process2.default.platform === "win32";
|
|
5344
|
+
const delimiter = windows ? ";" : ":";
|
|
5345
|
+
const keys = windows ? Object.keys(env).filter((key) => key.toLowerCase() === "path") : ["PATH"];
|
|
5346
|
+
for (const key of keys) {
|
|
5347
|
+
const value = env[key];
|
|
5348
|
+
if (value === void 0) {
|
|
5349
|
+
continue;
|
|
5350
|
+
}
|
|
5351
|
+
env[key] = value.split(delimiter).map(
|
|
5352
|
+
(entry) => windows && WINDOWS_QUOTED_PATTERN.test(entry) ? entry : anchorToCaller(entry)
|
|
5353
|
+
).join(delimiter);
|
|
5354
|
+
}
|
|
5355
|
+
}
|
|
5356
|
+
function callerRelativeProgram(program, cwd) {
|
|
5357
|
+
const windows = _process2.default.platform === "win32";
|
|
5358
|
+
const hasSeparator = windows ? WINDOWS_SEPARATOR_PATTERN.test(program) : program.includes("/");
|
|
5359
|
+
return cwd === void 0 || !hasSeparator ? program : anchorToCaller(program);
|
|
5360
|
+
}
|
|
5315
5361
|
var GIT_TRACE_PATTERN = /^\d{2}:\d{2}:\d{2}\.\d+\s+(?:trace:|[A-Za-z0-9_.-]+\.c:)/;
|
|
5316
5362
|
var TRACE_ENV_PATTERN = /^(?:GIT_TRACE\w*|GIT_CURL_VERBOSE)$/i;
|
|
5317
5363
|
function stripTraceEnv(env) {
|
|
@@ -5497,7 +5543,7 @@ var CliRunner = class _CliRunner {
|
|
|
5497
5543
|
* Build command argv based on execution context
|
|
5498
5544
|
*/
|
|
5499
5545
|
buildArgv(context, args) {
|
|
5500
|
-
const argv = [this.gitBinary];
|
|
5546
|
+
const argv = [callerRelativeProgram(this.gitBinary, spawnCwd(context, false))];
|
|
5501
5547
|
for (const parameter of this.configParameters()) {
|
|
5502
5548
|
argv.push("-c", parameter);
|
|
5503
5549
|
}
|
|
@@ -5546,7 +5592,7 @@ var CliRunner = class _CliRunner {
|
|
|
5546
5592
|
if (allPathPrefixes.length > 0) {
|
|
5547
5593
|
const isWindows = _process2.default.platform === "win32";
|
|
5548
5594
|
const separator = isWindows ? ";" : ":";
|
|
5549
|
-
const pathKey =
|
|
5595
|
+
const pathKey = pathKeyOf(env);
|
|
5550
5596
|
const currentPath = _nullishCoalesce(env[pathKey], () => ( ""));
|
|
5551
5597
|
env[pathKey] = [...allPathPrefixes, currentPath].join(separator);
|
|
5552
5598
|
}
|
|
@@ -5822,6 +5868,10 @@ var CliRunner = class _CliRunner {
|
|
|
5822
5868
|
if (envOverride) {
|
|
5823
5869
|
applyEnvOverride(env, envOverride);
|
|
5824
5870
|
}
|
|
5871
|
+
const cwd = spawnCwd(context, executable !== void 0);
|
|
5872
|
+
if (cwd !== void 0) {
|
|
5873
|
+
anchorSearchPath(env);
|
|
5874
|
+
}
|
|
5825
5875
|
if (internal) {
|
|
5826
5876
|
stripTraceEnv(env);
|
|
5827
5877
|
}
|
|
@@ -5864,7 +5914,7 @@ var CliRunner = class _CliRunner {
|
|
|
5864
5914
|
// The env above is already fully resolved (including any inherited variables),
|
|
5865
5915
|
// so the adapter must not merge the parent environment on top of it.
|
|
5866
5916
|
inheritEnv: false,
|
|
5867
|
-
cwd
|
|
5917
|
+
cwd,
|
|
5868
5918
|
signal
|
|
5869
5919
|
},
|
|
5870
5920
|
needsStderrStreaming ? {
|