git-colabor 0.3.0 → 0.3.1
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 +2 -1
- package/dist/askpass.cjs +11 -3
- package/dist/cli.cjs +31 -5
- package/dist/index.cjs +112 -74
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -158,7 +158,8 @@ Full threat model: [docs/SECURITY.md](../docs/SECURITY.md) in the extension repo
|
|
|
158
158
|
| `GIT_COLABOR_AUDIT_FILE` | audit log path |
|
|
159
159
|
| `GIT_COLABOR_MESSAGE_PATH` | commit template path |
|
|
160
160
|
| `GIT_COLABOR_LOG_FILE` / `GIT_COLABOR_LOG_LEVEL` | CLI debug log |
|
|
161
|
-
| `
|
|
161
|
+
| `GIT_COLABOR_GIT` | git executable to run (default: `git` from `PATH`; the extension points it at the git vscode.git runs) |
|
|
162
|
+
| `GIT_COLABOR_ASKPASS_SOCK` / `GIT_COLABOR_ASKPASS_TOKEN` | askpass bridge endpoint — UNIX socket, or a named pipe on Windows (set by the extension) |
|
|
162
163
|
|
|
163
164
|
## Library
|
|
164
165
|
|
package/dist/askpass.cjs
CHANGED
|
@@ -49,6 +49,14 @@ function pidIsAlive(pid) {
|
|
|
49
49
|
return e.code === "EPERM";
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
+
var SOCKET_NAME_RE = /^askpass-[\w.-]+\.sock$/;
|
|
53
|
+
var PIPE_RE = /^\\\\\.\\pipe\\git-colabor-askpass-[\w.-]+$/;
|
|
54
|
+
function askpassEndpointKind(dir, endpoint, platform = process.platform) {
|
|
55
|
+
if (typeof endpoint !== "string") return void 0;
|
|
56
|
+
if (platform === "win32" && PIPE_RE.test(endpoint)) return "pipe";
|
|
57
|
+
if (!SOCKET_NAME_RE.test(path.basename(endpoint))) return void 0;
|
|
58
|
+
return path.join(dir, path.basename(endpoint)) === endpoint ? "socket" : void 0;
|
|
59
|
+
}
|
|
52
60
|
function discoverSessionBridges() {
|
|
53
61
|
try {
|
|
54
62
|
const dir = dataDir();
|
|
@@ -58,10 +66,10 @@ function discoverSessionBridges() {
|
|
|
58
66
|
try {
|
|
59
67
|
const parsed = JSON.parse(fs.readFileSync(path.join(dir, s.f), "utf8"));
|
|
60
68
|
if (!parsed.socketPath || !parsed.token) continue;
|
|
61
|
-
const
|
|
62
|
-
const stale = parsed.pid !== void 0 && !pidIsAlive(parsed.pid) ||
|
|
69
|
+
const kind = askpassEndpointKind(dir, parsed.socketPath);
|
|
70
|
+
const stale = parsed.pid !== void 0 && !pidIsAlive(parsed.pid) || kind === void 0 || kind === "socket" && !fs.existsSync(parsed.socketPath);
|
|
63
71
|
if (stale) {
|
|
64
|
-
if (
|
|
72
|
+
if (kind === "socket" && fs.existsSync(parsed.socketPath)) {
|
|
65
73
|
try {
|
|
66
74
|
fs.rmSync(parsed.socketPath);
|
|
67
75
|
} catch {
|
package/dist/cli.cjs
CHANGED
|
@@ -353,9 +353,25 @@ var init_map = __esm({
|
|
|
353
353
|
idOf = (name, email) => `${name.trim()} <${email.trim()}>`;
|
|
354
354
|
}
|
|
355
355
|
});
|
|
356
|
+
function gitCommand() {
|
|
357
|
+
return process.env.GIT_COLABOR_GIT?.trim() || "git";
|
|
358
|
+
}
|
|
359
|
+
function gitNotFound(cmd, e) {
|
|
360
|
+
return new AppError({
|
|
361
|
+
code: "GIT_NOT_FOUND",
|
|
362
|
+
message: `cannot start git ("${cmd}"): ${e.message}`,
|
|
363
|
+
exitCode: EXIT_CODES.RUNTIME,
|
|
364
|
+
hints: [
|
|
365
|
+
"install Git, or put its directory on PATH",
|
|
366
|
+
"VS Code extension: set the `git.path` setting to the git executable",
|
|
367
|
+
"standalone CLI: set GIT_COLABOR_GIT to the git executable"
|
|
368
|
+
]
|
|
369
|
+
});
|
|
370
|
+
}
|
|
356
371
|
function run(args, opts) {
|
|
357
372
|
return new Promise((resolve4, reject) => {
|
|
358
|
-
const
|
|
373
|
+
const cmd = gitCommand();
|
|
374
|
+
const child = child_process.spawn(cmd, args, {
|
|
359
375
|
cwd: opts.cwd,
|
|
360
376
|
env: opts.env ? { ...process.env, ...opts.env } : process.env,
|
|
361
377
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -368,7 +384,7 @@ function run(args, opts) {
|
|
|
368
384
|
child.stderr.on("data", (d) => {
|
|
369
385
|
stderr += d.toString("utf8");
|
|
370
386
|
});
|
|
371
|
-
child.on("error", reject);
|
|
387
|
+
child.on("error", (e) => reject(e.code === "ENOENT" ? gitNotFound(cmd, e) : e));
|
|
372
388
|
child.on("close", (code) => {
|
|
373
389
|
resolve4({ stdout, stderr, exitCode: code ?? 0 });
|
|
374
390
|
});
|
|
@@ -408,6 +424,7 @@ async function runBin(cmd, args, opts = {}) {
|
|
|
408
424
|
var GitError;
|
|
409
425
|
var init_exec = __esm({
|
|
410
426
|
"src/core/git/exec.ts"() {
|
|
427
|
+
init_errors();
|
|
411
428
|
GitError = class extends Error {
|
|
412
429
|
cmd;
|
|
413
430
|
exitCode;
|
|
@@ -1032,6 +1049,12 @@ function pidIsAlive(pid) {
|
|
|
1032
1049
|
return e.code === "EPERM";
|
|
1033
1050
|
}
|
|
1034
1051
|
}
|
|
1052
|
+
function askpassEndpointKind(dir, endpoint, platform = process.platform) {
|
|
1053
|
+
if (typeof endpoint !== "string") return void 0;
|
|
1054
|
+
if (platform === "win32" && PIPE_RE.test(endpoint)) return "pipe";
|
|
1055
|
+
if (!SOCKET_NAME_RE.test(path.basename(endpoint))) return void 0;
|
|
1056
|
+
return path.join(dir, path.basename(endpoint)) === endpoint ? "socket" : void 0;
|
|
1057
|
+
}
|
|
1035
1058
|
function discoverSessionBridges() {
|
|
1036
1059
|
try {
|
|
1037
1060
|
const dir = dataDir();
|
|
@@ -1041,10 +1064,10 @@ function discoverSessionBridges() {
|
|
|
1041
1064
|
try {
|
|
1042
1065
|
const parsed = JSON.parse(fs.readFileSync(path.join(dir, s.f), "utf8"));
|
|
1043
1066
|
if (!parsed.socketPath || !parsed.token) continue;
|
|
1044
|
-
const
|
|
1045
|
-
const stale = parsed.pid !== void 0 && !pidIsAlive(parsed.pid) ||
|
|
1067
|
+
const kind = askpassEndpointKind(dir, parsed.socketPath);
|
|
1068
|
+
const stale = parsed.pid !== void 0 && !pidIsAlive(parsed.pid) || kind === void 0 || kind === "socket" && !fs.existsSync(parsed.socketPath);
|
|
1046
1069
|
if (stale) {
|
|
1047
|
-
if (
|
|
1070
|
+
if (kind === "socket" && fs.existsSync(parsed.socketPath)) {
|
|
1048
1071
|
try {
|
|
1049
1072
|
fs.rmSync(parsed.socketPath);
|
|
1050
1073
|
} catch {
|
|
@@ -1068,9 +1091,12 @@ function discoverSessionBridges() {
|
|
|
1068
1091
|
function discoverSessionBridge() {
|
|
1069
1092
|
return discoverSessionBridges()[0];
|
|
1070
1093
|
}
|
|
1094
|
+
var SOCKET_NAME_RE, PIPE_RE;
|
|
1071
1095
|
var init_session_bridge = __esm({
|
|
1072
1096
|
"src/core/secrets/session-bridge.ts"() {
|
|
1073
1097
|
init_paths();
|
|
1098
|
+
SOCKET_NAME_RE = /^askpass-[\w.-]+\.sock$/;
|
|
1099
|
+
PIPE_RE = /^\\\\\.\\pipe\\git-colabor-askpass-[\w.-]+$/;
|
|
1074
1100
|
}
|
|
1075
1101
|
});
|
|
1076
1102
|
|
package/dist/index.cjs
CHANGED
|
@@ -68,9 +68,83 @@ var init_formatter = __esm({
|
|
|
68
68
|
init_types();
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
|
+
|
|
72
|
+
// src/core/errors.ts
|
|
73
|
+
function toErrorPayload(e) {
|
|
74
|
+
if (e instanceof exports.AppError) return e.toPayload();
|
|
75
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
76
|
+
return { code: "INTERNAL", message, exitCode: exports.EXIT_CODES.RUNTIME };
|
|
77
|
+
}
|
|
78
|
+
exports.EXIT_CODES = void 0; exports.AppError = void 0; exports.Errors = void 0;
|
|
79
|
+
var init_errors = __esm({
|
|
80
|
+
"src/core/errors.ts"() {
|
|
81
|
+
exports.EXIT_CODES = {
|
|
82
|
+
OK: 0,
|
|
83
|
+
RUNTIME: 1,
|
|
84
|
+
USAGE: 2,
|
|
85
|
+
NOT_A_REPO: 3,
|
|
86
|
+
SECRET_UNAVAILABLE: 4,
|
|
87
|
+
NOT_FOUND: 5,
|
|
88
|
+
CONFLICT_BLOCKED: 6
|
|
89
|
+
};
|
|
90
|
+
exports.AppError = class extends Error {
|
|
91
|
+
code;
|
|
92
|
+
exitCode;
|
|
93
|
+
hints;
|
|
94
|
+
constructor(init) {
|
|
95
|
+
super(init.message);
|
|
96
|
+
this.name = "AppError";
|
|
97
|
+
this.code = init.code;
|
|
98
|
+
this.exitCode = init.exitCode ?? exports.EXIT_CODES.RUNTIME;
|
|
99
|
+
this.hints = init.hints;
|
|
100
|
+
}
|
|
101
|
+
toPayload() {
|
|
102
|
+
return { code: this.code, message: this.message, hints: this.hints, exitCode: this.exitCode };
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
exports.Errors = {
|
|
106
|
+
notARepo: (cwd) => new exports.AppError({
|
|
107
|
+
code: "NOT_A_REPO",
|
|
108
|
+
message: cwd ? `not a git repository: ${cwd}` : "not a git repository",
|
|
109
|
+
exitCode: exports.EXIT_CODES.NOT_A_REPO
|
|
110
|
+
}),
|
|
111
|
+
authorNotFound: (key) => new exports.AppError({
|
|
112
|
+
code: "AUTHOR_NOT_FOUND",
|
|
113
|
+
message: `Author with initials "${key}" not found in identities`,
|
|
114
|
+
exitCode: exports.EXIT_CODES.NOT_FOUND,
|
|
115
|
+
hints: [`Add it with: git colabor coauthor add ${key} "Full Name" email@example.com`]
|
|
116
|
+
}),
|
|
117
|
+
duplicateKey: (key) => new exports.AppError({
|
|
118
|
+
code: "DUPLICATE_KEY",
|
|
119
|
+
message: `Key "${key}" already exists`,
|
|
120
|
+
exitCode: exports.EXIT_CODES.NOT_FOUND,
|
|
121
|
+
hints: []
|
|
122
|
+
}),
|
|
123
|
+
invalidEmail: (email) => new exports.AppError({ code: "INVALID_EMAIL", message: `Invalid email: ${email}`, exitCode: exports.EXIT_CODES.USAGE }),
|
|
124
|
+
usage: (message, hints) => new exports.AppError({ code: "USAGE", message, exitCode: exports.EXIT_CODES.USAGE, hints }),
|
|
125
|
+
secretUnavailable: (message, hints) => new exports.AppError({ code: "SECRET_UNAVAILABLE", message, exitCode: exports.EXIT_CODES.SECRET_UNAVAILABLE, hints })
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
function gitCommand() {
|
|
130
|
+
return process.env.GIT_COLABOR_GIT?.trim() || "git";
|
|
131
|
+
}
|
|
132
|
+
function gitNotFound(cmd, e) {
|
|
133
|
+
return new exports.AppError({
|
|
134
|
+
code: "GIT_NOT_FOUND",
|
|
135
|
+
message: `cannot start git ("${cmd}"): ${e.message}`,
|
|
136
|
+
exitCode: exports.EXIT_CODES.RUNTIME,
|
|
137
|
+
hints: [
|
|
138
|
+
"install Git, or put its directory on PATH",
|
|
139
|
+
"VS Code extension: set the `git.path` setting to the git executable",
|
|
140
|
+
"standalone CLI: set GIT_COLABOR_GIT to the git executable"
|
|
141
|
+
]
|
|
142
|
+
});
|
|
143
|
+
}
|
|
71
144
|
function run(args, opts) {
|
|
72
145
|
return new Promise((resolve4, reject) => {
|
|
73
|
-
const
|
|
146
|
+
const cmd = gitCommand();
|
|
147
|
+
const child = child_process.spawn(cmd, args, {
|
|
74
148
|
cwd: opts.cwd,
|
|
75
149
|
env: opts.env ? { ...process.env, ...opts.env } : process.env,
|
|
76
150
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -83,7 +157,7 @@ function run(args, opts) {
|
|
|
83
157
|
child.stderr.on("data", (d) => {
|
|
84
158
|
stderr += d.toString("utf8");
|
|
85
159
|
});
|
|
86
|
-
child.on("error", reject);
|
|
160
|
+
child.on("error", (e) => reject(e.code === "ENOENT" ? gitNotFound(cmd, e) : e));
|
|
87
161
|
child.on("close", (code) => {
|
|
88
162
|
resolve4({ stdout, stderr, exitCode: code ?? 0 });
|
|
89
163
|
});
|
|
@@ -123,6 +197,7 @@ async function runBin(cmd, args, opts = {}) {
|
|
|
123
197
|
exports.GitError = void 0;
|
|
124
198
|
var init_exec = __esm({
|
|
125
199
|
"src/core/git/exec.ts"() {
|
|
200
|
+
init_errors();
|
|
126
201
|
exports.GitError = class extends Error {
|
|
127
202
|
cmd;
|
|
128
203
|
exitCode;
|
|
@@ -636,60 +711,8 @@ function nowHeldBy(session, source) {
|
|
|
636
711
|
// src/core/repo/status.ts
|
|
637
712
|
init_rev();
|
|
638
713
|
|
|
639
|
-
// src/core/errors.ts
|
|
640
|
-
var EXIT_CODES = {
|
|
641
|
-
OK: 0,
|
|
642
|
-
RUNTIME: 1,
|
|
643
|
-
USAGE: 2,
|
|
644
|
-
NOT_A_REPO: 3,
|
|
645
|
-
SECRET_UNAVAILABLE: 4,
|
|
646
|
-
NOT_FOUND: 5,
|
|
647
|
-
CONFLICT_BLOCKED: 6
|
|
648
|
-
};
|
|
649
|
-
var AppError = class extends Error {
|
|
650
|
-
code;
|
|
651
|
-
exitCode;
|
|
652
|
-
hints;
|
|
653
|
-
constructor(init) {
|
|
654
|
-
super(init.message);
|
|
655
|
-
this.name = "AppError";
|
|
656
|
-
this.code = init.code;
|
|
657
|
-
this.exitCode = init.exitCode ?? EXIT_CODES.RUNTIME;
|
|
658
|
-
this.hints = init.hints;
|
|
659
|
-
}
|
|
660
|
-
toPayload() {
|
|
661
|
-
return { code: this.code, message: this.message, hints: this.hints, exitCode: this.exitCode };
|
|
662
|
-
}
|
|
663
|
-
};
|
|
664
|
-
var Errors = {
|
|
665
|
-
notARepo: (cwd) => new AppError({
|
|
666
|
-
code: "NOT_A_REPO",
|
|
667
|
-
message: cwd ? `not a git repository: ${cwd}` : "not a git repository",
|
|
668
|
-
exitCode: EXIT_CODES.NOT_A_REPO
|
|
669
|
-
}),
|
|
670
|
-
authorNotFound: (key) => new AppError({
|
|
671
|
-
code: "AUTHOR_NOT_FOUND",
|
|
672
|
-
message: `Author with initials "${key}" not found in identities`,
|
|
673
|
-
exitCode: EXIT_CODES.NOT_FOUND,
|
|
674
|
-
hints: [`Add it with: git colabor coauthor add ${key} "Full Name" email@example.com`]
|
|
675
|
-
}),
|
|
676
|
-
duplicateKey: (key) => new AppError({
|
|
677
|
-
code: "DUPLICATE_KEY",
|
|
678
|
-
message: `Key "${key}" already exists`,
|
|
679
|
-
exitCode: EXIT_CODES.NOT_FOUND,
|
|
680
|
-
hints: []
|
|
681
|
-
}),
|
|
682
|
-
invalidEmail: (email) => new AppError({ code: "INVALID_EMAIL", message: `Invalid email: ${email}`, exitCode: EXIT_CODES.USAGE }),
|
|
683
|
-
usage: (message, hints) => new AppError({ code: "USAGE", message, exitCode: EXIT_CODES.USAGE, hints }),
|
|
684
|
-
secretUnavailable: (message, hints) => new AppError({ code: "SECRET_UNAVAILABLE", message, exitCode: EXIT_CODES.SECRET_UNAVAILABLE, hints })
|
|
685
|
-
};
|
|
686
|
-
function toErrorPayload(e) {
|
|
687
|
-
if (e instanceof AppError) return e.toPayload();
|
|
688
|
-
const message = e instanceof Error ? e.message : String(e);
|
|
689
|
-
return { code: "INTERNAL", message, exitCode: EXIT_CODES.RUNTIME };
|
|
690
|
-
}
|
|
691
|
-
|
|
692
714
|
// src/core/identity/map.ts
|
|
715
|
+
init_errors();
|
|
693
716
|
var norm = (s) => s.trim().toLowerCase();
|
|
694
717
|
var refOf = (i) => `${norm(i.name)} <${norm(i.email)}>`;
|
|
695
718
|
var idOf = (name, email) => `${name.trim()} <${email.trim()}>`;
|
|
@@ -708,7 +731,7 @@ function resolveRow(map, ref) {
|
|
|
708
731
|
if (/^\d+$/.test(ref.trim())) {
|
|
709
732
|
const row = map.identities[Number(ref.trim()) - 1];
|
|
710
733
|
if (row) return row;
|
|
711
|
-
throw Errors.usage(
|
|
734
|
+
throw exports.Errors.usage(
|
|
712
735
|
`identity index ${ref.trim()} out of range \u2014 the list has ${map.identities.length} entries (see \`git colabor identity ls\`)`
|
|
713
736
|
);
|
|
714
737
|
}
|
|
@@ -717,10 +740,10 @@ function resolveRow(map, ref) {
|
|
|
717
740
|
if (byEmail.length === 1) return byEmail[0];
|
|
718
741
|
if (byEmail.length > 1) {
|
|
719
742
|
const list = byEmail.map((i) => `"${idOf(i.name, i.email)}"`).join(", ");
|
|
720
|
-
throw Errors.usage(`email "${ref}" matches several identities \u2014 use the full form: ${list}`);
|
|
743
|
+
throw exports.Errors.usage(`email "${ref}" matches several identities \u2014 use the full form: ${list}`);
|
|
721
744
|
}
|
|
722
745
|
}
|
|
723
|
-
throw Errors.usage(`identity "${ref}" not found`);
|
|
746
|
+
throw exports.Errors.usage(`identity "${ref}" not found`);
|
|
724
747
|
}
|
|
725
748
|
function foldRow(rows, raw) {
|
|
726
749
|
let keyBindings = raw.keyBindings;
|
|
@@ -816,9 +839,9 @@ async function updateIdentity(ref, patch, opts = {}) {
|
|
|
816
839
|
if (opts?.clearAlias) delete row.alias;
|
|
817
840
|
const after = refOf(row);
|
|
818
841
|
const aliasClash = patch.alias && map.identities.find((i) => i !== row && i.alias === patch.alias);
|
|
819
|
-
if (aliasClash) throw Errors.usage(`alias "${patch.alias}" already belongs to ${idOf(aliasClash.name, aliasClash.email)}`);
|
|
842
|
+
if (aliasClash) throw exports.Errors.usage(`alias "${patch.alias}" already belongs to ${idOf(aliasClash.name, aliasClash.email)}`);
|
|
820
843
|
const clash = map.identities.find((i) => i !== row && refOf(i) === after);
|
|
821
|
-
if (clash) throw Errors.usage(`"${idOf(row.name, row.email)}" already exists`);
|
|
844
|
+
if (clash) throw exports.Errors.usage(`"${idOf(row.name, row.email)}" already exists`);
|
|
822
845
|
if (map.defaultIdentity === before) map.defaultIdentity = after;
|
|
823
846
|
await writeMap(map);
|
|
824
847
|
return row;
|
|
@@ -912,17 +935,18 @@ function toBrief(a) {
|
|
|
912
935
|
|
|
913
936
|
// src/core/identity/keys.ts
|
|
914
937
|
init_exec();
|
|
938
|
+
init_errors();
|
|
915
939
|
var FP_RE = /SHA256:[A-Za-z0-9+/=]+/;
|
|
916
940
|
async function fingerprintOfFile(path) {
|
|
917
941
|
const r = await runBin("ssh-keygen", ["-lf", path]);
|
|
918
942
|
if (r.exitCode !== 0) {
|
|
919
|
-
throw new AppError({
|
|
943
|
+
throw new exports.AppError({
|
|
920
944
|
code: "KEY_READ_FAILED",
|
|
921
945
|
message: `cannot read key fingerprint: ${r.stderr.trim() || "ssh-keygen failed"}`
|
|
922
946
|
});
|
|
923
947
|
}
|
|
924
948
|
const m = r.stdout.match(FP_RE);
|
|
925
|
-
if (!m) throw new AppError({ code: "KEY_READ_FAILED", message: `unparseable ssh-keygen output: ${r.stdout}` });
|
|
949
|
+
if (!m) throw new exports.AppError({ code: "KEY_READ_FAILED", message: `unparseable ssh-keygen output: ${r.stdout}` });
|
|
926
950
|
return m[0];
|
|
927
951
|
}
|
|
928
952
|
async function isEncrypted(path) {
|
|
@@ -1089,10 +1113,12 @@ init_rev();
|
|
|
1089
1113
|
// src/core/identity/sign.ts
|
|
1090
1114
|
init_config();
|
|
1091
1115
|
init_rev();
|
|
1116
|
+
init_errors();
|
|
1092
1117
|
|
|
1093
1118
|
// src/core/identity/gpg.ts
|
|
1094
1119
|
init_config();
|
|
1095
1120
|
init_exec();
|
|
1121
|
+
init_errors();
|
|
1096
1122
|
var UNUSABLE = /* @__PURE__ */ new Set(["i", "d", "r", "e", "n"]);
|
|
1097
1123
|
function unescape(s) {
|
|
1098
1124
|
return s.replace(/\\x([0-9a-fA-F]{2})/g, (_, h) => String.fromCharCode(parseInt(h, 16)));
|
|
@@ -1148,7 +1174,7 @@ async function listSigningKeys(cwd, query) {
|
|
|
1148
1174
|
try {
|
|
1149
1175
|
r = await runBin(program, ["--batch", "--list-secret-keys", "--with-colons", ...query ? [query] : []], { cwd });
|
|
1150
1176
|
} catch {
|
|
1151
|
-
throw new AppError({
|
|
1177
|
+
throw new exports.AppError({
|
|
1152
1178
|
code: "GPG_UNAVAILABLE",
|
|
1153
1179
|
message: `cannot run "${program}"`,
|
|
1154
1180
|
exitCode: 1,
|
|
@@ -1228,17 +1254,17 @@ async function disableSigning(cwd, scope = "local") {
|
|
|
1228
1254
|
}
|
|
1229
1255
|
}
|
|
1230
1256
|
async function setCommitSigning(opts) {
|
|
1231
|
-
if (!await insideWorkTree(opts.cwd)) throw Errors.notARepo(opts.cwd);
|
|
1257
|
+
if (!await insideWorkTree(opts.cwd)) throw exports.Errors.notARepo(opts.cwd);
|
|
1232
1258
|
if (!opts.on) {
|
|
1233
1259
|
await disableSigning(opts.cwd);
|
|
1234
1260
|
if (opts.id) await setSignCommits(opts.id, false);
|
|
1235
1261
|
await appendAudit({ action: "identity.sign", source: opts.source, identity: opts.id, repo: await safeTopLevel(opts.cwd), result: "ok", message: "signing off" });
|
|
1236
1262
|
return { signing: false };
|
|
1237
1263
|
}
|
|
1238
|
-
if (!opts.id) throw Errors.usage("git colabor identity sign <id>");
|
|
1264
|
+
if (!opts.id) throw exports.Errors.usage("git colabor identity sign <id>");
|
|
1239
1265
|
const identity = await getIdentity(opts.id);
|
|
1240
1266
|
const cfg = await writeIdentitySigning(identity, opts.cwd, opts.askpassScriptPath);
|
|
1241
|
-
if (!cfg) throw Errors.usage(`identity "${identity.name}" has no usable SSH or GPG key to sign with`);
|
|
1267
|
+
if (!cfg) throw exports.Errors.usage(`identity "${identity.name}" has no usable SSH or GPG key to sign with`);
|
|
1242
1268
|
await setSignCommits(opts.id, true);
|
|
1243
1269
|
await appendAudit({
|
|
1244
1270
|
action: "identity.sign",
|
|
@@ -1280,6 +1306,14 @@ function pidIsAlive(pid) {
|
|
|
1280
1306
|
return e.code === "EPERM";
|
|
1281
1307
|
}
|
|
1282
1308
|
}
|
|
1309
|
+
var SOCKET_NAME_RE = /^askpass-[\w.-]+\.sock$/;
|
|
1310
|
+
var PIPE_RE = /^\\\\\.\\pipe\\git-colabor-askpass-[\w.-]+$/;
|
|
1311
|
+
function askpassEndpointKind(dir, endpoint, platform = process.platform) {
|
|
1312
|
+
if (typeof endpoint !== "string") return void 0;
|
|
1313
|
+
if (platform === "win32" && PIPE_RE.test(endpoint)) return "pipe";
|
|
1314
|
+
if (!SOCKET_NAME_RE.test(path.basename(endpoint))) return void 0;
|
|
1315
|
+
return path.join(dir, path.basename(endpoint)) === endpoint ? "socket" : void 0;
|
|
1316
|
+
}
|
|
1283
1317
|
function discoverSessionBridges() {
|
|
1284
1318
|
try {
|
|
1285
1319
|
const dir = dataDir();
|
|
@@ -1289,10 +1323,10 @@ function discoverSessionBridges() {
|
|
|
1289
1323
|
try {
|
|
1290
1324
|
const parsed = JSON.parse(fs.readFileSync(path.join(dir, s.f), "utf8"));
|
|
1291
1325
|
if (!parsed.socketPath || !parsed.token) continue;
|
|
1292
|
-
const
|
|
1293
|
-
const stale = parsed.pid !== void 0 && !pidIsAlive(parsed.pid) ||
|
|
1326
|
+
const kind = askpassEndpointKind(dir, parsed.socketPath);
|
|
1327
|
+
const stale = parsed.pid !== void 0 && !pidIsAlive(parsed.pid) || kind === void 0 || kind === "socket" && !fs.existsSync(parsed.socketPath);
|
|
1294
1328
|
if (stale) {
|
|
1295
|
-
if (
|
|
1329
|
+
if (kind === "socket" && fs.existsSync(parsed.socketPath)) {
|
|
1296
1330
|
try {
|
|
1297
1331
|
fs.rmSync(parsed.socketPath);
|
|
1298
1332
|
} catch {
|
|
@@ -1488,6 +1522,7 @@ async function resolveActive(cwd, opts = {}) {
|
|
|
1488
1522
|
}
|
|
1489
1523
|
|
|
1490
1524
|
// src/core/identity/logout.ts
|
|
1525
|
+
init_errors();
|
|
1491
1526
|
async function safeTopLevel3(cwd) {
|
|
1492
1527
|
try {
|
|
1493
1528
|
return await topLevel(cwd);
|
|
@@ -1501,7 +1536,7 @@ async function logoutIdentity(opts) {
|
|
|
1501
1536
|
if (!id) {
|
|
1502
1537
|
const { identities } = await listIdentities();
|
|
1503
1538
|
if (identities.length === 1) id = idOf(identities[0].name, identities[0].email);
|
|
1504
|
-
else throw Errors.usage("no active identity \u2014 specify one: git colabor identity logout <id>");
|
|
1539
|
+
else throw exports.Errors.usage("no active identity \u2014 specify one: git colabor identity logout <id>");
|
|
1505
1540
|
}
|
|
1506
1541
|
const identity = await getIdentity(id);
|
|
1507
1542
|
const binding = await getKeyBinding(id);
|
|
@@ -1571,6 +1606,9 @@ function askSocket(socketPath, token, fingerprint) {
|
|
|
1571
1606
|
}, SOCKET_TIMEOUT_MS).unref?.();
|
|
1572
1607
|
});
|
|
1573
1608
|
}
|
|
1609
|
+
|
|
1610
|
+
// src/core/secrets/bridge.ts
|
|
1611
|
+
init_errors();
|
|
1574
1612
|
async function resolvePassphrase(fingerprint, opts = {}) {
|
|
1575
1613
|
if (opts.socketPath && opts.token) {
|
|
1576
1614
|
const got = await askSocket(opts.socketPath, opts.token, fingerprint);
|
|
@@ -1579,7 +1617,7 @@ async function resolvePassphrase(fingerprint, opts = {}) {
|
|
|
1579
1617
|
if (opts.interactive && process.stdin.isTTY) {
|
|
1580
1618
|
return await promptPassphraseTty(`Passphrase for ${fingerprint}: `);
|
|
1581
1619
|
}
|
|
1582
|
-
throw Errors.secretUnavailable("no passphrase source available", [
|
|
1620
|
+
throw exports.Errors.secretUnavailable("no passphrase source available", [
|
|
1583
1621
|
"run within the VS Code extension (provides the askpass bridge)",
|
|
1584
1622
|
"load the key into ssh-agent first (ssh-add)",
|
|
1585
1623
|
"import a passphraseless key"
|
|
@@ -1601,9 +1639,9 @@ async function promptPassphraseTty(prompt) {
|
|
|
1601
1639
|
}
|
|
1602
1640
|
}
|
|
1603
1641
|
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1642
|
+
// src/index.ts
|
|
1643
|
+
init_errors();
|
|
1644
|
+
|
|
1607
1645
|
exports.addConfigValue = addConfigValue;
|
|
1608
1646
|
exports.addIdentity = addIdentity;
|
|
1609
1647
|
exports.addRedactable = addRedactable;
|