repown 0.5.1 → 0.5.3

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.
@@ -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.originUrl ?? undefined);
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.credentialKeys.length > 0, credentialKeys: repo.credentialKeys,
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,
@@ -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 pinsCredential = repo.credentialKeys.length > 0 && repo.originUrl !== null;
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
- pinsCredential ? git.getUrlMatch('credential.username', repo.originUrl) : Promise.resolve(values.account),
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, shellWord } from '../core/guard/check.js';
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,15 +276,18 @@ 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
- if (hostOf(answers, ctx) !== 'github')
279
- return null;
280
- const logins = await ctx.signedIn();
281
- const login = accountOf(answers);
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, go back; otherwise the first push asks you to sign in as it';
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) {
@@ -583,11 +587,11 @@ function repointArgv(answers, ctx) {
583
587
  }
584
588
  function fetchArgv(answers, ctx) {
585
589
  const remote = answers['fetch'] === true ? fetchTarget(answers, ctx) : null;
586
- return remote ? [...gitIn(ctx), 'fetch', remote] : null;
590
+ return remote ? [...gitIn(ctx), 'fetch', ...positional(remote)] : null;
587
591
  }
588
592
  export function gitStepOf(argv) {
589
593
  const sub = argv[1] === '-C' ? argv.slice(3) : argv.slice(1);
590
- if (sub[0] === 'fetch' && sub.length === 2)
594
+ if (sub[0] === 'fetch' && (sub.length === 2 || (sub.length === 3 && sub[1] === '--')))
591
595
  return 'fetch';
592
596
  if (sub[0] !== 'config' || sub[1] !== '--local')
593
597
  return null;
@@ -619,7 +623,7 @@ function gitWhat(argv, ctx) {
619
623
  if (step === 'repoint')
620
624
  return 'Push through ' + argv.at(-1) + ' instead of the URL in ' + argv.at(-2) + ' (this clone only)';
621
625
  if (step === 'fetch')
622
- 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)';
623
627
  if (step === 'upstream')
624
628
  return 'Push branches without -u: the first push sets the upstream (this clone only)';
625
629
  return 'Let this clone push to ' + ctx.owner + '\'s repositories';
@@ -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
- return command.run(parsed.value);
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) {
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "repown",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "repown",
9
- "version": "0.5.1",
9
+ "version": "0.5.3",
10
10
  "license": "MIT",
11
11
  "bin": {
12
12
  "repown": "dist/cli.js"
13
13
  },
14
14
  "devDependencies": {
15
- "@types/node": "^26.6.3",
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.3",
57
- "resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.3.tgz",
58
- "integrity": "sha512-dsqMQQoeTLqu9wynDD00q573mNzso3IdQOAfHRJqLCcmCFPoGo9A1bDpUcv/9tnKpErQWv9uKeGfl37EIS02Yg==",
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.1",
3
+ "version": "0.5.3",
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.3",
57
+ "@types/node": "^26.6.4",
58
58
  "typescript": "^7.0.2"
59
59
  },
60
60
  "optionalDependencies": {