repown 0.3.0 → 0.5.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 +109 -1
- package/README.md +11 -3
- package/dist/cli.js +4 -4
- package/dist/commands/accounts.js +19 -13
- package/dist/commands/doctor.js +7 -5
- package/dist/commands/fix.js +5 -5
- package/dist/commands/guard.js +7 -5
- package/dist/commands/off.js +4 -4
- package/dist/commands/reauthor.js +64 -0
- package/dist/commands/scan.js +7 -6
- package/dist/commands/setup.js +7 -4
- package/dist/commands/start.js +6 -6
- package/dist/commands/status.js +66 -22
- package/dist/commands/use.js +14 -14
- package/dist/core/blockers.js +133 -0
- package/dist/core/config-snapshot.js +97 -0
- package/dist/core/credential/gcm.js +2 -2
- package/dist/core/credential/gh.js +12 -5
- package/dist/core/credential/repair.js +1 -1
- package/dist/core/git.js +145 -12
- package/dist/core/guard/check.js +48 -8
- package/dist/core/guard/hook.js +1 -1
- package/dist/core/hosts/github.js +11 -5
- package/dist/core/hosts/index.js +21 -3
- package/dist/core/identity.js +1 -1
- package/dist/core/inspect.js +6 -6
- package/dist/core/push-destination.js +82 -0
- package/dist/core/push-state.js +109 -0
- package/dist/core/reauthor.js +145 -0
- package/dist/core/registry.js +1 -1
- package/dist/core/unpushed.js +112 -43
- package/dist/program.js +10 -9
- package/dist/ui/args.js +3 -3
- package/dist/ui/command.js +1 -1
- package/dist/ui/dispatch.js +6 -6
- package/dist/ui/format.js +39 -0
- package/dist/ui/help.js +2 -2
- package/dist/ui/prompt.js +1 -1
- package/dist/wizard/clack.js +56 -21
- package/dist/wizard/engine.js +7 -4
- package/dist/wizard/home-context.js +23 -10
- package/dist/wizard/home-flow.js +33 -11
- package/dist/wizard/home-run.js +85 -44
- package/dist/wizard/home-text.js +14 -3
- package/dist/wizard/plain.js +2 -2
- package/dist/wizard/review-text.js +36 -14
- package/dist/wizard/setup-changes.js +11 -7
- package/dist/wizard/setup-context.js +31 -20
- package/dist/wizard/setup-flow.js +265 -56
- package/dist/wizard/setup-run.js +108 -40
- package/npm-shrinkwrap.json +378 -17
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,112 @@ commands. How a release is cut: [docs/RELEASING.md](docs/RELEASING.md).
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.5.0] - 2026-10-03
|
|
11
|
+
|
|
12
|
+
The start screen (bare `repown` outside a clone) now records and removes accounts without
|
|
13
|
+
leaving its frame, and warns before you pin a clone to someone else's GitHub account. Every
|
|
14
|
+
command repown prints for you to copy now pastes correctly in sh, bash, zsh, fish, PowerShell
|
|
15
|
+
and cmd. `status`, `doctor` and the pre-push guard are faster on Windows.
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
- **Remove an account** on the start screen: pick a recorded account, read what stays (clones
|
|
19
|
+
pinned to it keep their settings and the push guard), and confirm. It runs
|
|
20
|
+
`repown accounts remove`, and the start screen comes back without it (ADR-028).
|
|
21
|
+
- **A warning before you record someone else's GitHub account.** When gh or Git Credential
|
|
22
|
+
Manager is signed in to github.com as other accounts only, the name question in setup and on
|
|
23
|
+
the start screen says so: `signed in as octo-work, not octocat: if octocat isn't your
|
|
24
|
+
account, go back; otherwise the first push asks you to sign in as it`. A login that exists
|
|
25
|
+
can still be a stranger's, and its noreply address would link your commits to them. Nothing
|
|
26
|
+
is refused (ADR-028).
|
|
27
|
+
- `repown accounts add <login>`, when it asks, warns when github.com has no account by that
|
|
28
|
+
name (a typo) or the name is an organisation. It still records the account, and says nothing
|
|
29
|
+
when GitHub can't be asked.
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
- **Record an account on the start screen asks everything in its frame**: the login, where it
|
|
33
|
+
is hosted, and the commit name and email, prefilled from GitHub (name, noreply address), with
|
|
34
|
+
Back on each. It then runs `repown accounts add` with every answer as a flag, so the bare
|
|
35
|
+
`Commit name` / `Commit email` prompts are gone. A login already recorded is refused, and in
|
|
36
|
+
setup and on the start screen a login github.com doesn't know, or an organisation, is named
|
|
37
|
+
on the name question, so a typo can be fixed before anything is recorded.
|
|
38
|
+
- **The start screen comes back** with a fresh summary after Record an account, Remove an
|
|
39
|
+
account, Check this machine or Stop gh serving credentials. Quit, Esc or Ctrl-C leave it
|
|
40
|
+
(ADR-028).
|
|
41
|
+
- **Prefilled answers say where they came from**: `GitHub shows no name for octocat, so this
|
|
42
|
+
is the login`, and `prefilled with the private address GitHub gives octocat` instead of a
|
|
43
|
+
`1234+` example beside the real address. This machine's own identity reads `your default git
|
|
44
|
+
name here is …: use it only if this account does too`.
|
|
45
|
+
- **The wizard is easier to read in colour**, with nothing to set: the title is a cyan badge,
|
|
46
|
+
summary values are bold cyan, commands are cyan, and setup's closing line leads with a green
|
|
47
|
+
✔ (done) or a yellow ▲ (the next push will fail). On a terminal that can't draw Unicode
|
|
48
|
+
(Windows' classic console, the Linux console) the marks are `+` and `!`. Without colour (a
|
|
49
|
+
pipe, a log, `NO_COLOR`) the output is exactly as before. `repown accounts add` prints its
|
|
50
|
+
next command, `repown use <account>`, in cyan the same way (ADR-027).
|
|
51
|
+
- A question's note (this clone's current account, what the history holds, what GitHub said
|
|
52
|
+
about a login) is drawn inside that question, under its hint, instead of as a line above it
|
|
53
|
+
that read as part of the previous answer. Plain prompts already did this.
|
|
54
|
+
- Commands setup and the start screen show for you to copy start with `$ ` instead of `> `:
|
|
55
|
+
pasted whole, `>` was a redirect in every shell and left an empty file named `repown`
|
|
56
|
+
(ADR-027).
|
|
57
|
+
- **Faster on Windows:** `repown status`, `doctor`, `scan`, the pre-push guard, the start
|
|
58
|
+
screen's read of each clone and setup's first read take each git config scope in one read
|
|
59
|
+
instead of one process per key. One `repown status` in a clone went from 68 processes to 38,
|
|
60
|
+
about a third faster (ADR-029).
|
|
61
|
+
|
|
62
|
+
### Fixed
|
|
63
|
+
- **Security: pasting a command repown printed can no longer run part of it as code.** A value
|
|
64
|
+
no quoting keeps literal in every shell (`$`, a backtick, `"`, `%`, `!`, a curly double quote,
|
|
65
|
+
a control character, an escaping backslash) used to get a single-quoted command, and pasted
|
|
66
|
+
into PowerShell or cmd part of it ran. A remote's owner made of such text could do that
|
|
67
|
+
through the allow-owner advice of the guard, `status` or `use`. repown now says to add it by
|
|
68
|
+
hand, shows `[value not safe to paste]` in a command it runs itself, and prints the owner
|
|
69
|
+
with control and bidi characters escaped.
|
|
70
|
+
- **Copyable commands paste correctly in cmd and PowerShell as well as POSIX shells**: a value
|
|
71
|
+
with a space or an apostrophe is in double quotes (`--name "Octo Cat"`, on every OS), a
|
|
72
|
+
GitHub noreply address and a URL are no longer quoted, a leading `@` and a dashed word with
|
|
73
|
+
`.` or `:` are quoted (PowerShell read them as a splat, or split them), and the `--` before a
|
|
74
|
+
dashed login is `"--"` (PowerShell dropped a bare one).
|
|
75
|
+
- On a terminal that can't draw Unicode (classic Windows cmd), a text question's hint lines
|
|
76
|
+
drew a `│` beside a gutter of `|`. They now use the same bar as the rest of the frame.
|
|
77
|
+
- `type < to go back` no longer breaks across two lines; when it doesn't fit after the hint,
|
|
78
|
+
it takes a line of its own.
|
|
79
|
+
|
|
80
|
+
## [0.4.0] - 2026-09-30
|
|
81
|
+
|
|
82
|
+
### Added
|
|
83
|
+
|
|
84
|
+
- `repown reauthor [--yes]`: gives this branch's unpushed commits by another address
|
|
85
|
+
the pinned identity. It fetches the push destination first, rewrites only commits
|
|
86
|
+
no remote has (from the oldest one by another address), refuses on a merge in that
|
|
87
|
+
range, uncommitted changes, identity overrides or a destination it can't fetch,
|
|
88
|
+
runs without hooks, keeps a backup ref, prints the undo, and never pushes (ADR-026).
|
|
89
|
+
- `repown setup --repoint` and `--fetch`, which Recommended answers Yes where they
|
|
90
|
+
apply. Repoint: where the branch pushes to a URL naming the same repository as a
|
|
91
|
+
remote, setup points it back at that remote (`git config --local <key> <remote>`);
|
|
92
|
+
the URL, which can carry a token, is never printed. Fetch: where commits by another
|
|
93
|
+
address wait behind a remote never fetched, setup fetches it first (prompts off),
|
|
94
|
+
so the count and the rebase advice are right; a failed fetch is a warning (ADR-026).
|
|
95
|
+
- `repown setup --reauthor`: where unpushed commits carry another address, setup
|
|
96
|
+
asks (default No, in Recommended too) whether to re-author them as the account,
|
|
97
|
+
and runs `repown reauthor --yes` as its last step. Like `fix`, Enter at the review
|
|
98
|
+
is Decline and at the step is Skip. An already set-up clone offers **Re-author
|
|
99
|
+
them** on its first screen (ADR-026).
|
|
100
|
+
|
|
101
|
+
### Fixed
|
|
102
|
+
|
|
103
|
+
- `repown use` and setup's review no longer advise `git rebase --root` for commits a
|
|
104
|
+
never-fetched remote may already have. Where the branch's push destination has no
|
|
105
|
+
remote-tracking refs, pushes elsewhere than it fetches from, or is a URL or a name with no
|
|
106
|
+
remote, they say so, say how to fetch and count again where there is a remote to fetch,
|
|
107
|
+
and offer the rebase only for when the destination has none of those commits. The URL
|
|
108
|
+
is never printed (ADR-025).
|
|
109
|
+
- `repown setup` no longer says `done` when the next push would fail. It names what is in the way, first among the review's notes, on the already-set-up screen, and in its closing line (`set up for <account>; the next push will fail: …`): commits the guard will refuse, a sign-in in the push URL, identity or token variables, `author.email` in config, a destination owner, a diverged branch, a missing upstream, a detached HEAD (ADR-026).
|
|
110
|
+
- With the guard off, setup and status still name commits by another address, a destination owner and `GH_TOKEN`, but as a warning (`the guard is off, so …`): they no longer stop `done` or `ready` (ADR-026).
|
|
111
|
+
- `repown status` no longer says `ready` when the next push would fail. It prints what is in the way first among its warnings (`WARN push`), and ends `the next push will fail: …`; the exit code is unchanged (ADR-026).
|
|
112
|
+
- The re-author advice says `or pin that address` only when one address made them all.
|
|
113
|
+
- The suggested `git rebase` starts at the parent of the oldest commit by another address,
|
|
114
|
+
not the oldest unpushed one, so your own commits before it are never rewritten.
|
|
115
|
+
|
|
10
116
|
## [0.3.0] - 2026-09-29
|
|
11
117
|
|
|
12
118
|
### Changed
|
|
@@ -105,7 +211,9 @@ commands. How a release is cut: [docs/RELEASING.md](docs/RELEASING.md).
|
|
|
105
211
|
contract for scripts.
|
|
106
212
|
- Runs on Node 20+ on Windows, macOS and Linux, with zero runtime dependencies.
|
|
107
213
|
|
|
108
|
-
[Unreleased]: https://github.com/makubexD/repown/compare/v0.
|
|
214
|
+
[Unreleased]: https://github.com/makubexD/repown/compare/v0.5.0...HEAD
|
|
215
|
+
[0.5.0]: https://github.com/makubexD/repown/compare/v0.4.0...v0.5.0
|
|
216
|
+
[0.4.0]: https://github.com/makubexD/repown/compare/v0.3.0...v0.4.0
|
|
109
217
|
[0.3.0]: https://github.com/makubexD/repown/compare/v0.2.0...v0.3.0
|
|
110
218
|
[0.2.0]: https://github.com/makubexD/repown/compare/v0.1.1...v0.2.0
|
|
111
219
|
[0.1.1]: https://github.com/makubexD/repown/compare/v0.1.0...v0.1.1
|
package/README.md
CHANGED
|
@@ -109,11 +109,14 @@ repown # in a terminal: starts the guided setup of this clone
|
|
|
109
109
|
| Question | Recommended | Step by step | Flag |
|
|
110
110
|
| --- | --- | --- | --- |
|
|
111
111
|
| Which account should this clone belong to? | Asked. `repown setup <account>` skips the mode question and uses Recommended, so a recorded account goes straight to the review when nothing else must be asked. A new account also asks where it's hosted, the name and the email. | Asked | `<account>`, `--host`, `--name`, `--email` |
|
|
112
|
+
| Push through the remote instead of a URL? Asked when the branch pushes to a URL (which can carry its own sign-in) that names the same repository as a remote here. The review shows the key and the remote, never the URL. | Answers Yes without asking | Asked, default Yes | `--repoint` |
|
|
113
|
+
| Fetch the remote first? Asked when commits by another address wait behind a remote this clone has never fetched, so repown can count which it already has. Prompts are off; a failed fetch is a warning. | Answers Yes without asking | Asked, default Yes | `--fetch` |
|
|
112
114
|
| Let this clone push to origin's owner? Asked when origin belongs to someone else, like an organisation. | Asked, default Yes. No means the guard refuses pushes there. | Asked, default Yes | `--allow-owner <owner>` |
|
|
113
115
|
| Turn the guard on? | Answers Yes without asking | Asked | `--guard` |
|
|
114
116
|
| Push branches without -u? Only on git 2.37+. It sets `push.autoSetupRemote` in this clone only; the guard still checks that first push. | Answers Yes without asking | Asked, default Yes | `--auto-upstream` |
|
|
115
117
|
| gh. "Switch gh too" makes `gh pr create` match. | Switches without asking when gh already lists the account and the clone is not already pinned to it. A sign-in, which opens a browser, is asked, default No. Skips the question when the clone is already pinned to that account. | Asked | `--gh` |
|
|
116
118
|
| Take git's sign-ins back from gh? Machine-wide. | Asked, default No. Answer Yes if `repown doctor` said gh is the helper, or pushes from your other account's clones fail. | Asked, default No | `--fix` |
|
|
119
|
+
| Re-author your unpushed commits by another address as this account? Asked when commits you made before pinning (or an IDE made) carry another email. Only if you made them. It runs last, as `repown reauthor --yes`: it fetches first, rewrites only what no remote has, keeps a backup, and never pushes. | Asked, default No. Enter at the review is Decline when this is a step. | Asked, default No; Enter at the step is Skip | `--reauthor` |
|
|
117
120
|
|
|
118
121
|
Step by step asks every question: `--step-by-step`.
|
|
119
122
|
`--no-input` asks nothing ([scripts and CI](docs/CONFIGURATION.md#scripts-and-ci)).
|
|
@@ -196,7 +199,8 @@ with no account and no flags, and setup opens on this screen, before any questio
|
|
|
196
199
|
**Done** changes nothing. **Use another account** asks which account this clone should
|
|
197
200
|
use. When gh acts as someone else, a third option is **Sign in to gh as `<account>`** (or
|
|
198
201
|
**Make `<account>` gh's active account** when gh already lists it) and runs
|
|
199
|
-
`repown use <account> --gh`.
|
|
202
|
+
`repown use <account> --gh`. With unpushed commits by another address, **Re-author them**
|
|
203
|
+
is offered too (`repown reauthor --yes`). The upstream line shows the tracked branch (for example
|
|
200
204
|
`origin/main`) when there is one, otherwise `set on the first push (push.autoSetupRemote)`
|
|
201
205
|
when that setting is on, otherwise nothing. It is the same value `repown status` shows,
|
|
202
206
|
and `repown status` shows all of this without asking. Every screen:
|
|
@@ -213,8 +217,9 @@ then commit and push.
|
|
|
213
217
|
| | `repown fix [--dry-run] [--yes]` | undo `gh auth setup-git`, so each clone's pinned account is used; shows what it removes, and the undo, first |
|
|
214
218
|
| Once per clone | `repown setup [<account>]` | guided setup of this clone. Questions, flags and the review: [Quick start](#quick-start). A clone that is already set up opens on that screen |
|
|
215
219
|
| | `repown use <account> [--gh]` | what setup runs: pin this clone to an account. `--gh` switches gh's active account, or signs the account in to gh when needed (in a terminal). `--name` with `--email` skips the registry, the file where repown remembers accounts |
|
|
220
|
+
| | `repown reauthor [--yes]` | give this branch's unpushed commits by another address your pinned identity, so the guard lets them through. Fetches the push destination first, rewrites only what no remote has, keeps a backup ref, never pushes |
|
|
216
221
|
| | `repown guard on \| off \| status` | install, remove or show the pre-push hook (bare `repown guard` shows it) |
|
|
217
|
-
| Any time | `repown status` | this clone's and this machine's settings, and what to fix. Exits 1 on a problem; warnings alone exit 0 |
|
|
222
|
+
| Any time | `repown status` | this clone's and this machine's settings, and what to fix. It ends `ready: …`, or `the next push will fail: …` with what is in the way. Exits 1 on a problem; warnings alone exit 0 |
|
|
218
223
|
| | `repown scan [dir...] [--emails] [--depth <n>] [--format json]` | every clone under the folders (default: this one, 3 levels deep): owner, host, identity, guard, and which email domains its history has. Changes nothing |
|
|
219
224
|
| Rarely | `repown accounts list \| add \| remove` | the accounts this machine knows (bare `repown accounts` lists them; `add` takes `--name`, `--email`, `--host github\|azdo\|generic`; `list --format json` for scripts) |
|
|
220
225
|
| | `repown off` | unpin this clone, leaving global config alone; warns if the guard is still on |
|
|
@@ -230,7 +235,10 @@ then commit and push.
|
|
|
230
235
|
|
|
231
236
|
The start screen lists the accounts on this machine and the clones it found, then offers
|
|
232
237
|
the next command. The summary is in the frame. Picking a command closes the frame with
|
|
233
|
-
that command
|
|
238
|
+
that command (Record an account first asks the login, host, name and email in it; Remove
|
|
239
|
+
an account asks which, then to confirm). Nothing changes until you pick one. After
|
|
240
|
+
recording or removing an account, checking the machine or stopping gh, it comes back with
|
|
241
|
+
a fresh summary.
|
|
234
242
|
|
|
235
243
|
**Who is this clone?** `repown status` prints:
|
|
236
244
|
|
package/dist/cli.js
CHANGED
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
// can import without pulling in this file.
|
|
18
18
|
import { readFileSync } from 'node:fs';
|
|
19
19
|
import { fileURLToPath } from 'node:url';
|
|
20
|
-
import { COMMANDS } from
|
|
21
|
-
import { renderTopHelp } from
|
|
22
|
-
import { start } from
|
|
20
|
+
import { COMMANDS } from './program.js';
|
|
21
|
+
import { renderTopHelp } from './ui/help.js';
|
|
22
|
+
import { start } from './ui/dispatch.js';
|
|
23
23
|
function version() {
|
|
24
24
|
const path = fileURLToPath(new URL('../package.json', import.meta.url));
|
|
25
25
|
return JSON.parse(readFileSync(path, 'utf8')).version;
|
|
@@ -28,7 +28,7 @@ start({
|
|
|
28
28
|
name: 'repown',
|
|
29
29
|
commands: COMMANDS,
|
|
30
30
|
defaultCommand: 'status',
|
|
31
|
-
chooseDefault: () => import(
|
|
31
|
+
chooseDefault: () => import('./commands/start.js').then((mod) => mod.startDefault()),
|
|
32
32
|
topHelp: renderTopHelp,
|
|
33
33
|
version,
|
|
34
34
|
});
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
//
|
|
3
3
|
// Recording an account once is what makes `repown use <account>` a one-word command
|
|
4
4
|
// afterwards, in every repository on the machine.
|
|
5
|
-
import { loadRegistry, saveAccount, removeAccount, registryPath } from
|
|
6
|
-
import { providers } from
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
5
|
+
import { loadRegistry, saveAccount, removeAccount, registryPath } from '../core/registry.js';
|
|
6
|
+
import { lookUpProfile, providers } from '../core/hosts/index.js';
|
|
7
|
+
import { copyableCommand } from '../core/guard/check.js';
|
|
8
|
+
import { ask, interactive } from '../ui/prompt.js';
|
|
9
|
+
import { flagString, wantsJson, FORMAT_OPTION } from '../ui/args.js';
|
|
10
|
+
import * as out from '../ui/format.js';
|
|
10
11
|
async function list(args) {
|
|
11
12
|
const loaded = await loadRegistry();
|
|
12
13
|
if (!loaded.ok) {
|
|
@@ -71,18 +72,23 @@ async function add(args) {
|
|
|
71
72
|
out.fail('accounts', written.error);
|
|
72
73
|
return 1;
|
|
73
74
|
}
|
|
74
|
-
out.pass('accounts', account + ' ' + name + ' <' + email + '>');
|
|
75
|
+
out.pass('accounts', out.printable(account) + ' ' + out.printable(name) + ' <' + out.printable(email) + '>');
|
|
75
76
|
out.line();
|
|
76
|
-
out.line(' Use it in any clone:
|
|
77
|
+
out.line(' Use it in any clone: ' + out.accent(process.stdout, useCommand(account)));
|
|
77
78
|
out.line();
|
|
78
79
|
return 0;
|
|
79
80
|
}
|
|
81
|
+
/** `repown use <account>` to paste, `--` first for a dashed login; described when it can't be printed safely. */
|
|
82
|
+
function useCommand(account) {
|
|
83
|
+
const words = account.startsWith('-') ? ['repown', 'use', '--', account] : ['repown', 'use', account];
|
|
84
|
+
return copyableCommand(words) ?? 'repown use, with this account\'s name';
|
|
85
|
+
}
|
|
80
86
|
/** Best effort. A host that cannot be asked simply contributes no suggestion. */
|
|
81
87
|
async function suggestProfile(hostId, account) {
|
|
82
|
-
const
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
return
|
|
88
|
+
const found = await lookUpProfile(providers().find((candidate) => candidate.id === hostId), account);
|
|
89
|
+
if (found.problem)
|
|
90
|
+
out.warn('accounts', found.problem + ' (recording it anyway)');
|
|
91
|
+
return found.profile;
|
|
86
92
|
}
|
|
87
93
|
async function askFor(label, suggestion) {
|
|
88
94
|
const answer = await ask(label, suggestion);
|
|
@@ -100,10 +106,10 @@ async function remove(args) {
|
|
|
100
106
|
return 1;
|
|
101
107
|
}
|
|
102
108
|
if (!removed.value) {
|
|
103
|
-
out.warn('accounts', account + ' was not recorded.');
|
|
109
|
+
out.warn('accounts', out.printable(account) + ' was not recorded.');
|
|
104
110
|
return 0;
|
|
105
111
|
}
|
|
106
|
-
out.pass('accounts', 'removed ' + account);
|
|
112
|
+
out.pass('accounts', 'removed ' + out.printable(account));
|
|
107
113
|
out.line();
|
|
108
114
|
out.line(' Clones already pinned to it are unchanged -- their identity is in');
|
|
109
115
|
out.line(' their own .git/config. Unpin one with: repown off');
|
package/dist/commands/doctor.js
CHANGED
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
//
|
|
14
14
|
// Under that diagnosis, one row per account the registry, GCM or gh knows.
|
|
15
15
|
// accountRows decides the cells. A failed lookup stays `unknown`.
|
|
16
|
-
import { inspectRepo, inspectAuth, activeAccountLabel } from
|
|
17
|
-
import { loadRegistry } from
|
|
18
|
-
import { gitFor } from
|
|
19
|
-
import
|
|
16
|
+
import { inspectRepo, inspectAuth, activeAccountLabel } from '../core/inspect.js';
|
|
17
|
+
import { loadRegistry } from '../core/registry.js';
|
|
18
|
+
import { gitFor } from '../ui/args.js';
|
|
19
|
+
import { snapshotOf } from '../core/config-snapshot.js';
|
|
20
|
+
import * as out from '../ui/format.js';
|
|
20
21
|
const DOCTOR_TITLE = 'repown doctor · how this machine signs in to git hosts';
|
|
21
22
|
const NAME_WIDTH = 14;
|
|
22
23
|
const NOT_YET = 'not signed in yet (the first push signs in)';
|
|
@@ -29,7 +30,8 @@ export default {
|
|
|
29
30
|
summary: 'what serves credentials on this machine, and to whom',
|
|
30
31
|
examples: ['repown doctor'],
|
|
31
32
|
async run(args) {
|
|
32
|
-
|
|
33
|
+
// Read-only: config reads come from one list per scope (ADR-029).
|
|
34
|
+
const git = snapshotOf(gitFor(args));
|
|
33
35
|
const repo = await inspectRepo(git);
|
|
34
36
|
const auth = await inspectAuth(git, repo.originUrl ?? undefined);
|
|
35
37
|
const warned = printReport(repo, auth, await loadRegistry());
|
package/dist/commands/fix.js
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
// values and the reset gh wrote with them -- so it shows exactly what it will
|
|
6
6
|
// remove, and the undo, BEFORE asking. A change to machine-wide config should be
|
|
7
7
|
// reviewable rather than magic.
|
|
8
|
-
import { inspectAuth, storedAccountsLabel } from
|
|
9
|
-
import { planRepair, repair, describeValue } from
|
|
10
|
-
import { confirm, interactive } from
|
|
11
|
-
import { flagBool, gitFor } from
|
|
12
|
-
import * as out from
|
|
8
|
+
import { inspectAuth, storedAccountsLabel } from '../core/inspect.js';
|
|
9
|
+
import { planRepair, repair, describeValue } from '../core/credential/repair.js';
|
|
10
|
+
import { confirm, interactive } from '../ui/prompt.js';
|
|
11
|
+
import { flagBool, gitFor } from '../ui/args.js';
|
|
12
|
+
import * as out from '../ui/format.js';
|
|
13
13
|
export default {
|
|
14
14
|
summary: 'undo `gh auth setup-git` so per-repo account pins work again',
|
|
15
15
|
options: [
|
package/dist/commands/guard.js
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
// `guard check` is what the installed hook invokes, with the exact syntax baked
|
|
4
4
|
// into every hook already on disk (src/core/guard/hook.ts) -- `--remote` and
|
|
5
5
|
// `--url` on this action are a frozen contract, not just today's flags.
|
|
6
|
-
import { installGuard, uninstallGuard, guardState, fromNpxCache } from
|
|
7
|
-
import { check } from
|
|
8
|
-
import { flagString, gitFor } from
|
|
9
|
-
import
|
|
6
|
+
import { installGuard, uninstallGuard, guardState, fromNpxCache } from '../core/guard/hook.js';
|
|
7
|
+
import { check } from '../core/guard/check.js';
|
|
8
|
+
import { flagString, gitFor } from '../ui/args.js';
|
|
9
|
+
import { snapshotOf } from '../core/config-snapshot.js';
|
|
10
|
+
import * as out from '../ui/format.js';
|
|
10
11
|
/** "off" is an answer about a repository; outside one, it would be a guess. */
|
|
11
12
|
async function status(args) {
|
|
12
13
|
const git = gitFor(args);
|
|
@@ -50,7 +51,8 @@ async function disable(args) {
|
|
|
50
51
|
}
|
|
51
52
|
async function runCheck(args) {
|
|
52
53
|
const refusals = await check({
|
|
53
|
-
|
|
54
|
+
// Read-only, and on every push: config reads come from one list per scope (ADR-029).
|
|
55
|
+
git: snapshotOf(gitFor(args)),
|
|
54
56
|
remote: flagString(args, 'remote') ?? 'origin',
|
|
55
57
|
url: flagString(args, 'url') ?? '',
|
|
56
58
|
stdin: await readStdin(),
|
package/dist/commands/off.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
// this is the command you run when handing a machine back or when a clone should
|
|
5
5
|
// go back to inheriting the machine default, and it should be able to do that
|
|
6
6
|
// without being able to break anything else.
|
|
7
|
-
import { inspectRepo } from
|
|
8
|
-
import { clearIdentity, legacyAccountKey } from
|
|
9
|
-
import { gitFor } from
|
|
10
|
-
import * as out from
|
|
7
|
+
import { inspectRepo } from '../core/inspect.js';
|
|
8
|
+
import { clearIdentity, legacyAccountKey } from '../core/identity.js';
|
|
9
|
+
import { gitFor } from '../ui/args.js';
|
|
10
|
+
import * as out from '../ui/format.js';
|
|
11
11
|
export default {
|
|
12
12
|
summary: 'unpin this clone (leaves global config alone)',
|
|
13
13
|
examples: ['repown off'],
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// `repown reauthor`: give this branch's unpushed commits by another address the pinned
|
|
2
|
+
// identity, so the guard lets them through. It fetches the push destination first, rewrites
|
|
3
|
+
// only commits no remote has, keeps a backup ref, and never pushes (ADR-026).
|
|
4
|
+
import { planReauthor, applyReauthor } from '../core/reauthor.js';
|
|
5
|
+
import { confirm, interactive } from '../ui/prompt.js';
|
|
6
|
+
import { flagBool, gitFor } from '../ui/args.js';
|
|
7
|
+
import * as out from '../ui/format.js';
|
|
8
|
+
import { printable } from '../ui/format.js';
|
|
9
|
+
export default {
|
|
10
|
+
summary: 'rewrite this branch\'s unpushed commits by another address as the pinned account',
|
|
11
|
+
options: [
|
|
12
|
+
{ name: 'yes', kind: 'boolean', help: 'rewrite without asking to confirm' },
|
|
13
|
+
],
|
|
14
|
+
examples: ['repown reauthor', 'repown reauthor --yes'],
|
|
15
|
+
async run(args) {
|
|
16
|
+
const git = gitFor(args);
|
|
17
|
+
const email = await git.getConfig('user.email', 'local') ?? '';
|
|
18
|
+
out.detail('fetching the push destination first, so only what it lacks is rewritten');
|
|
19
|
+
const planned = await planReauthor(git, email, interactive());
|
|
20
|
+
if (!planned.ok) {
|
|
21
|
+
out.fail('reauthor', printable(planned.error));
|
|
22
|
+
return 1;
|
|
23
|
+
}
|
|
24
|
+
if (!planned.value) {
|
|
25
|
+
out.pass('reauthor', 'nothing to re-author: every unpushed commit here is by ' + printable(email));
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
preview(planned.value, email);
|
|
29
|
+
if (!await confirmed(args))
|
|
30
|
+
return 1;
|
|
31
|
+
return apply(git, planned.value, email);
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
function preview(plan, email) {
|
|
35
|
+
const noun = plan.count === 1 ? '1 commit' : plan.count + ' commits';
|
|
36
|
+
out.detail(noun + ' on ' + printable(plan.branch) + ' that ' + printable(plan.remote) + ' does not have will carry ' + printable(email) +
|
|
37
|
+
' (now by ' + plan.addresses.map(printable).join(', ') + ')');
|
|
38
|
+
out.detail('from ' + (plan.base === '--root' ? 'the first commit' : plan.base.slice(0, 12)) + ' on; their author dates are reset, and a backup is kept');
|
|
39
|
+
}
|
|
40
|
+
async function confirmed(args) {
|
|
41
|
+
if (flagBool(args, 'yes'))
|
|
42
|
+
return true;
|
|
43
|
+
if (!interactive()) {
|
|
44
|
+
out.fail('reauthor', 'this rewrites commits, so it needs confirmation.');
|
|
45
|
+
out.detail('re-run with --yes to proceed without being asked.');
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
if (await confirm('Rewrite these commits?'))
|
|
49
|
+
return true;
|
|
50
|
+
out.warn('reauthor', 'declined; nothing was changed.');
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
async function apply(git, plan, email) {
|
|
54
|
+
const done = await applyReauthor(git, plan, email);
|
|
55
|
+
if (!done.ok) {
|
|
56
|
+
out.fail('reauthor', printable(done.error));
|
|
57
|
+
return 1;
|
|
58
|
+
}
|
|
59
|
+
const noun = done.value.count === 1 ? '1 commit' : done.value.count + ' commits';
|
|
60
|
+
out.pass('reauthor', noun + ' now by ' + printable(email));
|
|
61
|
+
out.detail('undo: git reset --keep ' + printable(done.value.backup) + ' (drops commits made since)');
|
|
62
|
+
out.detail('nothing was pushed: git push when you are ready');
|
|
63
|
+
return 0;
|
|
64
|
+
}
|
package/dist/commands/scan.js
CHANGED
|
@@ -18,11 +18,12 @@
|
|
|
18
18
|
import { readdir } from 'node:fs/promises';
|
|
19
19
|
import { join, relative, resolve, sep } from 'node:path';
|
|
20
20
|
import { existsSync, statSync } from 'node:fs';
|
|
21
|
-
import { Git } from
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import
|
|
21
|
+
import { Git } from '../core/git.js';
|
|
22
|
+
import { snapshotOf } from '../core/config-snapshot.js';
|
|
23
|
+
import { inspectRepo } from '../core/inspect.js';
|
|
24
|
+
import { ok, err } from '../core/result.js';
|
|
25
|
+
import { flagBool, flagString, wantsJson, FORMAT_OPTION } from '../ui/args.js';
|
|
26
|
+
import * as out from '../ui/format.js';
|
|
26
27
|
export default {
|
|
27
28
|
summary: 'audit every clone under a directory',
|
|
28
29
|
positionals: { min: 0, max: Infinity, label: '<dir>' },
|
|
@@ -133,7 +134,7 @@ function childAt(root, path) {
|
|
|
133
134
|
* in different folders are told apart instead of printed as one name twice.
|
|
134
135
|
*/
|
|
135
136
|
async function describe(found, showEmails) {
|
|
136
|
-
const git = new Git(found.path);
|
|
137
|
+
const git = snapshotOf(new Git(found.path));
|
|
137
138
|
const repo = await inspectRepo(git);
|
|
138
139
|
const configured = await git.getConfig('repown.mirrorBranch', 'local');
|
|
139
140
|
const mirror = configured && await git.hasCommit('refs/heads/' + configured) ? configured : null;
|
package/dist/commands/setup.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
// how it should work: Recommended fills in the guard, upstream and a gh switch, and
|
|
3
3
|
// still asks when origin belongs to someone else. Step by step asks each one.
|
|
4
4
|
// It shows the commands its answers stand for, and runs exactly those --
|
|
5
|
-
// `accounts add`, `use`, `guard on`, `fix` -- so anything it
|
|
5
|
+
// `accounts add`, `use`, `guard on`, `fix`, `reauthor`, and a few git lines -- so anything it
|
|
6
6
|
// does can be done, or scripted, without it (src/wizard/setup-run.ts).
|
|
7
|
-
import { providers } from
|
|
8
|
-
import { interactive } from
|
|
9
|
-
import { runSetup } from
|
|
7
|
+
import { providers } from '../core/hosts/index.js';
|
|
8
|
+
import { interactive } from '../ui/prompt.js';
|
|
9
|
+
import { runSetup } from '../wizard/setup-run.js';
|
|
10
10
|
export default {
|
|
11
11
|
summary: 'guided setup of this clone: asks, shows each step and its command, then runs them',
|
|
12
12
|
positionals: { min: 0, max: 1, label: '<account>' },
|
|
@@ -19,6 +19,9 @@ export default {
|
|
|
19
19
|
{ name: 'guard', kind: 'boolean', help: 'turn the push guard on (guard on)' },
|
|
20
20
|
{ name: 'auto-upstream', kind: 'boolean', help: 'push branches without -u: the first push sets the upstream, in this clone only (push.autoSetupRemote)' },
|
|
21
21
|
{ name: 'fix', kind: 'boolean', help: 'stop gh being the credential helper, where it is (fix --yes)' },
|
|
22
|
+
{ name: 'repoint', kind: 'boolean', help: 'where the branch pushes to a URL naming the same repository as a remote, push through that remote instead (git config --local)' },
|
|
23
|
+
{ name: 'fetch', kind: 'boolean', help: 'fetch the push destination first, where commits by another address wait behind a remote never fetched (prompts off)' },
|
|
24
|
+
{ name: 'reauthor', kind: 'boolean', help: 'rewrite this branch\'s unpushed commits by another address as the account, last (reauthor --yes)' },
|
|
22
25
|
{ name: 'step-by-step', kind: 'boolean', help: 'ask every question instead of the recommended answers (not with --no-input)' },
|
|
23
26
|
{ name: 'no-input', kind: 'boolean', help: 'ask nothing: a question not given as a flag is No; exit 2 if the account is incomplete' },
|
|
24
27
|
],
|
package/dist/commands/start.js
CHANGED
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
// outside a clone, including a bare repository, open the start screen: a
|
|
8
8
|
// runner too. With stdout redirected outside a clone, the top help.
|
|
9
9
|
// Everything else is status.
|
|
10
|
-
import { Git } from
|
|
11
|
-
import { inspectRepo } from
|
|
12
|
-
import { identityProblems } from
|
|
13
|
-
import { interactive } from
|
|
10
|
+
import { Git } from '../core/git.js';
|
|
11
|
+
import { inspectRepo } from '../core/inspect.js';
|
|
12
|
+
import { identityProblems } from './status.js';
|
|
13
|
+
import { interactive } from '../ui/prompt.js';
|
|
14
14
|
export const SETUP_NOTE = 'This clone isn\'t set up yet, so repown is starting setup (repown status shows its settings).';
|
|
15
15
|
export const PINNED_NOTE = 'Starting setup to check this clone (repown status shows its settings without asking anything).';
|
|
16
16
|
/** Setup, status, the start screen, or the top help. No output. */
|
|
@@ -27,11 +27,11 @@ export async function startDefault(deps = realDeps()) {
|
|
|
27
27
|
return pick.choice;
|
|
28
28
|
}
|
|
29
29
|
function startHome() {
|
|
30
|
-
return import(
|
|
30
|
+
return import('../wizard/home-run.js').then((mod) => mod.runHome());
|
|
31
31
|
}
|
|
32
32
|
function startSetup(pinned) {
|
|
33
33
|
const lead = pinned ? PINNED_NOTE : SETUP_NOTE;
|
|
34
|
-
return import(
|
|
34
|
+
return import('../wizard/setup-run.js').then((mod) => mod.runSetup(bareArgs(), { interactive: true, lead }));
|
|
35
35
|
}
|
|
36
36
|
function bareArgs() {
|
|
37
37
|
return { positional: [], flags: new Map() };
|