repown 0.5.0 → 0.5.1
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 +28 -1
- package/dist/commands/accounts.js +2 -2
- package/dist/commands/scan.js +2 -1
- package/dist/commands/status.js +1 -1
- package/dist/commands/use.js +7 -3
- package/dist/core/credential/gcm.js +1 -1
- package/dist/core/credential/gh.js +2 -1
- package/dist/core/git.js +18 -0
- package/dist/core/hosts/github.js +33 -8
- package/dist/core/inspect.js +13 -2
- package/dist/core/push-state.js +7 -3
- package/dist/core/registry.js +11 -4
- package/dist/wizard/home-run.js +8 -1
- package/dist/wizard/home-text.js +4 -0
- package/dist/wizard/setup-context.js +2 -2
- package/dist/wizard/setup-flow.js +4 -2
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,32 @@ commands. How a release is cut: [docs/RELEASING.md](docs/RELEASING.md).
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.5.1] - 2026-10-03
|
|
11
|
+
|
|
12
|
+
A safety release: account lookups can no longer borrow another account's profile, the start
|
|
13
|
+
screen won't ask questions it can't save, and the owner repown names for a push is the one the
|
|
14
|
+
push guard checks.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
- **Security: a typed login can no longer pull in another account's GitHub profile.**
|
|
18
|
+
`repown accounts add ../user` made the lookup GitHub's own `/user`, your signed-in account,
|
|
19
|
+
and suggested its name and noreply id for a different login. Now only a login spelled the way
|
|
20
|
+
GitHub spells one (letters, digits, `-`, `_`) is looked up, as one URL path segment; anything
|
|
21
|
+
else is recorded as typed with nothing suggested, and a login GitHub can't have (a dot, a
|
|
22
|
+
slash) is named as no account on github.com without asking it. A profile name with control or
|
|
23
|
+
bidi characters is dropped instead of drawn and saved (the name question then says `GitHub
|
|
24
|
+
gives no usable name for …`), the missing-account warning escapes the login, and setup and the
|
|
25
|
+
start screen refuse a login made only of dots.
|
|
26
|
+
- The start screen's Record an account checks first that the account list can be saved. When
|
|
27
|
+
it can't be read, or has entries repown can't read, it says why and asks nothing, instead of
|
|
28
|
+
asking four questions and then failing to save (and skipping the "already recorded" check).
|
|
29
|
+
- Setup, `repown status`, `repown use`, `repown scan` and the push blockers name the owner your
|
|
30
|
+
pushes really go to, after `pushurl` and git's `url.<base>.insteadOf` / `pushInsteadOf`
|
|
31
|
+
rewrites, the same owner the pre-push guard checks, with the host of that same URL. Before,
|
|
32
|
+
they read the configured URL and could say a push was fine that the guard then refused, or
|
|
33
|
+
warn about an owner the push never reaches. `scan --format json`'s `owner` and `host` now
|
|
34
|
+
describe that push URL (the same values unless pushes are rewritten).
|
|
35
|
+
|
|
10
36
|
## [0.5.0] - 2026-10-03
|
|
11
37
|
|
|
12
38
|
The start screen (bare `repown` outside a clone) now records and removes accounts without
|
|
@@ -211,7 +237,8 @@ and cmd. `status`, `doctor` and the pre-push guard are faster on Windows.
|
|
|
211
237
|
contract for scripts.
|
|
212
238
|
- Runs on Node 20+ on Windows, macOS and Linux, with zero runtime dependencies.
|
|
213
239
|
|
|
214
|
-
[Unreleased]: https://github.com/makubexD/repown/compare/v0.5.
|
|
240
|
+
[Unreleased]: https://github.com/makubexD/repown/compare/v0.5.1...HEAD
|
|
241
|
+
[0.5.1]: https://github.com/makubexD/repown/compare/v0.5.0...v0.5.1
|
|
215
242
|
[0.5.0]: https://github.com/makubexD/repown/compare/v0.4.0...v0.5.0
|
|
216
243
|
[0.4.0]: https://github.com/makubexD/repown/compare/v0.3.0...v0.4.0
|
|
217
244
|
[0.3.0]: https://github.com/makubexD/repown/compare/v0.2.0...v0.3.0
|
|
@@ -69,7 +69,7 @@ async function add(args) {
|
|
|
69
69
|
return 1;
|
|
70
70
|
const written = await saveAccount(account, { name, email, host: hostId });
|
|
71
71
|
if (!written.ok) {
|
|
72
|
-
out.fail('accounts', written.error);
|
|
72
|
+
out.fail('accounts', out.printable(written.error));
|
|
73
73
|
return 1;
|
|
74
74
|
}
|
|
75
75
|
out.pass('accounts', out.printable(account) + ' ' + out.printable(name) + ' <' + out.printable(email) + '>');
|
|
@@ -87,7 +87,7 @@ function useCommand(account) {
|
|
|
87
87
|
async function suggestProfile(hostId, account) {
|
|
88
88
|
const found = await lookUpProfile(providers().find((candidate) => candidate.id === hostId), account);
|
|
89
89
|
if (found.problem)
|
|
90
|
-
out.warn('accounts', found.problem + ' (recording it anyway)');
|
|
90
|
+
out.warn('accounts', out.printable(found.problem) + ' (recording it anyway)');
|
|
91
91
|
return found.profile;
|
|
92
92
|
}
|
|
93
93
|
async function askFor(label, suggestion) {
|
package/dist/commands/scan.js
CHANGED
|
@@ -144,7 +144,8 @@ async function describe(found, showEmails) {
|
|
|
144
144
|
path: resolve(found.path),
|
|
145
145
|
remote: repo.originUrl !== null,
|
|
146
146
|
owner: repo.owner,
|
|
147
|
-
host
|
|
147
|
+
// owner and host describe the same URL: where origin's pushes go (ADR-014 note).
|
|
148
|
+
host: repo.url ? repo.ownerProvider.id : null,
|
|
148
149
|
identity: identityOf(repo),
|
|
149
150
|
guard: repo.guard,
|
|
150
151
|
history: counts.ok ? grouped(counts.value, showEmails) : null,
|
package/dist/commands/status.js
CHANGED
|
@@ -135,7 +135,7 @@ function person(name, email, absent) {
|
|
|
135
135
|
function originOf(repo) {
|
|
136
136
|
if (!repo.originUrl)
|
|
137
137
|
return 'no remote';
|
|
138
|
-
return (repo.owner ?? 'unknown') + ' ' + out.dim('(' + repo.
|
|
138
|
+
return (repo.owner ?? 'unknown') + ' ' + out.dim('(' + repo.ownerProvider.label + ')');
|
|
139
139
|
}
|
|
140
140
|
function pushesAs(repo) {
|
|
141
141
|
if (!repo.originUrl)
|
package/dist/commands/use.js
CHANGED
|
@@ -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', values.name + ' <' + values.email + '> push-as:' + account);
|
|
53
|
+
out.pass('identity', out.printable(values.name + ' <' + values.email + '> push-as:' + account));
|
|
54
54
|
if (flagBool(args, 'gh'))
|
|
55
55
|
await applyGh(account, repo);
|
|
56
56
|
await reportConcerns(account, repo, values.email);
|
|
@@ -100,16 +100,20 @@ async function askAndRecord(account, repo, known) {
|
|
|
100
100
|
out.line();
|
|
101
101
|
out.line(' No record of "' + account + '" yet. Asking once, then never again.');
|
|
102
102
|
const entry = await askProfile({
|
|
103
|
-
name: known.name ?? suggested.name ?? account, email: known.email ?? suggested.email,
|
|
103
|
+
name: offered(known.name) ?? suggested.name ?? offered(account) ?? '', email: offered(known.email) ?? suggested.email,
|
|
104
104
|
}, repo.provider.id);
|
|
105
105
|
if (!entry)
|
|
106
106
|
return null;
|
|
107
107
|
const saved = await saveAccount(account, entry);
|
|
108
108
|
if (!saved.ok)
|
|
109
|
-
out.warn('accounts', 'pinned, but not recorded: ' + saved.error);
|
|
109
|
+
out.warn('accounts', 'pinned, but not recorded: ' + out.printable(saved.error));
|
|
110
110
|
out.line();
|
|
111
111
|
return entry;
|
|
112
112
|
}
|
|
113
|
+
/** A default worth offering: one printable() would change would be drawn raw, and saved if accepted. */
|
|
114
|
+
function offered(value) {
|
|
115
|
+
return value && out.printable(value) === value ? value : undefined;
|
|
116
|
+
}
|
|
113
117
|
async function askProfile(defaults, host) {
|
|
114
118
|
const name = await ask('Commit name', defaults.name);
|
|
115
119
|
if (!name.ok) {
|
|
@@ -20,7 +20,7 @@ const NAMES = ['git-credential-manager', 'git-credential-manager-core'];
|
|
|
20
20
|
async function searchDirectories() {
|
|
21
21
|
const directories = [];
|
|
22
22
|
// Git for Windows bundles GCM as a sibling of git's own exec-path:
|
|
23
|
-
// <root>/mingw64/libexec/git-core -> <root>/mingw64/bin
|
|
23
|
+
// <root>/mingw64/libexec/git-core -> <root>/mingw64/bin (ucrt64 from Git 2.56 on)
|
|
24
24
|
const execPath = await run('git', ['--exec-path']);
|
|
25
25
|
if (succeeded(execPath)) {
|
|
26
26
|
const mingw = dirname(dirname(execPath.stdout.trim()));
|
|
@@ -100,7 +100,8 @@ function toAccount(raw) {
|
|
|
100
100
|
}
|
|
101
101
|
/** Arguments for a github.com profile field. `--hostname` so GH_HOST cannot redirect the call. */
|
|
102
102
|
export function ghProfileArgs(login, field) {
|
|
103
|
-
|
|
103
|
+
// One path segment, whatever the login holds (callers also look up only GitHub-shaped logins).
|
|
104
|
+
return ['api', '--hostname', 'github.com', `users/${encodeURIComponent(login)}`, '--jq', `.${field}`];
|
|
104
105
|
}
|
|
105
106
|
/** A profile field from github.com, or null. Absence here is unremarkable. */
|
|
106
107
|
export async function ghProfileField(login, field) {
|
package/dist/core/git.js
CHANGED
|
@@ -75,6 +75,24 @@ export class Git {
|
|
|
75
75
|
async remotes() {
|
|
76
76
|
return lines(await this.exec(['remote']));
|
|
77
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* The URL `git push <remote>` uses, as the pre-push hook receives it: pushurl, then
|
|
80
|
+
* pushInsteadOf and insteadOf applied by git itself (the first, when there are several).
|
|
81
|
+
* The raw keys only when git can't say (an old git without `remote get-url`).
|
|
82
|
+
*/
|
|
83
|
+
async remotePushUrl(remote) {
|
|
84
|
+
const asked = output(await this.exec(['remote', 'get-url', '--push', '--', remote]));
|
|
85
|
+
if (asked)
|
|
86
|
+
return asked;
|
|
87
|
+
return (await this.getConfig('remote.' + remote + '.pushurl')) ?? this.getConfig('remote.' + remote + '.url');
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* A bare URL after git's insteadOf rewriting (`ls-remote --get-url` contacts nothing).
|
|
91
|
+
* It reads fetch rules, so a pushInsteadOf on a bare push URL is not applied.
|
|
92
|
+
*/
|
|
93
|
+
async rewrittenUrl(url) {
|
|
94
|
+
return output(await this.exec(['ls-remote', '--get-url', '--', url]));
|
|
95
|
+
}
|
|
78
96
|
/** Remote names, in the order git lists them. A failed read is an error, not "none". */
|
|
79
97
|
async readRemotes() {
|
|
80
98
|
const listed = await this.exec(['remote']);
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
// SSH remote pins no credential key rather than one that selects nothing.
|
|
11
11
|
import { credentialPrefix } from '../url.js';
|
|
12
12
|
import { ghProfileField, ghProfileLookup } from '../credential/gh.js';
|
|
13
|
+
import { printable } from '../../ui/format.js';
|
|
13
14
|
const HOSTS = ['github.com', 'gist.github.com', 'www.github.com', 'ssh.github.com'];
|
|
14
15
|
export function githubProvider() {
|
|
15
16
|
return {
|
|
@@ -25,15 +26,30 @@ export function githubProvider() {
|
|
|
25
26
|
function credentialKeys(url) {
|
|
26
27
|
return url.scheme === 'https' ? [`credential.${credentialPrefix(url)}.username`] : [];
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
/**
|
|
30
|
+
* GitHub's own login shape (an underscore for Enterprise Managed Users). Nothing else is
|
|
31
|
+
* looked up: a typed `../user` would make `users/../user` GitHub's own `/user`, the
|
|
32
|
+
* signed-in account, and suggest its name and address for another login.
|
|
33
|
+
*/
|
|
34
|
+
export function githubLogin(login) {
|
|
35
|
+
return /^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(login);
|
|
36
|
+
}
|
|
37
|
+
function resolveProfile(account) {
|
|
38
|
+
return profileFrom(account, ghProfileField);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The suggestion for a GitHub-shaped login. A name that printable() would change (control,
|
|
42
|
+
* bidi, zero-width characters) is dropped: it would be drawn, and saved if accepted.
|
|
43
|
+
*/
|
|
44
|
+
export async function profileFrom(account, read) {
|
|
45
|
+
if (!githubLogin(account))
|
|
46
|
+
return null;
|
|
47
|
+
const [found, id] = await Promise.all([read(account, 'name'), read(account, 'id')]);
|
|
48
|
+
const name = found && printable(found) === found ? found : null;
|
|
33
49
|
// GitHub's own noreply address: publishable by design, and it still links
|
|
34
50
|
// the commit to the account. Offered as a default so a private address
|
|
35
51
|
// need never be published to get working attribution.
|
|
36
|
-
const email = id ? `${id}+${account}@users.noreply.github.com` : undefined;
|
|
52
|
+
const email = id && /^\d+$/.test(id) ? `${id}+${account}@users.noreply.github.com` : undefined;
|
|
37
53
|
if (!name && !email)
|
|
38
54
|
return null;
|
|
39
55
|
return { ...(name ? { name } : {}), ...(email ? { email } : {}) };
|
|
@@ -46,8 +62,17 @@ export function isNoreplyAddress(email) {
|
|
|
46
62
|
* The users endpoint answers for an organisation too, with type Organization.
|
|
47
63
|
* Anything else, including a failed call, is unknown -- not a user.
|
|
48
64
|
*/
|
|
49
|
-
|
|
50
|
-
|
|
65
|
+
function accountKind(login) {
|
|
66
|
+
return kindFrom(login, ghProfileLookup);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* What github.com says a login is. One GitHub can't have (a dot, a slash, a leading dash)
|
|
70
|
+
* is missing without asking: the typo still gets its sentence, and nothing reaches the API.
|
|
71
|
+
*/
|
|
72
|
+
export async function kindFrom(login, lookup) {
|
|
73
|
+
if (!githubLogin(login))
|
|
74
|
+
return 'missing';
|
|
75
|
+
const found = await lookup(login, 'type');
|
|
51
76
|
if (found.missing)
|
|
52
77
|
return 'missing';
|
|
53
78
|
if (found.value === 'User')
|
package/dist/core/inspect.js
CHANGED
|
@@ -19,20 +19,31 @@ export async function inspectRepo(git) {
|
|
|
19
19
|
const url = originUrl ? parseGitUrl(originUrl) : null;
|
|
20
20
|
const provider = providerFor(url);
|
|
21
21
|
const credentialKeys = url ? provider.credentialKeys(url) : [];
|
|
22
|
-
const [root, branch, hook, identity, guard, helper] = await Promise.all([
|
|
22
|
+
const [root, branch, hook, identity, guard, helper, pushed] = await Promise.all([
|
|
23
23
|
isRepo ? git.root() : Promise.resolve(null),
|
|
24
24
|
isRepo ? git.currentBranch() : Promise.resolve(null),
|
|
25
25
|
isRepo ? hookLocation(git) : Promise.resolve(null),
|
|
26
26
|
readIdentity(git, credentialKeys[0] ?? null),
|
|
27
27
|
isRepo ? guardState(git) : Promise.resolve('off'),
|
|
28
28
|
git.getUrlMatch('credential.helper', originUrl ?? DEFAULT_PROBE_URL),
|
|
29
|
+
pushSide(git, originUrl),
|
|
29
30
|
]);
|
|
30
31
|
return {
|
|
31
32
|
git, isRepo, root, branch, originUrl, url, provider,
|
|
32
|
-
owner:
|
|
33
|
+
owner: pushed.owner, ownerProvider: pushed.provider,
|
|
33
34
|
identity, credentialKeys, guard, hook, helper,
|
|
34
35
|
};
|
|
35
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Who origin's pushes go to, and on which host: the URL git pushes to (pushurl,
|
|
39
|
+
* pushInsteadOf, insteadOf), the one the guard checks, not the configured fetch URL the
|
|
40
|
+
* credentials follow. The owner and its host always come from that same URL.
|
|
41
|
+
*/
|
|
42
|
+
async function pushSide(git, originUrl) {
|
|
43
|
+
const pushed = originUrl ? parseGitUrl((await git.remotePushUrl('origin')) ?? originUrl) : null;
|
|
44
|
+
const provider = providerFor(pushed);
|
|
45
|
+
return { owner: pushed ? provider.ownerOf(pushed) : null, provider };
|
|
46
|
+
}
|
|
36
47
|
export async function inspectAuth(git, probeUrl) {
|
|
37
48
|
const gcmPath = await findGcm();
|
|
38
49
|
const [stored, gh, present, helper, ghHelperOrigins] = await Promise.all([
|
package/dist/core/push-state.js
CHANGED
|
@@ -55,7 +55,7 @@ async function repointOf(git, branch) {
|
|
|
55
55
|
async function destinationOf(git, target) {
|
|
56
56
|
if (!target)
|
|
57
57
|
return null;
|
|
58
|
-
const raw = target.isRemote ? await pushUrlOf(git, target.name) : target.name;
|
|
58
|
+
const raw = target.isRemote ? await pushUrlOf(git, target.name) : await bareTargetUrl(git, target.name);
|
|
59
59
|
const url = raw ? parseGitUrl(raw) : null;
|
|
60
60
|
const owner = url ? providerFor(url).ownerOf(url) : null;
|
|
61
61
|
if (!owner)
|
|
@@ -63,8 +63,12 @@ async function destinationOf(git, target) {
|
|
|
63
63
|
const allowed = (await git.getAllConfig('repown.allowOwner', 'local')).map((value) => value.toLowerCase());
|
|
64
64
|
return { remote: target.isRemote ? target.name : null, owner, allowed };
|
|
65
65
|
}
|
|
66
|
-
|
|
67
|
-
return
|
|
66
|
+
function pushUrlOf(git, remote) {
|
|
67
|
+
return git.remotePushUrl(remote);
|
|
68
|
+
}
|
|
69
|
+
/** A push straight to a URL, as git rewrites it (insteadOf; see rewrittenUrl). */
|
|
70
|
+
async function bareTargetUrl(git, url) {
|
|
71
|
+
return (await git.rewrittenUrl(url)) ?? url;
|
|
68
72
|
}
|
|
69
73
|
/** Only the tracked ref ON the destination: a triangular workflow's upstream does not block its push. */
|
|
70
74
|
async function divergenceOf(git, target) {
|
package/dist/core/registry.js
CHANGED
|
@@ -69,13 +69,20 @@ function readAccounts(value) {
|
|
|
69
69
|
}
|
|
70
70
|
return { accounts, unreadable };
|
|
71
71
|
}
|
|
72
|
+
/** Why a write would fail or drop entries, or null when it would keep every entry. */
|
|
73
|
+
export function writeProblem(registry) {
|
|
74
|
+
if (!registry.ok)
|
|
75
|
+
return registry.error;
|
|
76
|
+
if (registry.value.unreadable.length === 0)
|
|
77
|
+
return null;
|
|
78
|
+
return registryPath() + ' has entries repown cannot read (' + registry.value.unreadable.join(', ') +
|
|
79
|
+
') -- saving would drop them; fix or remove them first';
|
|
80
|
+
}
|
|
72
81
|
/** The registry, but only if a write would keep every entry in it. */
|
|
73
82
|
async function loadForWrite() {
|
|
74
83
|
const registry = await loadRegistry();
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return err(registryPath() + ' has entries repown cannot read (' + registry.value.unreadable.join(', ') +
|
|
78
|
-
') -- saving would drop them; fix or remove them first');
|
|
84
|
+
const problem = writeProblem(registry);
|
|
85
|
+
return problem === null || !registry.ok ? registry : err(problem);
|
|
79
86
|
}
|
|
80
87
|
export async function lookupAccount(account) {
|
|
81
88
|
const registry = await loadRegistry();
|
package/dist/wizard/home-run.js
CHANGED
|
@@ -16,7 +16,8 @@ import { renderTopHelp } from '../ui/help.js';
|
|
|
16
16
|
import { CANCEL, runFlow } from './engine.js';
|
|
17
17
|
import { readHome, readSignedIn } from './home-context.js';
|
|
18
18
|
import { BACK as HOME_BACK, MENU, accountChoices, accountOfChoice, commandFor, homeNote, listedClones, menuItems, summaryLines } from './home-flow.js';
|
|
19
|
-
import { BACK_LABEL, BUSY, CANCELLED, QUIT, WHAT_NEXT, WHICH_ACCOUNT, WHICH_CLONE, homeTitle, removeLabel, removeNote, removeQuestion } from './home-text.js';
|
|
19
|
+
import { BACK_LABEL, BUSY, CANCELLED, QUIT, WHAT_NEXT, WHICH_ACCOUNT, WHICH_CLONE, homeTitle, recordBlocked, removeLabel, removeNote, removeQuestion } from './home-text.js';
|
|
20
|
+
import { writeProblem } from '../core/registry.js';
|
|
20
21
|
import { formatCommand, loginStep, newAccountOf, printable, profileSteps } from './setup-flow.js';
|
|
21
22
|
import { COMMAND_MARK } from './review-text.js';
|
|
22
23
|
import { suggester } from './setup-context.js';
|
|
@@ -103,6 +104,12 @@ async function runInClone(prompter, cwd) {
|
|
|
103
104
|
* then `accounts add` with every answer as a flag, so it has nothing left to ask.
|
|
104
105
|
*/
|
|
105
106
|
async function recordAccount(prompter, home, deps) {
|
|
107
|
+
// The same reasons accounts add would give on save, before anyone answers four questions for nothing.
|
|
108
|
+
const blocked = writeProblem(home.registry);
|
|
109
|
+
if (blocked) {
|
|
110
|
+
prompter.note(recordBlocked(printable(blocked)));
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
106
113
|
const ctx = accountContext(home, deps);
|
|
107
114
|
const walk = await runFlow({ steps: [loginStep(ctx), ...profileSteps(ctx)] }, ctx, FIRST_PASS, prompter);
|
|
108
115
|
if (walk.status === 'cancelled')
|
package/dist/wizard/home-text.js
CHANGED
|
@@ -44,6 +44,10 @@ export function unreadableLine(recorded, unreadable, path) {
|
|
|
44
44
|
const tail = unreadable + ' unreadable in ' + path + ': run repown accounts list';
|
|
45
45
|
return recorded === 0 ? tail : recorded + ' recorded, ' + tail;
|
|
46
46
|
}
|
|
47
|
+
/** Said instead of the account questions when the answers could not be saved anyway. */
|
|
48
|
+
export function recordBlocked(reason) {
|
|
49
|
+
return 'Record an account needs an account list it can save: ' + reason.replace(/\.$/, '') + '. Nothing was asked.';
|
|
50
|
+
}
|
|
47
51
|
export function couldNotRead(path) {
|
|
48
52
|
return 'could not read ' + path;
|
|
49
53
|
}
|
|
@@ -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));
|
|
@@ -290,7 +290,7 @@ function loginPrefill(answers, found, ctx) {
|
|
|
290
290
|
if (found.name || typeof answers['name'] === 'string')
|
|
291
291
|
return null;
|
|
292
292
|
const answered = found.email !== undefined && hostOf(answers, ctx) === 'github';
|
|
293
|
-
return answered ? 'GitHub
|
|
293
|
+
return answered ? 'GitHub gives no usable name for ' + printable(accountOf(answers)) + ', so this is the login' : 'this is the login';
|
|
294
294
|
}
|
|
295
295
|
function machineName(ctx) {
|
|
296
296
|
const name = ctx.machineIdentity.name;
|
|
@@ -420,7 +420,7 @@ export const SOURCE_GH = 'signed in to gh';
|
|
|
420
420
|
export const SOURCE_GCM = 'stored in Git Credential Manager';
|
|
421
421
|
const OWNER_UNKNOWN = SOURCE_OWNS + '; may be an organisation';
|
|
422
422
|
function accountChoices(ctx) {
|
|
423
|
-
const recorded = Object.entries(ctx.recorded).map(([account, entry]) => ({ value: account, label: account, hint: entry.name + ' <' + entry.email + '>' }));
|
|
423
|
+
const recorded = Object.entries(ctx.recorded).map(([account, entry]) => ({ value: account, label: printable(account), hint: printable(entry.name + ' <' + entry.email + '>') }));
|
|
424
424
|
const detected = ctx.detected.map((account) => detectedChoice(account, ctx));
|
|
425
425
|
return [...recorded, ...detected, { value: NEW_ACCOUNT, label: 'a new account', hint: 'record another account on this machine' }];
|
|
426
426
|
}
|
|
@@ -491,6 +491,8 @@ const LOGIN = /^[\w.@-]+$/;
|
|
|
491
491
|
export function loginProblem(value) {
|
|
492
492
|
if (!value.trim())
|
|
493
493
|
return 'a value is required';
|
|
494
|
+
if (/^\.+$/.test(value))
|
|
495
|
+
return 'a login can\'t be only dots';
|
|
494
496
|
return LOGIN.test(value) ? null : 'use letters, digits and . _ @ - only';
|
|
495
497
|
}
|
|
496
498
|
function newAccountProblem(value, ctx) {
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "repown",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
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.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"bin": {
|
|
12
12
|
"repown": "dist/cli.js"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "repown",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
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",
|