git-colabor 0.1.4 → 0.1.6
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 +15 -14
- package/dist/cli.cjs +18 -3
- package/dist/index.cjs +12 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# git-colabor
|
|
2
2
|
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="assets/images/git-co-author-enhanced.png" width="140" alt="Git Colabor logo" />
|
|
5
|
+
</p>
|
|
6
|
+
|
|
3
7
|
**`git colabor`** — switch the Git **committer + pusher identity** and **SSH key** per repository, and manage **co-authors** with a better experience, from one CLI.
|
|
4
8
|
|
|
5
9
|
This is the CLI half of Git Colabor. A VS Code extension ([`vscode-git-colabor`](https://github.com/hnrobert/vscode-git-colabor)) bundles this binary and drives it over its `--json` interface — but the CLI is fully standalone and scriptable.
|
|
@@ -24,7 +28,7 @@ You share a machine — a lab workstation, a pair-programming box, a Remote-SSH
|
|
|
24
28
|
Requires **Node.js >= 24**.
|
|
25
29
|
|
|
26
30
|
```bash
|
|
27
|
-
npm install -g git-colabor
|
|
31
|
+
npm install -g git-colabor
|
|
28
32
|
# or from source:
|
|
29
33
|
git clone git@github.com:hnrobert/git-colabor.git && cd git-colabor
|
|
30
34
|
pnpm install && pnpm build && npm link
|
|
@@ -43,14 +47,14 @@ git colabor identity add --name "Robert" --email me@personal.io \
|
|
|
43
47
|
# 2. Use one in the current repo
|
|
44
48
|
git colabor identity use id_a1b2c3d4 # from `identity ls`
|
|
45
49
|
|
|
46
|
-
# 3. Pairing: add a co-author
|
|
47
|
-
git colabor coauthor add
|
|
48
|
-
git colabor coauthor
|
|
50
|
+
# 3. Pairing: add a co-author (must exist as an identity)
|
|
51
|
+
git colabor coauthor add jamie@example.com # next commit only
|
|
52
|
+
git colabor coauthor add jamie@example.com --always # every commit in this repo
|
|
49
53
|
|
|
50
54
|
git commit # Co-authored-by: trailer included
|
|
51
55
|
|
|
52
56
|
# 4. Done pairing / leaving the repo
|
|
53
|
-
git colabor coauthor
|
|
57
|
+
git colabor coauthor rm jamie@example.com
|
|
54
58
|
git colabor identity revert # restore pre-tool git config
|
|
55
59
|
```
|
|
56
60
|
|
|
@@ -60,11 +64,10 @@ git colabor identity revert # restore pre-tool git config
|
|
|
60
64
|
|
|
61
65
|
| Command | Effect |
|
|
62
66
|
| --- | --- |
|
|
63
|
-
| `coauthor
|
|
64
|
-
| `coauthor
|
|
65
|
-
| `coauthor
|
|
66
|
-
| `coauthor print
|
|
67
|
-
| `coauthor add <key> "Name" <email>` | Add to `.git-coauthors`. |
|
|
67
|
+
| `coauthor add <email\|id> [--always] [--global]` | Add a co-author: one-shot (next commit), `--always` (every commit in this repo), `--global` (every repo). The person must exist as an identity. |
|
|
68
|
+
| `coauthor rm <email\|id>` | Remove a co-author from every scope it is active in. |
|
|
69
|
+
| `coauthor ls [filter]` | Active co-authors + available candidates (identities minus the active one); optional substring filter. |
|
|
70
|
+
| `coauthor print` | Print the `Co-authored-by:` trailer blob for the current selection. |
|
|
68
71
|
| `coauthor suggest [filter]` | Suggest co-authors from `git shortlog` history; interactive pick without `--json`. |
|
|
69
72
|
|
|
70
73
|
Selecting co-authors rewrites the commit template (`commit.template` / `~/.gitmessage`): all existing `Co-authored-by:` trailers are stripped and the current selection re-appended — the same behavior as git-mob's message formatter.
|
|
@@ -125,7 +128,6 @@ This is the contract the VS Code extension consumes.
|
|
|
125
128
|
| `~/.config/git-colabor/identities.json` | Identity map (referenced key paths + fingerprints; env `GIT_COLABOR_MAP`) | `0600` |
|
|
126
129
|
| `~/.config/git-colabor/audit.log` | JSONL audit trail | `0600` |
|
|
127
130
|
| `<git-dir>/colabor/state.json` | Per-repo state: active identity, `heldBy`, opt-in signing flag, config backups | `0600` |
|
|
128
|
-
| `.git-coauthors` (repo, else `~/.git-coauthors`) | Co-author catalogue, git-mob-compatible JSON | — |
|
|
129
131
|
| `~/.gitmessage` (or `commit.template`) | Commit template seeded with trailers | — |
|
|
130
132
|
|
|
131
133
|
(Windows: the data dir is `%APPDATA%\git-colabor`.)
|
|
@@ -134,8 +136,8 @@ Git config keys **written locally** per repo: `user.name`, `user.email`, `core.s
|
|
|
134
136
|
|
|
135
137
|
## git-mob compatibility
|
|
136
138
|
|
|
137
|
-
- Same
|
|
138
|
-
-
|
|
139
|
+
- Same trailer format `Co-authored-by: NAME <EMAIL>` and the same template-rewrite semantics (strip existing trailers, re-append the current selection).
|
|
140
|
+
- Co-author candidates come from **identities**, not `.git-coauthors` — the catalogue file plays no role.
|
|
139
141
|
- Does **not** read or write git-mob's `git-mob.co-author` config — the two tools can coexist.
|
|
140
142
|
|
|
141
143
|
## Security notes
|
|
@@ -152,7 +154,6 @@ Full threat model: [docs/SECURITY.md](../docs/SECURITY.md) in the extension repo
|
|
|
152
154
|
| --- | --- |
|
|
153
155
|
| `GIT_COLABOR_MAP` | identity map path |
|
|
154
156
|
| `GIT_COLABOR_AUDIT_FILE` | audit log path |
|
|
155
|
-
| `GIT_COLABOR_COAUTHORS_PATH` | `.git-coauthors` path |
|
|
156
157
|
| `GIT_COLABOR_MESSAGE_PATH` | commit template path |
|
|
157
158
|
| `GIT_COLABOR_LOG_FILE` / `GIT_COLABOR_LOG_LEVEL` | CLI debug log |
|
|
158
159
|
| `GIT_COLABOR_ASKPASS_SOCK` / `GIT_COLABOR_ASKPASS_TOKEN` | askpass bridge endpoint (set by the extension) |
|
package/dist/cli.cjs
CHANGED
|
@@ -743,7 +743,7 @@ function isStale(heldBy, staleMinutes) {
|
|
|
743
743
|
const ageMs = Date.now() - new Date(heldBy.since).getTime();
|
|
744
744
|
return ageMs > staleMinutes * 6e4;
|
|
745
745
|
}
|
|
746
|
-
async function detectConflict(session, cwd, staleMinutes =
|
|
746
|
+
async function detectConflict(session, cwd, staleMinutes = Infinity) {
|
|
747
747
|
const st = await readState(cwd);
|
|
748
748
|
const hb = st.heldBy;
|
|
749
749
|
if (!hb || hb.session === session) return null;
|
|
@@ -1050,7 +1050,11 @@ async function applyResolvedIdentity(args) {
|
|
|
1050
1050
|
await captureBackupIfFirstTouch(opts.cwd);
|
|
1051
1051
|
await setConfig("user.name", name, "local", opts.cwd);
|
|
1052
1052
|
await setConfig("user.email", email, "local", opts.cwd);
|
|
1053
|
-
if (sshCommand)
|
|
1053
|
+
if (sshCommand) {
|
|
1054
|
+
await setConfig("core.sshCommand", sshCommand, "local", opts.cwd);
|
|
1055
|
+
} else if (identity && !identity.sshKeyPath) {
|
|
1056
|
+
await unsetConfig("core.sshCommand", "local", opts.cwd);
|
|
1057
|
+
}
|
|
1054
1058
|
await setConfig("colabor.managed", "true", "local", opts.cwd);
|
|
1055
1059
|
await setConfig("colabor.managed-by", opts.source, "local", opts.cwd);
|
|
1056
1060
|
const state = await readState(opts.cwd);
|
|
@@ -1065,6 +1069,12 @@ async function applyResolvedIdentity(args) {
|
|
|
1065
1069
|
if (opts.askpassScriptPath) {
|
|
1066
1070
|
await setConfig("gpg.ssh.program", await ensureSignWrapper(opts.askpassScriptPath), "local", opts.cwd);
|
|
1067
1071
|
}
|
|
1072
|
+
} else if (state.signing === true && identity && !identity.sshKeyPath) {
|
|
1073
|
+
state.signing = false;
|
|
1074
|
+
await unsetConfig("commit.gpgsign", "local", opts.cwd);
|
|
1075
|
+
await unsetConfig("gpg.format", "local", opts.cwd);
|
|
1076
|
+
await unsetConfig("user.signingKey", "local", opts.cwd);
|
|
1077
|
+
await unsetConfig("gpg.ssh.program", "local", opts.cwd);
|
|
1068
1078
|
}
|
|
1069
1079
|
await writeState(state, opts.cwd);
|
|
1070
1080
|
let agent;
|
|
@@ -1274,7 +1284,7 @@ function toBrief(a) {
|
|
|
1274
1284
|
}
|
|
1275
1285
|
|
|
1276
1286
|
// src/cli/identity.ts
|
|
1277
|
-
var USE_SPEC = { valueFlags: ["--source", "--as-name", "--as-email"], boolFlags: ["--no-override"] };
|
|
1287
|
+
var USE_SPEC = { valueFlags: ["--source", "--as-name", "--as-email", "--stale-minutes"], boolFlags: ["--no-override"] };
|
|
1278
1288
|
var ADD_SPEC = {
|
|
1279
1289
|
valueFlags: ["--name", "--email", "--key", "--host", "--source"],
|
|
1280
1290
|
boolFlags: ["--default", "--no-encrypt"]
|
|
@@ -1437,6 +1447,10 @@ async function agentKey(p, ctx) {
|
|
|
1437
1447
|
async function use(p, ctx) {
|
|
1438
1448
|
const id = p.positionals[0];
|
|
1439
1449
|
if (!id) throw Errors.usage("git colabor identity use <id>");
|
|
1450
|
+
const staleRaw = p.values["--stale-minutes"];
|
|
1451
|
+
if (staleRaw !== void 0 && !Number.isFinite(Number(staleRaw))) {
|
|
1452
|
+
throw Errors.usage(`--stale-minutes must be a number, got "${staleRaw}"`);
|
|
1453
|
+
}
|
|
1440
1454
|
const current = await getIdentity(id);
|
|
1441
1455
|
if (current.disabled) await updateIdentity(id, { disabled: void 0 });
|
|
1442
1456
|
const { identity, result } = await applyIdentity(id, {
|
|
@@ -1445,6 +1459,7 @@ async function use(p, ctx) {
|
|
|
1445
1459
|
asName: p.values["--as-name"],
|
|
1446
1460
|
asEmail: p.values["--as-email"],
|
|
1447
1461
|
noOverride: p.bools.has("--no-override"),
|
|
1462
|
+
staleMinutes: staleRaw ? Number(staleRaw) : void 0,
|
|
1448
1463
|
askpassScriptPath: ctx.askpassScriptPath,
|
|
1449
1464
|
socketPath: ctx.socketPath,
|
|
1450
1465
|
token: ctx.token
|
package/dist/index.cjs
CHANGED
|
@@ -447,7 +447,7 @@ function isStale(heldBy, staleMinutes) {
|
|
|
447
447
|
const ageMs = Date.now() - new Date(heldBy.since).getTime();
|
|
448
448
|
return ageMs > staleMinutes * 6e4;
|
|
449
449
|
}
|
|
450
|
-
async function detectConflict(session, cwd, staleMinutes =
|
|
450
|
+
async function detectConflict(session, cwd, staleMinutes = Infinity) {
|
|
451
451
|
const st = await readState(cwd);
|
|
452
452
|
const hb = st.heldBy;
|
|
453
453
|
if (!hb || hb.session === session) return null;
|
|
@@ -929,7 +929,11 @@ async function applyResolvedIdentity(args) {
|
|
|
929
929
|
await captureBackupIfFirstTouch(opts.cwd);
|
|
930
930
|
await setConfig("user.name", name, "local", opts.cwd);
|
|
931
931
|
await setConfig("user.email", email, "local", opts.cwd);
|
|
932
|
-
if (sshCommand)
|
|
932
|
+
if (sshCommand) {
|
|
933
|
+
await setConfig("core.sshCommand", sshCommand, "local", opts.cwd);
|
|
934
|
+
} else if (identity && !identity.sshKeyPath) {
|
|
935
|
+
await unsetConfig("core.sshCommand", "local", opts.cwd);
|
|
936
|
+
}
|
|
933
937
|
await setConfig("colabor.managed", "true", "local", opts.cwd);
|
|
934
938
|
await setConfig("colabor.managed-by", opts.source, "local", opts.cwd);
|
|
935
939
|
const state = await readState(opts.cwd);
|
|
@@ -944,6 +948,12 @@ async function applyResolvedIdentity(args) {
|
|
|
944
948
|
if (opts.askpassScriptPath) {
|
|
945
949
|
await setConfig("gpg.ssh.program", await ensureSignWrapper(opts.askpassScriptPath), "local", opts.cwd);
|
|
946
950
|
}
|
|
951
|
+
} else if (state.signing === true && identity && !identity.sshKeyPath) {
|
|
952
|
+
state.signing = false;
|
|
953
|
+
await unsetConfig("commit.gpgsign", "local", opts.cwd);
|
|
954
|
+
await unsetConfig("gpg.format", "local", opts.cwd);
|
|
955
|
+
await unsetConfig("user.signingKey", "local", opts.cwd);
|
|
956
|
+
await unsetConfig("gpg.ssh.program", "local", opts.cwd);
|
|
947
957
|
}
|
|
948
958
|
await writeState(state, opts.cwd);
|
|
949
959
|
let agent;
|