repown 0.5.0 → 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 +98 -1
- package/README.md +4 -1
- package/dist/commands/accounts.js +44 -6
- package/dist/commands/doctor.js +63 -31
- package/dist/commands/off.js +11 -3
- package/dist/commands/scan.js +2 -1
- package/dist/commands/start.js +19 -2
- package/dist/commands/status.js +17 -15
- package/dist/commands/use.js +16 -9
- package/dist/core/blockers.js +4 -2
- package/dist/core/config-snapshot.js +7 -0
- package/dist/core/credential/gcm.js +1 -1
- package/dist/core/credential/gh.js +26 -14
- package/dist/core/exec.js +57 -6
- package/dist/core/git.js +118 -17
- package/dist/core/guard/check.js +1 -26
- package/dist/core/hosts/github.js +52 -9
- package/dist/core/hosts/index.js +3 -1
- package/dist/core/inspect.js +45 -7
- package/dist/core/push-destination.js +55 -15
- package/dist/core/push-state.js +9 -5
- package/dist/core/reauthor.js +37 -10
- package/dist/core/refspec.js +45 -0
- package/dist/core/registry.js +11 -4
- 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 +15 -7
- package/dist/wizard/home-text.js +4 -0
- package/dist/wizard/review-text.js +4 -3
- package/dist/wizard/setup-context.js +7 -7
- package/dist/wizard/setup-flow.js +17 -11
- package/dist/wizard/setup-run.js +3 -2
- package/npm-shrinkwrap.json +6 -6
- package/package.json +2 -2
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// and the machine (gh, the credential helper, the global identity, git's version).
|
|
4
4
|
// Nothing here writes.
|
|
5
5
|
import { gitSupportsAutoUpstream } from '../core/version.js';
|
|
6
|
-
import { inspectRepo, inspectAuth } from '../core/inspect.js';
|
|
6
|
+
import { inspectRepo, inspectAuth, pinsCredential } from '../core/inspect.js';
|
|
7
7
|
import { pinHolds } from '../core/identity.js';
|
|
8
8
|
import { loadRegistry } from '../core/registry.js';
|
|
9
9
|
import { planRepair } from '../core/credential/repair.js';
|
|
@@ -97,7 +97,7 @@ async function readFacts(git, repo, recorded, options) {
|
|
|
97
97
|
return finishFacts(git, repo, recorded, loaded);
|
|
98
98
|
}
|
|
99
99
|
async function loadClone(git, repo, options) {
|
|
100
|
-
const authPromise = options.auth ? Promise.resolve(options.auth) : inspectAuth(git, repo.
|
|
100
|
+
const authPromise = options.auth ? Promise.resolve(options.auth) : inspectAuth(git, repo.credentialUrl ?? undefined);
|
|
101
101
|
const [auth, pinned, allowed, planned, addresses, helpers, ownerIsUser, upstream, [unpushed, push]] = await Promise.all([
|
|
102
102
|
authPromise,
|
|
103
103
|
git.getConfig('repown.account', 'local'),
|
|
@@ -156,7 +156,7 @@ function assemble(cwd, recorded, repo, facts) {
|
|
|
156
156
|
detected: facts.detected,
|
|
157
157
|
ownerIsUser: facts.ownerIsUser,
|
|
158
158
|
allowed: facts.allowed.map((owner) => owner.toLowerCase()),
|
|
159
|
-
credentialPinned: repo
|
|
159
|
+
credentialPinned: pinsCredential(repo), credentialKeys: repo.credentialKeys,
|
|
160
160
|
gh: facts.gh, ghIsHelper: facts.ghIsHelper,
|
|
161
161
|
guard: repo.guard,
|
|
162
162
|
redirected: repo.hook?.redirected ?? false, hookPath: repo.hook?.path ?? null,
|
|
@@ -204,11 +204,11 @@ function ghLogins(gh) {
|
|
|
204
204
|
export async function askOwnerIsUser(repo, auth, options = {}) {
|
|
205
205
|
if (options.classifyOwner === false)
|
|
206
206
|
return null;
|
|
207
|
-
if (repo.
|
|
207
|
+
if (repo.ownerProvider.id !== 'github' || !repo.owner)
|
|
208
208
|
return null;
|
|
209
209
|
if (signedIn(auth, repo.owner))
|
|
210
210
|
return true;
|
|
211
|
-
const ask = options.accountKind ?? repo.
|
|
211
|
+
const ask = options.accountKind ?? repo.ownerProvider.accountKind;
|
|
212
212
|
if (!ask)
|
|
213
213
|
return null;
|
|
214
214
|
return asUser(await ask(repo.owner));
|
|
@@ -245,11 +245,11 @@ async function pinIntact(git, pinned, entry, repo) {
|
|
|
245
245
|
}
|
|
246
246
|
/** The identity and push account git resolves for this clone, from every scope it reads. */
|
|
247
247
|
async function gitUses(git, values, repo) {
|
|
248
|
-
const
|
|
248
|
+
const pinned = pinsCredential(repo) && repo.credentialUrl !== null;
|
|
249
249
|
const [name, email, user] = await Promise.all([
|
|
250
250
|
git.getConfig('user.name'),
|
|
251
251
|
git.getConfig('user.email'),
|
|
252
|
-
|
|
252
|
+
pinned ? git.getUrlMatch('credential.username', repo.credentialUrl) : Promise.resolve(values.account),
|
|
253
253
|
]);
|
|
254
254
|
return name === values.name && email === values.email && user === values.account;
|
|
255
255
|
}
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
import { ghAdvice, upstreamText } from '../commands/status.js';
|
|
10
10
|
import { providers } from '../core/hosts/index.js';
|
|
11
11
|
import { isNoreplyAddress } from '../core/hosts/github.js';
|
|
12
|
-
import { ALLOW_OWNER_BY_HAND, allowOwnerCommand
|
|
12
|
+
import { ALLOW_OWNER_BY_HAND, allowOwnerCommand } from '../core/guard/check.js';
|
|
13
|
+
import { positional, shellWord } from '../core/shell.js';
|
|
13
14
|
import { printable } from '../ui/format.js';
|
|
14
15
|
import { foreignAddresses, foreignCount } from '../core/unpushed.js';
|
|
15
16
|
import { blockers } from '../core/blockers.js';
|
|
@@ -275,22 +276,25 @@ async function nameDetail(answers, ctx) {
|
|
|
275
276
|
}
|
|
276
277
|
/** On GitHub, when this machine is signed in as other logins only: perhaps not this person's account. */
|
|
277
278
|
async function notSignedIn(answers, ctx) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
279
|
+
return hostOf(answers, ctx) === 'github' ? signedInNote(accountOf(answers), await ctx.signedIn(), 'go back') : null;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* `signed in as A, not X: if X isn't your account, <undo>; ...`, or null when X is among the
|
|
283
|
+
* logins or none could be read. Typed `accounts add` says it too, with its own undo.
|
|
284
|
+
*/
|
|
285
|
+
export function signedInNote(login, logins, undo) {
|
|
282
286
|
if (!logins || logins.length === 0 || logins.some((other) => other.toLowerCase() === login.toLowerCase()))
|
|
283
287
|
return null;
|
|
284
288
|
const shown = printable(login);
|
|
285
289
|
return 'signed in as ' + logins.map(printable).join(', ') + ', not ' + shown + ': if ' + shown +
|
|
286
|
-
' isn\'t your account,
|
|
290
|
+
' isn\'t your account, ' + undo + '; otherwise the first push asks you to sign in as it';
|
|
287
291
|
}
|
|
288
292
|
/** Said when the name question starts as the login: no profile name was found. */
|
|
289
293
|
function loginPrefill(answers, found, ctx) {
|
|
290
294
|
if (found.name || typeof answers['name'] === 'string')
|
|
291
295
|
return null;
|
|
292
296
|
const answered = found.email !== undefined && hostOf(answers, ctx) === 'github';
|
|
293
|
-
return answered ? 'GitHub
|
|
297
|
+
return answered ? 'GitHub gives no usable name for ' + printable(accountOf(answers)) + ', so this is the login' : 'this is the login';
|
|
294
298
|
}
|
|
295
299
|
function machineName(ctx) {
|
|
296
300
|
const name = ctx.machineIdentity.name;
|
|
@@ -420,7 +424,7 @@ export const SOURCE_GH = 'signed in to gh';
|
|
|
420
424
|
export const SOURCE_GCM = 'stored in Git Credential Manager';
|
|
421
425
|
const OWNER_UNKNOWN = SOURCE_OWNS + '; may be an organisation';
|
|
422
426
|
function accountChoices(ctx) {
|
|
423
|
-
const recorded = Object.entries(ctx.recorded).map(([account, entry]) => ({ value: account, label: account, hint: entry.name + ' <' + entry.email + '>' }));
|
|
427
|
+
const recorded = Object.entries(ctx.recorded).map(([account, entry]) => ({ value: account, label: printable(account), hint: printable(entry.name + ' <' + entry.email + '>') }));
|
|
424
428
|
const detected = ctx.detected.map((account) => detectedChoice(account, ctx));
|
|
425
429
|
return [...recorded, ...detected, { value: NEW_ACCOUNT, label: 'a new account', hint: 'record another account on this machine' }];
|
|
426
430
|
}
|
|
@@ -491,6 +495,8 @@ const LOGIN = /^[\w.@-]+$/;
|
|
|
491
495
|
export function loginProblem(value) {
|
|
492
496
|
if (!value.trim())
|
|
493
497
|
return 'a value is required';
|
|
498
|
+
if (/^\.+$/.test(value))
|
|
499
|
+
return 'a login can\'t be only dots';
|
|
494
500
|
return LOGIN.test(value) ? null : 'use letters, digits and . _ @ - only';
|
|
495
501
|
}
|
|
496
502
|
function newAccountProblem(value, ctx) {
|
|
@@ -581,11 +587,11 @@ function repointArgv(answers, ctx) {
|
|
|
581
587
|
}
|
|
582
588
|
function fetchArgv(answers, ctx) {
|
|
583
589
|
const remote = answers['fetch'] === true ? fetchTarget(answers, ctx) : null;
|
|
584
|
-
return remote ? [...gitIn(ctx), 'fetch', remote] : null;
|
|
590
|
+
return remote ? [...gitIn(ctx), 'fetch', ...positional(remote)] : null;
|
|
585
591
|
}
|
|
586
592
|
export function gitStepOf(argv) {
|
|
587
593
|
const sub = argv[1] === '-C' ? argv.slice(3) : argv.slice(1);
|
|
588
|
-
if (sub[0] === 'fetch' && sub.length === 2)
|
|
594
|
+
if (sub[0] === 'fetch' && (sub.length === 2 || (sub.length === 3 && sub[1] === '--')))
|
|
589
595
|
return 'fetch';
|
|
590
596
|
if (sub[0] !== 'config' || sub[1] !== '--local')
|
|
591
597
|
return null;
|
|
@@ -617,7 +623,7 @@ function gitWhat(argv, ctx) {
|
|
|
617
623
|
if (step === 'repoint')
|
|
618
624
|
return 'Push through ' + argv.at(-1) + ' instead of the URL in ' + argv.at(-2) + ' (this clone only)';
|
|
619
625
|
if (step === 'fetch')
|
|
620
|
-
return 'Fetch ' + argv.at(-1) + ', so repown can tell which commits it already has';
|
|
626
|
+
return 'Fetch ' + argv.at(-1) + ', so repown can tell which commits it already has (prompts off: a sign-in that would ask fails instead)';
|
|
621
627
|
if (step === 'upstream')
|
|
622
628
|
return 'Push branches without -u: the first push sets the upstream (this clone only)';
|
|
623
629
|
return 'Let this clone push to ' + ctx.owner + '\'s repositories';
|
package/dist/wizard/setup-run.js
CHANGED
|
@@ -16,7 +16,7 @@ import useCommand, { NEXT_GUARD } from '../commands/use.js';
|
|
|
16
16
|
import fixCommand from '../commands/fix.js';
|
|
17
17
|
import reauthorCommand from '../commands/reauthor.js';
|
|
18
18
|
import guardGroup from '../commands/guard.js';
|
|
19
|
-
import accountsGroup from '../commands/accounts.js';
|
|
19
|
+
import accountsGroup, { asked } from '../commands/accounts.js';
|
|
20
20
|
import { wizard, refusedGiven } from './engine.js';
|
|
21
21
|
import { setupFlow, planCommands, formatCommand, gitStepOf, keptFlags, briefOf, missingFlags, printable, dropFixPrefix, NEW_ACCOUNT, accountOf, pinUnchanged, ghNoted } from './setup-flow.js';
|
|
22
22
|
import { cloneChangeLines, machineChangeLines, readCloneSnapshot } from './setup-changes.js';
|
|
@@ -462,7 +462,8 @@ async function runOne(argv, git) {
|
|
|
462
462
|
out.fail('setup', 'could not run ' + formatCommand(argv) + ': ' + parsed.error);
|
|
463
463
|
return 2;
|
|
464
464
|
}
|
|
465
|
-
|
|
465
|
+
// Setup said while asking what accounts add would warn about a typed login.
|
|
466
|
+
return command.run(command === accountsGroup.actions['add'] ? asked(parsed.value) : parsed.value);
|
|
466
467
|
}
|
|
467
468
|
/** The Command a planned argv names, and the arguments after its name; null for anything else. */
|
|
468
469
|
function commandFor(argv) {
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "repown",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "repown",
|
|
9
|
-
"version": "0.5.
|
|
9
|
+
"version": "0.5.2",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"bin": {
|
|
12
12
|
"repown": "dist/cli.js"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@types/node": "^26.6.
|
|
15
|
+
"@types/node": "^26.6.4",
|
|
16
16
|
"typescript": "^7.0.2"
|
|
17
17
|
},
|
|
18
18
|
"engines": {
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
"node_modules/@types/node": {
|
|
56
|
-
"version": "26.6.
|
|
57
|
-
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.
|
|
58
|
-
"integrity": "sha512-
|
|
56
|
+
"version": "26.6.4",
|
|
57
|
+
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.4.tgz",
|
|
58
|
+
"integrity": "sha512-ldVPDCzj7fsaGZrLB0NuHuTvJcsNasysBAqMolr/cgxrLd1xbqxIr3XJiPnHHJUCxj5sNF1vnRj9aWnrVh5Jcg==",
|
|
59
59
|
"dev": true,
|
|
60
60
|
"license": "MIT",
|
|
61
61
|
"dependencies": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "repown",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Use several git accounts on one machine: each repo owns its identity, so you move between repos with no switch command and never push the wrong one.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@types/node": "^26.6.
|
|
57
|
+
"@types/node": "^26.6.4",
|
|
58
58
|
"typescript": "^7.0.2"
|
|
59
59
|
},
|
|
60
60
|
"optionalDependencies": {
|