repown 0.5.3 → 0.5.4
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 +10 -1
- package/dist/core/guard/hook.js +8 -6
- package/dist/core/inspect.js +3 -3
- package/dist/core/push-state.js +15 -10
- package/dist/wizard/setup-run.js +3 -2
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,14 @@ commands. How a release is cut: [docs/RELEASING.md](docs/RELEASING.md).
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.5.4] - 2026-10-12
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- Reading a clone starts up to three fewer git processes (about 75 ms each on
|
|
14
|
+
Windows): the guard's state now comes from the hook location already read, and the
|
|
15
|
+
sign-in and later-push-URL checks share one read of origin's push URLs. Output is
|
|
16
|
+
unchanged.
|
|
17
|
+
|
|
10
18
|
## [0.5.3] - 2026-10-11
|
|
11
19
|
|
|
12
20
|
### Fixed
|
|
@@ -326,7 +334,8 @@ and cmd. `status`, `doctor` and the pre-push guard are faster on Windows.
|
|
|
326
334
|
contract for scripts.
|
|
327
335
|
- Runs on Node 20+ on Windows, macOS and Linux, with zero runtime dependencies.
|
|
328
336
|
|
|
329
|
-
[Unreleased]: https://github.com/makubexD/repown/compare/v0.5.
|
|
337
|
+
[Unreleased]: https://github.com/makubexD/repown/compare/v0.5.4...HEAD
|
|
338
|
+
[0.5.4]: https://github.com/makubexD/repown/compare/v0.5.3...v0.5.4
|
|
330
339
|
[0.5.3]: https://github.com/makubexD/repown/compare/v0.5.2...v0.5.3
|
|
331
340
|
[0.5.2]: https://github.com/makubexD/repown/compare/v0.5.1...v0.5.2
|
|
332
341
|
[0.5.1]: https://github.com/makubexD/repown/compare/v0.5.0...v0.5.1
|
package/dist/core/guard/hook.js
CHANGED
|
@@ -51,10 +51,6 @@ async function hookDirs(git) {
|
|
|
51
51
|
return null;
|
|
52
52
|
return { own: join(resolve(git.cwd, common), 'hooks'), effective: resolve(git.cwd, hooks) };
|
|
53
53
|
}
|
|
54
|
-
/** The pre-push hook git will actually RUN -- through core.hooksPath if that is set. */
|
|
55
|
-
export async function hookPath(git) {
|
|
56
|
-
return (await hookLocation(git))?.path ?? null;
|
|
57
|
-
}
|
|
58
54
|
export async function hookLocation(git) {
|
|
59
55
|
const dirs = await hookDirs(git);
|
|
60
56
|
return dirs ? { path: join(dirs.effective, 'pre-push'), redirected: isRedirected(dirs) } : null;
|
|
@@ -88,8 +84,14 @@ function redirectMessage(dirs) {
|
|
|
88
84
|
'pre-push hook run: repown guard check --remote="$1" --url="$2"';
|
|
89
85
|
}
|
|
90
86
|
export async function guardState(git) {
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
return guardStateAt(await hookLocation(git));
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The guard's state at a location already read, so one read need not ask git twice. Only a
|
|
91
|
+
* location from this same read: after a write or a wait, read it again (ADR-029).
|
|
92
|
+
*/
|
|
93
|
+
export async function guardStateAt(location) {
|
|
94
|
+
return location ? stateOf(location.path) : 'off';
|
|
93
95
|
}
|
|
94
96
|
/**
|
|
95
97
|
* The PATH fallback trusts a `repown` only if it SAYS it is repown. Without this, any
|
package/dist/core/inspect.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { parseGitUrl } from './url.js';
|
|
10
10
|
import { providerFor } from './hosts/index.js';
|
|
11
11
|
import { readIdentity } from './identity.js';
|
|
12
|
-
import {
|
|
12
|
+
import { guardStateAt, hookLocation } from './guard/hook.js';
|
|
13
13
|
import { findGcm, listAccounts, isGcm } from './credential/gcm.js';
|
|
14
14
|
import { ghState, ghInstalled, isGh } from './credential/gh.js';
|
|
15
15
|
const DEFAULT_PROBE_URL = 'https://github.com/';
|
|
@@ -18,14 +18,14 @@ export async function inspectRepo(git) {
|
|
|
18
18
|
const originUrl = isRepo ? await git.getConfig('remote.origin.url') : null;
|
|
19
19
|
const url = originUrl ? parseGitUrl(originUrl) : null;
|
|
20
20
|
const sides = await originSides(git, originUrl);
|
|
21
|
-
const [root, branch, hook, identity,
|
|
21
|
+
const [root, branch, hook, identity, helper] = await Promise.all([
|
|
22
22
|
isRepo ? git.root() : Promise.resolve(null),
|
|
23
23
|
isRepo ? git.currentBranch() : Promise.resolve(null),
|
|
24
24
|
isRepo ? hookLocation(git) : Promise.resolve(null),
|
|
25
25
|
readIdentity(git, sides.credential.keys[0] ?? null),
|
|
26
|
-
isRepo ? guardState(git) : Promise.resolve('off'),
|
|
27
26
|
git.getUrlMatch('credential.helper', sides.credential.url ?? DEFAULT_PROBE_URL),
|
|
28
27
|
]);
|
|
28
|
+
const guard = await guardStateAt(hook);
|
|
29
29
|
return {
|
|
30
30
|
git, isRepo, root, branch, originUrl, url, provider: providerFor(url),
|
|
31
31
|
owner: sides.owner, ownerProvider: sides.ownerProvider,
|
package/dist/core/push-state.js
CHANGED
|
@@ -16,8 +16,14 @@ export async function readPushFacts(git, unpushed, env = process.env) {
|
|
|
16
16
|
const branch = head?.kind === 'branch' ? head.name : null;
|
|
17
17
|
const target = branch ? await pushTarget(git, branch) : null;
|
|
18
18
|
const rewritable = await rewritableOf(git, target);
|
|
19
|
+
// A remote target's push URLs, read once for the sign-in and later-URL checks.
|
|
20
|
+
const pushed = target?.isRemote ? git.remoteUrls(target.name, true) : null;
|
|
19
21
|
const [configOverrides, signin, repoint, destination, laterUrls, divergence, elsewhere, upstream] = await Promise.all([
|
|
20
|
-
overridesIn(git),
|
|
22
|
+
overridesIn(git),
|
|
23
|
+
signinOf(git, target, { rewritable: rewritable !== null, pushed }),
|
|
24
|
+
repointOf(git, branch),
|
|
25
|
+
rewritable ? null : destinationOf(git, target),
|
|
26
|
+
laterUrlsOf(git, target, pushed),
|
|
21
27
|
divergenceOf(git, target), elsewhereOf(git, target), upstreamOf(git, branch, target),
|
|
22
28
|
]);
|
|
23
29
|
return {
|
|
@@ -34,8 +40,9 @@ function carriesSecret(raw) {
|
|
|
34
40
|
const user = raw ? parseGitUrl(raw)?.user : null;
|
|
35
41
|
return !!user && (user.includes(':') || /^(gh[pousr]_|github_pat_)/i.test(user));
|
|
36
42
|
}
|
|
37
|
-
async function signinOf(git, target, rewritable) {
|
|
38
|
-
const found = target
|
|
43
|
+
async function signinOf(git, target, { rewritable, pushed }) {
|
|
44
|
+
const found = pushed && target ? await remoteSignin(git, target.name, await pushed)
|
|
45
|
+
: target && !rewritable ? await bareSignin(git, target) : null;
|
|
39
46
|
if (found)
|
|
40
47
|
return found;
|
|
41
48
|
const headers = await git.configOrigins('^http\\.(.*\\.)?extraheader$');
|
|
@@ -57,8 +64,7 @@ async function bareSignin(git, target) {
|
|
|
57
64
|
* adds is found and one a rule takes out is not. A URL that is a configured value is named
|
|
58
65
|
* by its key; any other came from a rewrite, and only the remote is named.
|
|
59
66
|
*/
|
|
60
|
-
async function remoteSignin(git, remote) {
|
|
61
|
-
const pushed = await git.remoteUrls(remote, true);
|
|
67
|
+
async function remoteSignin(git, remote, pushed) {
|
|
62
68
|
if (!pushed.ok)
|
|
63
69
|
return configuredSignin(git, remote);
|
|
64
70
|
const signed = pushed.value.find(carriesSecret);
|
|
@@ -96,10 +102,10 @@ async function destinationOf(git, target) {
|
|
|
96
102
|
const allowed = (await git.getAllConfig('repown.allowOwner', 'local')).map((value) => value.toLowerCase());
|
|
97
103
|
return { remote: target.isRemote ? target.name : null, owner, allowed };
|
|
98
104
|
}
|
|
99
|
-
async function laterUrlsOf(git, target) {
|
|
100
|
-
if (!target?.isRemote)
|
|
105
|
+
async function laterUrlsOf(git, target, pushed) {
|
|
106
|
+
if (!target?.isRemote || !pushed)
|
|
101
107
|
return null;
|
|
102
|
-
const urls = [...new Set(await pushUrlsOf(git, target.name))];
|
|
108
|
+
const urls = [...new Set(await pushUrlsOf(git, target.name, await pushed))];
|
|
103
109
|
if (urls.length < 2)
|
|
104
110
|
return null;
|
|
105
111
|
const owners = urls.slice(1).flatMap((raw) => {
|
|
@@ -112,8 +118,7 @@ async function laterUrlsOf(git, target) {
|
|
|
112
118
|
return { remote: target.name, owners, allowed };
|
|
113
119
|
}
|
|
114
120
|
/** Every URL git pushes `remote` with; a git that cannot list them gets the configured values. */
|
|
115
|
-
async function pushUrlsOf(git, remote) {
|
|
116
|
-
const listed = await git.remoteUrls(remote, true);
|
|
121
|
+
async function pushUrlsOf(git, remote, listed) {
|
|
117
122
|
if (listed.ok)
|
|
118
123
|
return listed.value;
|
|
119
124
|
const pushurls = await git.getAllConfig('remote.' + remote + '.pushurl');
|
package/dist/wizard/setup-run.js
CHANGED
|
@@ -25,7 +25,7 @@ import { plainPrompter } from './plain.js';
|
|
|
25
25
|
import { COMMAND_MARK } from './review-text.js';
|
|
26
26
|
import { blockers } from '../core/blockers.js';
|
|
27
27
|
import { readPushFacts } from '../core/push-state.js';
|
|
28
|
-
import {
|
|
28
|
+
import { guardStateAt, hookLocation } from '../core/guard/hook.js';
|
|
29
29
|
import { readUnpushed } from '../core/unpushed.js';
|
|
30
30
|
const CANCELLED = 130;
|
|
31
31
|
export async function runSetup(args, deps) {
|
|
@@ -365,7 +365,8 @@ function closing(account, found) {
|
|
|
365
365
|
/** Re-read after the run: a step may have fixed what the review showed, or not. */
|
|
366
366
|
async function blockersNow(git, account) {
|
|
367
367
|
const email = await git.getConfig('user.email', 'local') ?? '';
|
|
368
|
-
const [facts,
|
|
368
|
+
const [facts, hook] = await Promise.all([readPushFacts(git, await readUnpushed(git)), hookLocation(git)]);
|
|
369
|
+
const guard = await guardStateAt(hook);
|
|
369
370
|
return blockers(facts, { email, account, autoUpstream: false, guarded: guard !== 'off' || hook?.redirected === true });
|
|
370
371
|
}
|
|
371
372
|
async function printClone(before, state) {
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "repown",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
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.4",
|
|
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.4",
|
|
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",
|