repown 0.5.1 → 0.5.2
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 +71 -1
- package/README.md +4 -1
- package/dist/commands/accounts.js +42 -4
- package/dist/commands/doctor.js +63 -31
- package/dist/commands/off.js +11 -3
- package/dist/commands/start.js +19 -2
- package/dist/commands/status.js +16 -14
- package/dist/commands/use.js +10 -7
- package/dist/core/blockers.js +4 -2
- package/dist/core/config-snapshot.js +7 -0
- package/dist/core/credential/gh.js +25 -14
- package/dist/core/exec.js +57 -6
- package/dist/core/git.js +100 -17
- package/dist/core/guard/check.js +1 -26
- package/dist/core/hosts/github.js +21 -3
- package/dist/core/hosts/index.js +3 -1
- package/dist/core/inspect.js +42 -15
- package/dist/core/push-destination.js +55 -15
- package/dist/core/push-state.js +2 -2
- package/dist/core/reauthor.js +37 -10
- package/dist/core/refspec.js +45 -0
- package/dist/core/shell.js +32 -0
- package/dist/core/unpushed.js +10 -9
- package/dist/ui/format.js +11 -0
- package/dist/ui/help.js +2 -1
- package/dist/wizard/home-context.js +7 -6
- package/dist/wizard/home-run.js +7 -6
- package/dist/wizard/review-text.js +4 -3
- package/dist/wizard/setup-context.js +5 -5
- package/dist/wizard/setup-flow.js +13 -9
- package/dist/wizard/setup-run.js +3 -2
- package/npm-shrinkwrap.json +6 -6
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,75 @@ commands. How a release is cut: [docs/RELEASING.md](docs/RELEASING.md).
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.5.2] - 2026-10-10
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- In Git Bash's mintty without ConPTY, bare `repown` showed status with no word on why the start
|
|
14
|
+
screen or setup never opened. It now notes on stderr that `winpty repown` asks: setup in a
|
|
15
|
+
clone, the start screen outside one.
|
|
16
|
+
- Setup's and the start screen's text wrapped by character count, so a line holding
|
|
17
|
+
Chinese, Japanese or Korean characters, or emoji, ran past the frame. It now wraps by the
|
|
18
|
+
columns a terminal draws.
|
|
19
|
+
- Typed `repown accounts add` recorded a login setup refuses, overwrote or doubled one already
|
|
20
|
+
recorded, and never said whom this machine is signed in as, all silently. It now warns for each
|
|
21
|
+
(`so setup would not take it (recording it anyway)`, `is already recorded: this replaces its
|
|
22
|
+
name and email`, `signed in as octo-work, not octocat: …`) and still records. A question cancelled
|
|
23
|
+
records nothing and warns of nothing.
|
|
24
|
+
- `repown status` said nothing about a push destination owned by someone else when origin's
|
|
25
|
+
own owner already had a warning, though the destination was another remote (a
|
|
26
|
+
`pushRemote` fork): both are now said. Setup's fetch step says `prompts off: a sign-in that
|
|
27
|
+
would ask fails instead`, as it runs.
|
|
28
|
+
- A timed-out `git fetch`, `ls-remote` or `reauthor` rebase was reported only when it finished
|
|
29
|
+
on its own: on Windows the `git` on PATH is often a wrapper whose real git kept running (and
|
|
30
|
+
holding the clone's locks) after repown killed the wrapper. A timeout now ends the whole
|
|
31
|
+
process tree on Windows and is reported within seconds everywhere.
|
|
32
|
+
- A remote whose name starts with `-` (set by hand in config) could not be fetched by
|
|
33
|
+
`reauthor` or setup, and the advice printed no command for it. git now gets `--` before the
|
|
34
|
+
name, and printed commands read `git fetch "--" <remote>` and `git push -u "--" <remote>
|
|
35
|
+
<branch>`.
|
|
36
|
+
- `repown use` printed `push-as:<account>` where it pins no credential (SSH, Azure DevOps,
|
|
37
|
+
another host, no remote). The `identity` line now ends at the address there, and the
|
|
38
|
+
warning reads `credentials on GitHub are not pinned by repown.` (`on this host` for another
|
|
39
|
+
host) instead of `this host credentials are not pinned by repown.`
|
|
40
|
+
- The credential pin followed origin's URL as written. A clone that fetches over SSH and
|
|
41
|
+
pushes over https (a `pushurl` or `pushInsteadOf`) is now pinned, and `repown setup` no
|
|
42
|
+
longer offers `use` again there; a clone whose https URL an `insteadOf` sends over SSH is no
|
|
43
|
+
longer reported as pinned (`status` says `not pinned by repown on GitHub`). The credential
|
|
44
|
+
helper `status`, `use`, `doctor` and setup check is the one serving the URL the pin is for,
|
|
45
|
+
and `repown off` also removes the key of origin's URLs as configured.
|
|
46
|
+
- In a clone that fetches only some branches (`git clone --single-branch`, `--depth`, or a
|
|
47
|
+
`^refs/heads/<branch>` refspec), a branch pushed from it gets no remote-tracking ref, yet
|
|
48
|
+
`repown use`, setup and status offered the plain `git rebase` over commits that push had
|
|
49
|
+
published. They now say `origin's <branch> is not fetched here (remote.origin.fetch leaves
|
|
50
|
+
it out), so some of these may already be there` and offer the rebase only for the case where
|
|
51
|
+
origin has none of them. Tracking refs are also looked for where the remote's own refspecs
|
|
52
|
+
write them, so a remote fetching into another namespace no longer reads as never fetched.
|
|
53
|
+
- `repown reauthor` rewrote commits the destination already had when the clone fetches only
|
|
54
|
+
some branches or a tag had been pushed, so the next push was refused as non-fast-forward. It
|
|
55
|
+
now asks the destination which branches and tags it has, leaves alone what they reach, and
|
|
56
|
+
refuses when a branch there was never fetched here: `origin has commits this clone has not
|
|
57
|
+
fetched (…)`. It now runs in a single-branch clone, where it refused before. A push that
|
|
58
|
+
`pushInsteadOf` or a second `url` sends elsewhere is refused, and `repown use`, setup and
|
|
59
|
+
status make their rebase conditional for it, as they already did for a `pushurl`.
|
|
60
|
+
- `repown reauthor` refused in every sparse checkout (`uncommitted changes (or files hidden with
|
|
61
|
+
skip-worktree)`), since sparse-checkout marks the files it leaves out that way. Those files no
|
|
62
|
+
longer count; a skip-worktree file that is on disk, or an assume-unchanged one, still refuses.
|
|
63
|
+
Run from a subfolder, it saw only that folder's hidden files; it now checks the whole clone.
|
|
64
|
+
- `repown use` no longer says `No stored credential … the first push signs in` or `gh is still
|
|
65
|
+
the git credential helper, so this pin is not honoured` in a clone where it pins no credential
|
|
66
|
+
(an SSH remote, Azure DevOps, another host): pushes there use that host's own sign-in. Setup
|
|
67
|
+
already said nothing there.
|
|
68
|
+
- `repown doctor` in a clone repown pins no credential for (SSH, Azure DevOps, another host)
|
|
69
|
+
diagnosed that host's helper in words about github.com and per-clone sign-in. It now opens
|
|
70
|
+
with a `This clone` section (why origin gets no pin, and the helper serving it, with no
|
|
71
|
+
verdict), then reports on the machine for github.com, as it does outside a clone: no row is
|
|
72
|
+
marked `(this clone)`, and a passing verdict starts `for github.com, `. So gh serving
|
|
73
|
+
github.com now fails there too (exit 1), as it does outside a clone. Helper names and gh's
|
|
74
|
+
active login are drawn escaped.
|
|
75
|
+
- `repown --help` lists exit code 130 (setup or the start screen cancelled), describes
|
|
76
|
+
`accounts` as list, record or forget, and `accounts add` says that on GitHub the name and
|
|
77
|
+
email are suggested from the profile through gh.
|
|
78
|
+
|
|
10
79
|
## [0.5.1] - 2026-10-03
|
|
11
80
|
|
|
12
81
|
A safety release: account lookups can no longer borrow another account's profile, the start
|
|
@@ -237,7 +306,8 @@ and cmd. `status`, `doctor` and the pre-push guard are faster on Windows.
|
|
|
237
306
|
contract for scripts.
|
|
238
307
|
- Runs on Node 20+ on Windows, macOS and Linux, with zero runtime dependencies.
|
|
239
308
|
|
|
240
|
-
[Unreleased]: https://github.com/makubexD/repown/compare/v0.5.
|
|
309
|
+
[Unreleased]: https://github.com/makubexD/repown/compare/v0.5.2...HEAD
|
|
310
|
+
[0.5.2]: https://github.com/makubexD/repown/compare/v0.5.1...v0.5.2
|
|
241
311
|
[0.5.1]: https://github.com/makubexD/repown/compare/v0.5.0...v0.5.1
|
|
242
312
|
[0.5.0]: https://github.com/makubexD/repown/compare/v0.4.0...v0.5.0
|
|
243
313
|
[0.4.0]: https://github.com/makubexD/repown/compare/v0.3.0...v0.4.0
|
package/README.md
CHANGED
|
@@ -280,7 +280,7 @@ note, not a warning. Every warning it can print:
|
|
|
280
280
|
|
|
281
281
|
| Command | 0 | 1 | 2 | Other |
|
|
282
282
|
| --- | --- | --- | --- | --- |
|
|
283
|
-
| In general | Success | Failure or refusal | Usage error | |
|
|
283
|
+
| In general | Success | Failure or refusal | Usage error | 130 when setup or the start screen is cancelled |
|
|
284
284
|
| `repown scan` | Whatever it finds (read its output or JSON) | | A missing folder or a bad `--depth` | |
|
|
285
285
|
| `repown setup` | Done, or already set up | Decline, or it can't start | Flags that don't fit, or no terminal without `--no-input` | 130 when cancelled or interrupted; a failing step's own code |
|
|
286
286
|
| `repown status` | Success. Warnings alone exit 0 | A problem | | |
|
|
@@ -337,6 +337,9 @@ The same commands `repown setup` runs, if you'd rather type them:
|
|
|
337
337
|
([card 3](docs/HOW-IT-WORKS.md#3-pin-a-clone)). If the repository belongs to another
|
|
338
338
|
owner, such as an organisation, `use` prints the line that allows it.
|
|
339
339
|
|
|
340
|
+
In a GitHub clone over https (elsewhere the `identity` line has no `push-as:`, and `use` says
|
|
341
|
+
repown pins no credential there):
|
|
342
|
+
|
|
340
343
|
```
|
|
341
344
|
$ cd ~/code/dotfiles
|
|
342
345
|
$ repown use octocat
|
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
// afterwards, in every repository on the machine.
|
|
5
5
|
import { loadRegistry, saveAccount, removeAccount, registryPath } from '../core/registry.js';
|
|
6
6
|
import { lookUpProfile, providers } from '../core/hosts/index.js';
|
|
7
|
-
import { copyableCommand } from '../core/
|
|
7
|
+
import { copyableCommand } from '../core/shell.js';
|
|
8
8
|
import { ask, interactive } from '../ui/prompt.js';
|
|
9
|
-
import { flagString, wantsJson, FORMAT_OPTION } from '../ui/args.js';
|
|
9
|
+
import { flagBool, flagString, wantsJson, FORMAT_OPTION } from '../ui/args.js';
|
|
10
|
+
import { loginProblem, signedInNote } from '../wizard/setup-flow.js';
|
|
11
|
+
import { readSignedIn } from '../wizard/home-context.js';
|
|
10
12
|
import * as out from '../ui/format.js';
|
|
11
13
|
async function list(args) {
|
|
12
14
|
const loaded = await loadRegistry();
|
|
@@ -67,6 +69,9 @@ async function add(args) {
|
|
|
67
69
|
const email = flagString(args, 'email') ?? await askFor('Commit email', suggested.email);
|
|
68
70
|
if (email === null)
|
|
69
71
|
return 1;
|
|
72
|
+
// After the questions: a cancelled one records nothing, so nothing says "recording it anyway".
|
|
73
|
+
if (!flagBool(args, ASKED))
|
|
74
|
+
await warnLogin(account, hostId);
|
|
70
75
|
const written = await saveAccount(account, { name, email, host: hostId });
|
|
71
76
|
if (!written.ok) {
|
|
72
77
|
out.fail('accounts', out.printable(written.error));
|
|
@@ -78,6 +83,39 @@ async function add(args) {
|
|
|
78
83
|
out.line();
|
|
79
84
|
return 0;
|
|
80
85
|
}
|
|
86
|
+
/** Set by setup and the start screen, which said what warnLogin says while asking. Not an option, so argv can't set it. */
|
|
87
|
+
export const ASKED = 'asked';
|
|
88
|
+
/** The same arguments, marked as already asked (ASKED). */
|
|
89
|
+
export function asked(args) {
|
|
90
|
+
return { ...args, flags: new Map([...args.flags, [ASKED, true]]) };
|
|
91
|
+
}
|
|
92
|
+
/** What setup says while asking, said for a typed login: warnings only, it is still recorded (WIZ-10). */
|
|
93
|
+
async function warnLogin(account, hostId) {
|
|
94
|
+
const shown = out.printable(account);
|
|
95
|
+
const problem = loginProblem(account);
|
|
96
|
+
if (problem)
|
|
97
|
+
out.warn('accounts', '"' + shown + '": ' + problem + ', so setup would not take it (recording it anyway)');
|
|
98
|
+
const clash = await recordedClash(account);
|
|
99
|
+
if (clash)
|
|
100
|
+
out.warn('accounts', clash);
|
|
101
|
+
const note = hostId === 'github' ? signedInNote(account, await readSignedIn(process.cwd()), removeCommand(account)) : null;
|
|
102
|
+
if (note)
|
|
103
|
+
out.warn('accounts', note);
|
|
104
|
+
}
|
|
105
|
+
/** A recorded login spelt the same, any case: this replaces it, or sits beside it. */
|
|
106
|
+
async function recordedClash(account) {
|
|
107
|
+
const loaded = await loadRegistry();
|
|
108
|
+
const same = loaded.ok ? Object.keys(loaded.value.accounts).find((key) => key.toLowerCase() === account.toLowerCase()) : undefined;
|
|
109
|
+
if (same === undefined)
|
|
110
|
+
return null;
|
|
111
|
+
if (same === account)
|
|
112
|
+
return '"' + out.printable(account) + '" is already recorded: this replaces its name and email';
|
|
113
|
+
return '"' + out.printable(same) + '" is already recorded on this machine: this records "' + out.printable(account) + '" beside it';
|
|
114
|
+
}
|
|
115
|
+
function removeCommand(account) {
|
|
116
|
+
const words = account.startsWith('-') ? ['repown', 'accounts', 'remove', '--', account] : ['repown', 'accounts', 'remove', account];
|
|
117
|
+
return copyableCommand(words) ?? 'remove it with repown accounts remove';
|
|
118
|
+
}
|
|
81
119
|
/** `repown use <account>` to paste, `--` first for a dashed login; described when it can't be printed safely. */
|
|
82
120
|
function useCommand(account) {
|
|
83
121
|
const words = account.startsWith('-') ? ['repown', 'use', '--', account] : ['repown', 'use', account];
|
|
@@ -123,7 +161,7 @@ const listAction = {
|
|
|
123
161
|
run: list,
|
|
124
162
|
};
|
|
125
163
|
const addAction = {
|
|
126
|
-
summary: 'record an account (asks for name
|
|
164
|
+
summary: 'record an account (asks for its name and email once; on GitHub, suggested from its profile through gh)',
|
|
127
165
|
positionals: { min: 1, max: 1, label: '<account>' },
|
|
128
166
|
options: [
|
|
129
167
|
{ name: 'name', kind: 'string', help: 'the commit author name' },
|
|
@@ -144,7 +182,7 @@ const removeAction = {
|
|
|
144
182
|
run: remove,
|
|
145
183
|
};
|
|
146
184
|
export default {
|
|
147
|
-
summary: 'list or
|
|
185
|
+
summary: 'list, record or forget the accounts this machine knows',
|
|
148
186
|
defaultAction: 'list',
|
|
149
187
|
actions: { list: listAction, add: addAction, remove: removeAction },
|
|
150
188
|
// `rm` was the advertised name first; it keeps working, unadvertised.
|
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 '../core/inspect.js';
|
|
16
|
+
import { inspectRepo, inspectAuth, activeAccountLabel, pinsCredential } from '../core/inspect.js';
|
|
17
17
|
import { loadRegistry } from '../core/registry.js';
|
|
18
18
|
import { gitFor } from '../ui/args.js';
|
|
19
19
|
import { snapshotOf } from '../core/config-snapshot.js';
|
|
20
|
+
import { parseGitUrl } from '../core/url.js';
|
|
20
21
|
import * as out from '../ui/format.js';
|
|
21
22
|
const DOCTOR_TITLE = 'repown doctor · how this machine signs in to git hosts';
|
|
22
23
|
const NAME_WIDTH = 14;
|
|
@@ -26,6 +27,8 @@ const NONE_YET = 'none recorded, stored or signed in yet';
|
|
|
26
27
|
const NO_GCM = 'no accounts recorded or signed in to gh; Git Credential Manager isn\'t installed';
|
|
27
28
|
const STORED_UNUSED = 'stored in Git Credential Manager, which git isn\'t using';
|
|
28
29
|
const SETUP_POINTER = 'repown setup';
|
|
30
|
+
const MACHINE = 'This machine';
|
|
31
|
+
const MACHINE_FOR_GITHUB = 'This machine, for github.com';
|
|
29
32
|
export default {
|
|
30
33
|
summary: 'what serves credentials on this machine, and to whom',
|
|
31
34
|
examples: ['repown doctor'],
|
|
@@ -33,10 +36,10 @@ export default {
|
|
|
33
36
|
// Read-only: config reads come from one list per scope (ADR-029).
|
|
34
37
|
const git = snapshotOf(gitFor(args));
|
|
35
38
|
const repo = await inspectRepo(git);
|
|
36
|
-
const auth = await inspectAuth(git, repo
|
|
39
|
+
const auth = await inspectAuth(git, probeUrl(repo));
|
|
37
40
|
const warned = printReport(repo, auth, await loadRegistry());
|
|
38
|
-
const found = diagnose(auth,
|
|
39
|
-
closeDoctor(found
|
|
41
|
+
const found = diagnose(auth, ssoHost(repo));
|
|
42
|
+
closeDoctor(scoped(repo, found) + warningTally(warned));
|
|
40
43
|
return found.code;
|
|
41
44
|
},
|
|
42
45
|
};
|
|
@@ -240,15 +243,43 @@ function recordedPhrase(row) {
|
|
|
240
243
|
/** Prints the machine and its accounts; returns how many sources could not be read. */
|
|
241
244
|
function printReport(repo, auth, registry) {
|
|
242
245
|
out.heading(DOCTOR_TITLE);
|
|
243
|
-
|
|
244
|
-
|
|
246
|
+
const unpinned = unpinnedClone(repo);
|
|
247
|
+
if (unpinned)
|
|
248
|
+
printClone(repo);
|
|
249
|
+
printMachine(auth, unpinned ? MACHINE_FOR_GITHUB : MACHINE);
|
|
250
|
+
// In an unpinned clone the rows are github.com's sign-ins, none of them this clone's.
|
|
251
|
+
const report = accountRows(registry, auth, unpinned ? null : pinnedOf(repo));
|
|
245
252
|
printAccounts(report);
|
|
246
253
|
out.line();
|
|
247
254
|
return report.warnings.length;
|
|
248
255
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
256
|
+
/**
|
|
257
|
+
* Said first, since the machine below is github.com's: why origin gets no pin, and the helper
|
|
258
|
+
* that serves origin's URL, named with no verdict (repown can't judge a helper it doesn't pin for).
|
|
259
|
+
*/
|
|
260
|
+
function printClone(repo) {
|
|
261
|
+
out.heading('This clone');
|
|
262
|
+
out.field('sign-in', unpinnedReason(repo) + ', so no credential is pinned here');
|
|
263
|
+
// Over SSH git asks no credential helper.
|
|
264
|
+
if (credentialTarget(repo)?.scheme !== 'ssh')
|
|
265
|
+
out.field('helper', out.printable(repo.helper ?? 'none configured'));
|
|
266
|
+
}
|
|
267
|
+
/** Read from the URL git uses for origin, after insteadOf, which is what credentialKeys follows. */
|
|
268
|
+
function unpinnedReason(repo) {
|
|
269
|
+
if (credentialTarget(repo)?.scheme === 'ssh')
|
|
270
|
+
return 'origin is an SSH URL';
|
|
271
|
+
if (repo.credentialHost.id === 'github')
|
|
272
|
+
return 'origin is not an HTTPS URL';
|
|
273
|
+
if (repo.credentialHost.id === 'generic')
|
|
274
|
+
return 'origin is not on GitHub';
|
|
275
|
+
return 'origin is on ' + repo.credentialHost.label;
|
|
276
|
+
}
|
|
277
|
+
function credentialTarget(repo) {
|
|
278
|
+
return repo.credentialUrl ? parseGitUrl(repo.credentialUrl) : null;
|
|
279
|
+
}
|
|
280
|
+
function printMachine(auth, heading) {
|
|
281
|
+
out.heading(heading);
|
|
282
|
+
out.field('helper', out.printable(auth.helper ?? 'none configured'));
|
|
252
283
|
out.field('GCM', auth.gcmPath === null ? 'not found' : out.displayPath(auth.gcmPath));
|
|
253
284
|
out.field('gh active', activeAccountLabel(auth));
|
|
254
285
|
}
|
|
@@ -270,12 +301,12 @@ function warnSource(warning) {
|
|
|
270
301
|
if (warning.detail)
|
|
271
302
|
out.detail(warning.detail);
|
|
272
303
|
}
|
|
273
|
-
function diagnose(auth,
|
|
304
|
+
function diagnose(auth, ssoAt) {
|
|
274
305
|
if (auth.ghIsHelper)
|
|
275
306
|
return diagnoseGhHelper(auth);
|
|
276
307
|
if (!auth.helperIsGcm)
|
|
277
308
|
return diagnoseUnknownHelper(auth);
|
|
278
|
-
return diagnoseHealthy(auth,
|
|
309
|
+
return diagnoseHealthy(auth, ssoAt);
|
|
279
310
|
}
|
|
280
311
|
const READY = 'ready: each clone signs in as its own account through Git Credential Manager';
|
|
281
312
|
const READY_EMPTY = 'ready · no accounts stored yet: the first push signs in once';
|
|
@@ -306,7 +337,7 @@ function diagnoseGhHelper(auth) {
|
|
|
306
337
|
/** On its own line, and only when known: an empty "()" used to read as a bug. */
|
|
307
338
|
function ghHelperActive(auth) {
|
|
308
339
|
if (auth.gh.ok && auth.gh.value.active)
|
|
309
|
-
out.detail('Active right now: ' + auth.gh.value.active);
|
|
340
|
+
out.detail('Active right now: ' + out.printable(auth.gh.value.active));
|
|
310
341
|
}
|
|
311
342
|
function ghHelperFiles(auth) {
|
|
312
343
|
const files = [...new Set(auth.ghHelperOrigins.map((entry) => entry.file))];
|
|
@@ -318,7 +349,7 @@ function ghHelperFiles(auth) {
|
|
|
318
349
|
out.detail(' ' + file);
|
|
319
350
|
}
|
|
320
351
|
function diagnoseUnknownHelper(auth) {
|
|
321
|
-
const helper = auth.helper ?? 'nothing';
|
|
352
|
+
const helper = out.printable(auth.helper ?? 'nothing');
|
|
322
353
|
out.warn('helper', 'github.com is served by "' + helper + '", which repown has no opinion about.');
|
|
323
354
|
out.detail('The per-repository pin (credential.<url>.username) only works if');
|
|
324
355
|
out.detail('that helper honours it.');
|
|
@@ -327,12 +358,12 @@ function diagnoseUnknownHelper(auth) {
|
|
|
327
358
|
function unchecked(helper) {
|
|
328
359
|
return 'unchecked: repown can\'t tell whether ' + helper + ' honours the per-clone pin';
|
|
329
360
|
}
|
|
330
|
-
function diagnoseHealthy(auth,
|
|
361
|
+
function diagnoseHealthy(auth, ssoAt) {
|
|
331
362
|
explainGcm();
|
|
332
363
|
const empty = emptyStore(auth);
|
|
333
364
|
if (empty)
|
|
334
365
|
warnEmptyStore();
|
|
335
|
-
ssoNote(
|
|
366
|
+
ssoNote(ssoAt);
|
|
336
367
|
return { code: 0, verdict: empty ? READY_EMPTY : READY };
|
|
337
368
|
}
|
|
338
369
|
function explainGcm() {
|
|
@@ -352,24 +383,25 @@ function warnEmptyStore() {
|
|
|
352
383
|
// not done"). A credential that is otherwise healthy still fails the moment
|
|
353
384
|
// it touches an org it is not SSO-authorized for, and that failure looks
|
|
354
385
|
// identical to a bad token. Printed unconditionally so it is there before it
|
|
355
|
-
// is needed.
|
|
356
|
-
//
|
|
357
|
-
|
|
358
|
-
function ssoNote(target) {
|
|
386
|
+
// is needed. The authorization is the org's SSO settings on the GitHub host
|
|
387
|
+
// the diagnosis is about.
|
|
388
|
+
function ssoNote(host) {
|
|
359
389
|
out.line(' If a push fails although the account is stored, the org may need SSO');
|
|
360
|
-
out.line(' authorization: ' +
|
|
390
|
+
out.line(' authorization: authorize it in the org\'s SSO settings on ' + host);
|
|
391
|
+
}
|
|
392
|
+
/** The origin's host where repown pins a credential (GitHub over HTTPS), github.com otherwise. */
|
|
393
|
+
function ssoHost(repo) {
|
|
394
|
+
return (pinsCredential(repo) ? credentialTarget(repo)?.host : null) ?? 'github.com';
|
|
361
395
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
return 'check ' + target.label + "'s SSO settings";
|
|
396
|
+
/** A clone with an origin repown pins no credential for. No origin reads as outside a clone. */
|
|
397
|
+
function unpinnedClone(repo) {
|
|
398
|
+
return repo.url !== null && !pinsCredential(repo);
|
|
366
399
|
}
|
|
367
|
-
|
|
368
|
-
|
|
400
|
+
/** The origin's URL where repown pins a credential; github.com otherwise, as outside a clone. */
|
|
401
|
+
function probeUrl(repo) {
|
|
402
|
+
return pinsCredential(repo) ? repo.credentialUrl ?? undefined : undefined;
|
|
369
403
|
}
|
|
370
|
-
/**
|
|
371
|
-
function
|
|
372
|
-
|
|
373
|
-
return null;
|
|
374
|
-
return repo.url?.host ?? 'github.com';
|
|
404
|
+
/** In an unpinned clone a passing verdict says it is about github.com, not this clone. */
|
|
405
|
+
function scoped(repo, found) {
|
|
406
|
+
return unpinnedClone(repo) && found.code === 0 ? 'for github.com, ' + found.verdict : found.verdict;
|
|
375
407
|
}
|
package/dist/commands/off.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
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 '../core/inspect.js';
|
|
7
|
+
import { inspectRepo, keysOf, pinsCredential } from '../core/inspect.js';
|
|
8
8
|
import { clearIdentity, legacyAccountKey } from '../core/identity.js';
|
|
9
9
|
import { gitFor } from '../ui/args.js';
|
|
10
10
|
import * as out from '../ui/format.js';
|
|
@@ -22,7 +22,7 @@ export default {
|
|
|
22
22
|
const legacy = repo.url ? [legacyAccountKey(repo.url)] : [];
|
|
23
23
|
const had = id.name ?? id.email ?? id.owner ?? id.account ??
|
|
24
24
|
(legacy[0] ? await git.getConfig(legacy[0], 'local') : null);
|
|
25
|
-
const keys = [...new Set([...repo.credentialKeys, ...legacy])];
|
|
25
|
+
const keys = [...new Set([...repo.credentialKeys, ...await configuredKeys(repo), ...legacy])];
|
|
26
26
|
const failed = (await clearIdentity(git, keys)).filter((outcome) => !outcome.written);
|
|
27
27
|
if (failed.length > 0) {
|
|
28
28
|
out.fail('off', 'could not remove ' + failed.map((outcome) => outcome.key).join(', '));
|
|
@@ -37,13 +37,21 @@ export default {
|
|
|
37
37
|
return 0;
|
|
38
38
|
},
|
|
39
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* The keys of origin's URLs as configured, before insteadOf and pushInsteadOf: a rule
|
|
42
|
+
* added since `use` changes where git sends origin, not what `use` wrote.
|
|
43
|
+
*/
|
|
44
|
+
async function configuredKeys(repo) {
|
|
45
|
+
const pushurls = await repo.git.getAllConfig('remote.origin.pushurl');
|
|
46
|
+
return [repo.originUrl, ...pushurls].flatMap((url) => (url ? keysOf(url) : []));
|
|
47
|
+
}
|
|
40
48
|
/** Read AFTER the clear: before it, the "inherited" value is still the local one. */
|
|
41
49
|
async function reportInherited(git, before) {
|
|
42
50
|
const id = (await inspectRepo(git)).identity;
|
|
43
51
|
out.line();
|
|
44
52
|
out.line(' This clone now inherits the machine default:');
|
|
45
53
|
out.field('commits as', describe(id.inheritedName, id.inheritedEmail));
|
|
46
|
-
if (before
|
|
54
|
+
if (pinsCredential(before))
|
|
47
55
|
out.field('pushes as', id.inheritedAccount ?? 'nothing pinned');
|
|
48
56
|
out.line();
|
|
49
57
|
if (before.guard === 'on') {
|
package/dist/commands/start.js
CHANGED
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
// Everything else is status.
|
|
10
10
|
import { Git } from '../core/git.js';
|
|
11
11
|
import { inspectRepo } from '../core/inspect.js';
|
|
12
|
-
import { identityProblems } from './status.js';
|
|
12
|
+
import statusCommand, { identityProblems } from './status.js';
|
|
13
13
|
import { interactive } from '../ui/prompt.js';
|
|
14
|
+
import * as out from '../ui/format.js';
|
|
14
15
|
export const SETUP_NOTE = 'This clone isn\'t set up yet, so repown is starting setup (repown status shows its settings).';
|
|
15
16
|
export const PINNED_NOTE = 'Starting setup to check this clone (repown status shows its settings without asking anything).';
|
|
16
17
|
/** Setup, status, the start screen, or the top help. No output. */
|
|
@@ -24,8 +25,21 @@ export async function startDefault(deps = realDeps()) {
|
|
|
24
25
|
return () => startSetup(pick.pinned);
|
|
25
26
|
if (pick.choice === 'home')
|
|
26
27
|
return startHome;
|
|
28
|
+
if (pick.choice === 'status' && !deps.interactive && deps.mintty)
|
|
29
|
+
return statusInMintty;
|
|
27
30
|
return pick.choice;
|
|
28
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* mintty without ConPTY hands its programs pipes, not a console, so nothing can ask there and
|
|
34
|
+
* bare repown shows status; winpty gives it a console (Git for Windows ships it).
|
|
35
|
+
*/
|
|
36
|
+
export function minttyWithoutConsole(env, platform, stdinIsTerminal) {
|
|
37
|
+
return platform === 'win32' && !stdinIsTerminal && env['TERM_PROGRAM'] === 'mintty';
|
|
38
|
+
}
|
|
39
|
+
function statusInMintty() {
|
|
40
|
+
out.noted('repown', 'mintty gives repown no console here, so it shows status: run winpty repown to be asked (setup in a clone, the start screen outside one)');
|
|
41
|
+
return statusCommand.run(bareArgs());
|
|
42
|
+
}
|
|
29
43
|
function startHome() {
|
|
30
44
|
return import('../wizard/home-run.js').then((mod) => mod.runHome());
|
|
31
45
|
}
|
|
@@ -52,5 +66,8 @@ function outsideClone(stdoutIsTerminal) {
|
|
|
52
66
|
return stdoutIsTerminal ? 'home' : 'help';
|
|
53
67
|
}
|
|
54
68
|
function realDeps() {
|
|
55
|
-
return {
|
|
69
|
+
return {
|
|
70
|
+
interactive: interactive(), stdoutIsTerminal: process.stdout.isTTY === true, git: new Git(process.cwd()),
|
|
71
|
+
mintty: minttyWithoutConsole(process.env, process.platform, process.stdin.isTTY === true),
|
|
72
|
+
};
|
|
56
73
|
}
|
package/dist/commands/status.js
CHANGED
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
// What would stop the next push (blockers.ts, the list setup reads too) comes first among
|
|
15
15
|
// the warnings, and `ready:` is said only without it (ADR-026). It is still a warning:
|
|
16
16
|
// the exit code is unchanged (ADR-020). This reports; it changes nothing.
|
|
17
|
-
import { inspectRepo, inspectAuth, activeAccountLabel } from '../core/inspect.js';
|
|
17
|
+
import { inspectRepo, inspectAuth, activeAccountLabel, pinsCredential } from '../core/inspect.js';
|
|
18
18
|
import { isPinned } from '../core/identity.js';
|
|
19
19
|
import { loadRegistry } from '../core/registry.js';
|
|
20
20
|
import { snapshotOf } from '../core/config-snapshot.js';
|
|
21
|
-
import { ALLOW_OWNER_BY_HAND, allowOwnerCommand, allowedOwners
|
|
21
|
+
import { ALLOW_OWNER_BY_HAND, allowOwnerCommand, allowedOwners } from '../core/guard/check.js';
|
|
22
|
+
import { copyableCommand, positional } from '../core/shell.js';
|
|
22
23
|
import { existsSync } from 'node:fs';
|
|
23
24
|
import { join } from 'node:path';
|
|
24
25
|
import { gitFor } from '../ui/args.js';
|
|
@@ -38,7 +39,7 @@ export default {
|
|
|
38
39
|
out.detail('repown pins an identity per clone, so it needs one to work in.');
|
|
39
40
|
return 1;
|
|
40
41
|
}
|
|
41
|
-
const auth = await inspectAuth(git, repo.
|
|
42
|
+
const auth = await inspectAuth(git, repo.credentialUrl ?? undefined);
|
|
42
43
|
const registry = await loadRegistry();
|
|
43
44
|
await summary(repo, auth, registry);
|
|
44
45
|
const problems = collectProblems(repo, auth);
|
|
@@ -54,7 +55,7 @@ export default {
|
|
|
54
55
|
/** "Honours it" only where the helper is GCM, the one measured to read the pin (ADR-001). */
|
|
55
56
|
function verdict(repo, auth, problems) {
|
|
56
57
|
if (problems.length === 0) {
|
|
57
|
-
out.pass('identity', repo
|
|
58
|
+
out.pass('identity', pinsCredential(repo) && auth.helperIsGcm
|
|
58
59
|
? 'this clone is pinned, and its credential mechanism honours it'
|
|
59
60
|
: 'this clone\'s commit identity is pinned; its credentials are left to ' + (repo.helper ?? 'nothing'));
|
|
60
61
|
return 0;
|
|
@@ -115,7 +116,8 @@ async function upstreamField(repo) {
|
|
|
115
116
|
return null;
|
|
116
117
|
const tracked = await repo.git.upstreamRef();
|
|
117
118
|
const enabled = tracked === null ? await repo.git.getBoolConfig('push.autoSetupRemote') : null;
|
|
118
|
-
|
|
119
|
+
const push = copyableCommand(['git', 'push', '-u', ...positional(pushRemote(remotes)), branch.name]) ?? 'git push -u with the remote and this branch';
|
|
120
|
+
return upstreamText(tracked, enabled) ?? 'none yet: ' + push;
|
|
119
121
|
}
|
|
120
122
|
function pushRemote(remotes) {
|
|
121
123
|
return remotes.includes('origin') ? 'origin' : remotes[0];
|
|
@@ -140,8 +142,8 @@ function originOf(repo) {
|
|
|
140
142
|
function pushesAs(repo) {
|
|
141
143
|
if (!repo.originUrl)
|
|
142
144
|
return 'no remote to push to';
|
|
143
|
-
if (repo
|
|
144
|
-
return 'not pinned by repown on ' + repo.
|
|
145
|
+
if (!pinsCredential(repo))
|
|
146
|
+
return 'not pinned by repown on ' + repo.credentialHost.label;
|
|
145
147
|
return repo.identity.account ?? 'NOT SET LOCALLY';
|
|
146
148
|
}
|
|
147
149
|
// A registry that cannot be read is reported. Skipping it would look like "none recorded".
|
|
@@ -186,10 +188,10 @@ async function pushBlockers(repo, account) {
|
|
|
186
188
|
// The upstream field already says how to push a branch without one: not a warning here.
|
|
187
189
|
return blockers(facts, { email: repo.identity.email ?? '', account, autoUpstream: true, guarded });
|
|
188
190
|
}
|
|
189
|
-
/** First among the warnings.
|
|
190
|
-
function printBlockers(found,
|
|
191
|
+
/** First among the warnings. The owner the origin warning names is not said twice; another one is. */
|
|
192
|
+
function printBlockers(found, warnedOwner) {
|
|
191
193
|
for (const blocker of found) {
|
|
192
|
-
if (blocker.kind === 'owner' &&
|
|
194
|
+
if (blocker.kind === 'owner' && blocker.owner?.toLowerCase() === warnedOwner?.toLowerCase())
|
|
193
195
|
continue;
|
|
194
196
|
const [first = '', ...rest] = blocker.lines;
|
|
195
197
|
out.warn('push', printable(first));
|
|
@@ -215,7 +217,7 @@ function closingLine(end) {
|
|
|
215
217
|
}
|
|
216
218
|
const GH_OPTIONAL = ' · gh: optional (see the note above)';
|
|
217
219
|
function readyLine(repo, account, warnings, ghNote) {
|
|
218
|
-
const head = repo
|
|
220
|
+
const head = !pinsCredential(repo)
|
|
219
221
|
? 'ready: commits use ' + account + '; pushes use this host\'s own sign-in'
|
|
220
222
|
: 'ready: commits and pushes use ' + account;
|
|
221
223
|
if (warnings.length > 0)
|
|
@@ -252,7 +254,7 @@ export function identityProblems(repo) {
|
|
|
252
254
|
fix: SETUP_FIX,
|
|
253
255
|
}];
|
|
254
256
|
}
|
|
255
|
-
if (repo
|
|
257
|
+
if (!pinsCredential(repo) || id.account)
|
|
256
258
|
return [];
|
|
257
259
|
return [{
|
|
258
260
|
what: 'No account is pinned, so pushes fall back to the machine default (' +
|
|
@@ -263,7 +265,7 @@ export function identityProblems(repo) {
|
|
|
263
265
|
async function reportWarnings(repo, auth, registry, found) {
|
|
264
266
|
const tags = ['origin', 'account', 'guard', 'submodule', 'helper', 'gh'];
|
|
265
267
|
const foreignOwner = await originForeign(repo);
|
|
266
|
-
printBlockers(found, foreignOwner);
|
|
268
|
+
printBlockers(found, foreignOwner ? repo.owner : null);
|
|
267
269
|
const fired = [
|
|
268
270
|
foreignOwner && ownerWarning(repo),
|
|
269
271
|
accountWarning(repo, registry),
|
|
@@ -297,7 +299,7 @@ function accountWarning(repo, registry) {
|
|
|
297
299
|
}
|
|
298
300
|
/** A pinned credential key is only as good as the helper reading it. gh as helper is a problem, reported elsewhere. */
|
|
299
301
|
function helperWarning(repo, auth) {
|
|
300
|
-
if (repo
|
|
302
|
+
if (!pinsCredential(repo) || auth.helperIsGcm || auth.ghIsHelper)
|
|
301
303
|
return false;
|
|
302
304
|
if (!auth.helper) {
|
|
303
305
|
out.warn('helper', 'no credential helper is set, so the pinned account selects no credential; git will prompt on push.');
|
package/dist/commands/use.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
// GitHub CLI on the same account: `gh auth switch` when gh already lists it,
|
|
18
18
|
// and, in a terminal, `gh auth login` when it does not. After `repown fix`
|
|
19
19
|
// neither changes which account git pushes as.
|
|
20
|
-
import { inspectRepo, inspectAuth } from '../core/inspect.js';
|
|
20
|
+
import { inspectRepo, inspectAuth, pinsCredential } from '../core/inspect.js';
|
|
21
21
|
import { pinIdentity } from '../core/identity.js';
|
|
22
22
|
import { lookupAccount, saveAccount } from '../core/registry.js';
|
|
23
23
|
import { ghSwitch, ghLogin, readGhLoginVersion, } from '../core/credential/gh.js';
|
|
@@ -50,7 +50,7 @@ export default {
|
|
|
50
50
|
return 1;
|
|
51
51
|
if (!reportPinned(await pinIdentity(git, { ...values, account }, repo.credentialKeys)))
|
|
52
52
|
return 1;
|
|
53
|
-
out.pass('identity', out.printable(values.name + ' <' + values.email + '> push-as:' + account));
|
|
53
|
+
out.pass('identity', out.printable(values.name + ' <' + values.email + '>' + (pinsCredential(repo) ? ' push-as:' + account : '')));
|
|
54
54
|
if (flagBool(args, 'gh'))
|
|
55
55
|
await applyGh(account, repo);
|
|
56
56
|
await reportConcerns(account, repo, values.email);
|
|
@@ -162,7 +162,7 @@ function storesIn(gcm, helper) {
|
|
|
162
162
|
return ASK + 'press Enter (Yes): it also stores this sign-in in ' + where + ', so the first push won\'t ask again.';
|
|
163
163
|
}
|
|
164
164
|
async function applyGh(account, repo) {
|
|
165
|
-
const auth = await inspectAuth(repo.git, repo.
|
|
165
|
+
const auth = await inspectAuth(repo.git, repo.credentialUrl ?? undefined);
|
|
166
166
|
const action = ghAction(account, auth, interactive());
|
|
167
167
|
if (action === 'advise')
|
|
168
168
|
return notSignedIn(account);
|
|
@@ -210,7 +210,7 @@ function loginFailed(failure) {
|
|
|
210
210
|
out.detail('fix: gh auth login');
|
|
211
211
|
}
|
|
212
212
|
async function reportLogin(account, repo, before) {
|
|
213
|
-
const after = await inspectAuth(repo.git, repo.
|
|
213
|
+
const after = await inspectAuth(repo.git, repo.credentialUrl ?? undefined);
|
|
214
214
|
reportActive(account, after);
|
|
215
215
|
if (!before.ghIsHelper && after.ghIsHelper)
|
|
216
216
|
helperTakenOver();
|
|
@@ -253,8 +253,8 @@ async function switchCli(account) {
|
|
|
253
253
|
/** Everything that is now true but not yet right. Warnings, never refusals. */
|
|
254
254
|
async function reportConcerns(account, repo, email) {
|
|
255
255
|
await reportUnpushed(repo, email, account);
|
|
256
|
-
if (repo
|
|
257
|
-
out.warn('host', repo.
|
|
256
|
+
if (!pinsCredential(repo) && repo.url) {
|
|
257
|
+
out.warn('host', 'credentials on ' + repo.credentialHost.label + ' are not pinned by repown.');
|
|
258
258
|
out.detail('commits are pinned and the guard still runs; only credential');
|
|
259
259
|
out.detail('selection is left to whatever already serves this host.');
|
|
260
260
|
}
|
|
@@ -283,8 +283,11 @@ async function ownerConcern(account, repo) {
|
|
|
283
283
|
out.detail('normal for an organisation repository. To stop the guard refusing it:');
|
|
284
284
|
out.detail(' ' + (allowOwnerCommand(repo.owner) ?? ALLOW_OWNER_BY_HAND));
|
|
285
285
|
}
|
|
286
|
+
/** Only where use pinned a credential: elsewhere pushes use the host's own sign-in, as setup's credentialGap says. */
|
|
286
287
|
async function credentialConcern(account, repo) {
|
|
287
|
-
|
|
288
|
+
if (!pinsCredential(repo))
|
|
289
|
+
return;
|
|
290
|
+
const auth = await inspectAuth(repo.git, repo.credentialUrl ?? undefined);
|
|
288
291
|
if (auth.ghIsHelper) {
|
|
289
292
|
out.warn('helper', 'gh is still the git credential helper, so this pin is not honoured.');
|
|
290
293
|
out.detail('fix: repown fix');
|
package/dist/core/blockers.js
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
// never an absence (a skipped check must not look passed). What only the guard would
|
|
7
7
|
// refuse is still said with the guard off, as a warning that blocks nothing.
|
|
8
8
|
import { unpushedLines, foreignCount } from './unpushed.js';
|
|
9
|
-
import { ALLOW_OWNER_BY_HAND, allowOwnerCommand
|
|
9
|
+
import { ALLOW_OWNER_BY_HAND, allowOwnerCommand } from './guard/check.js';
|
|
10
|
+
import { copyableCommand, positional } from './shell.js';
|
|
10
11
|
import { printable } from '../ui/format.js';
|
|
11
12
|
const TOKENS = ['GH_TOKEN', 'GITHUB_TOKEN'];
|
|
12
13
|
export function blockers(facts, choice) {
|
|
@@ -101,6 +102,7 @@ function ownerBlocker(destination, branch, choice) {
|
|
|
101
102
|
const guard = choice.guarded ? 'the guard will refuse it' : 'the guard is off, so it pushes there anyway';
|
|
102
103
|
return [{
|
|
103
104
|
kind: 'owner',
|
|
105
|
+
owner: destination.owner,
|
|
104
106
|
summary: 'the push goes to "' + printable(destination.owner) + '"',
|
|
105
107
|
lines: [branch + ' pushes to ' + where + ', owned by "' + printable(destination.owner) + '", not ' + choice.account +
|
|
106
108
|
': ' + guard + '. If you belong there: ' + (allowOwnerCommand(destination.owner) ?? ALLOW_OWNER_BY_HAND)],
|
|
@@ -125,7 +127,7 @@ function divergenceBlocker(divergence, branch) {
|
|
|
125
127
|
function upstreamBlocker(facts, branch, autoUpstream) {
|
|
126
128
|
if (facts.upstream !== 'missing' || autoUpstream)
|
|
127
129
|
return [];
|
|
128
|
-
const push = copyableCommand(['git', 'push', '-u', facts.destination?.remote ?? 'origin', branch]) ?? 'git push -u with the remote and this branch';
|
|
130
|
+
const push = copyableCommand(['git', 'push', '-u', ...positional(facts.destination?.remote ?? 'origin'), branch]) ?? 'git push -u with the remote and this branch';
|
|
129
131
|
return [{ kind: 'upstream', summary: branch + ' has no upstream', lines: [branch + ' has no upstream: the first push needs ' + push], blocks: true }];
|
|
130
132
|
}
|
|
131
133
|
function detachedBlocker() {
|