repown 0.1.0 → 0.2.0
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 +66 -1
- package/README.md +310 -150
- package/dist/cli.js +15 -6
- package/dist/commands/doctor.js +323 -50
- package/dist/commands/fix.js +14 -12
- package/dist/commands/guard.js +10 -2
- package/dist/commands/scan.js +1 -1
- package/dist/commands/setup.js +27 -0
- package/dist/commands/start.js +38 -0
- package/dist/commands/status.js +244 -41
- package/dist/commands/use.js +139 -10
- package/dist/core/credential/gh.js +96 -9
- package/dist/core/exec.js +55 -6
- package/dist/core/git.js +43 -1
- package/dist/core/guard/check.js +1 -1
- package/dist/core/guard/hook.js +11 -2
- package/dist/core/hosts/github.js +31 -14
- package/dist/core/identity.js +28 -2
- package/dist/core/inspect.js +3 -2
- package/dist/core/unpushed.js +110 -0
- package/dist/core/version.js +17 -0
- package/dist/ui/args.js +2 -1
- package/dist/ui/dispatch.js +15 -5
- package/dist/ui/format.js +15 -1
- package/dist/ui/help.js +9 -5
- package/dist/wizard/clack.js +117 -0
- package/dist/wizard/engine.js +244 -0
- package/dist/wizard/plain.js +172 -0
- package/dist/wizard/review-text.js +110 -0
- package/dist/wizard/setup-changes.js +73 -0
- package/dist/wizard/setup-context.js +256 -0
- package/dist/wizard/setup-flow.js +728 -0
- package/dist/wizard/setup-run.js +459 -0
- package/npm-shrinkwrap.json +121 -0
- package/package.json +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,69 @@ commands. How a release is cut: [docs/RELEASING.md](docs/RELEASING.md).
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.2.0] - 2026-09-28
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- `repown setup`: a guided setup of the clone you're in. It asks which account owns
|
|
15
|
+
it (and records a new one), whether this clone may push to origin's owner, whether
|
|
16
|
+
to turn the guard on, whether to push branches without `-u` (git 2.37+), whether to
|
|
17
|
+
switch gh or sign the account in to gh, and whether to stop gh being git's
|
|
18
|
+
credential helper (`fix`, machine-wide). The review lists only steps that would
|
|
19
|
+
change something, nothing changes until you choose Run, and the run ends by listing
|
|
20
|
+
what changed in the clone and on the machine.
|
|
21
|
+
- **Recommended** (the default) asks only what it must and fills in the rest; the
|
|
22
|
+
steps still show in the review, where you can change any answer. **Step by step**
|
|
23
|
+
(`--step-by-step`) asks every question, then confirms each step (Yes, Skip or
|
|
24
|
+
Stop) before running it.
|
|
25
|
+
- The first question lists the accounts it can already see (origin's owner, gh's,
|
|
26
|
+
Git Credential Manager's) and suggests the one that owns the repository.
|
|
27
|
+
- Every question is also a flag, and `--no-input` runs it from a script. Exit
|
|
28
|
+
codes: 0 done or already set up, 1 declined or can't start, 2 for flags that
|
|
29
|
+
don't fit, 130 on Esc or Ctrl-C, and a failed step's own code.
|
|
30
|
+
- A clone that is already set up opens on **This clone is already set up**, with
|
|
31
|
+
Done, Use another account, and a gh option when gh acts as someone else.
|
|
32
|
+
- In a plain terminal it asks with numbered choices.
|
|
33
|
+
- `repown use <account> --gh` signs the account in to gh when gh doesn't list it
|
|
34
|
+
(in a terminal, gh 2.40 or later).
|
|
35
|
+
- `repown use` warns about commits on the branch that no remote has yet and that
|
|
36
|
+
another address authored, which the guard would refuse, and prints the rebase that
|
|
37
|
+
re-authors them. Setup's review notes the same.
|
|
38
|
+
- `repown guard on` warns when it runs from npx's cache, because the hook would call a
|
|
39
|
+
temporary copy that later disappears.
|
|
40
|
+
- One optional runtime dependency, `@clack/prompts` 1.8.1, pinned and locked by the
|
|
41
|
+
`npm-shrinkwrap.json` that now ships. Only `repown setup` loads it, never the
|
|
42
|
+
pre-push hook; where it can't load, setup falls back to plain prompts.
|
|
43
|
+
|
|
44
|
+
### Changed
|
|
45
|
+
|
|
46
|
+
- In a terminal, bare `repown` in a clone always opens `repown setup`, set up or not.
|
|
47
|
+
Outside a clone it shows help; without a terminal, or with output redirected, it
|
|
48
|
+
still prints status, so scripts and CI get the report.
|
|
49
|
+
- `repown status` says what it shows: a title, the clone's path and branch, "This
|
|
50
|
+
clone" and "This machine" groups, the branch's upstream, whether the account is
|
|
51
|
+
recorded, and a closing count. The verdict comes first. gh acting as another
|
|
52
|
+
account is an optional note, not a warning, and it names a gh fix that works.
|
|
53
|
+
- `repown doctor` shows each account's readiness for git and for gh, and ends with
|
|
54
|
+
one verdict line. The SSO reminder is one sentence naming the host.
|
|
55
|
+
- On Windows, `status` and `doctor` show paths with backslashes.
|
|
56
|
+
- Docs: the README starts with `repown setup` and keeps what a new user needs.
|
|
57
|
+
Configuration moved to docs/CONFIGURATION.md, and the FAQ and the comparison with
|
|
58
|
+
other approaches to docs/FAQ.md. SECURITY.md explains private reporting.
|
|
59
|
+
|
|
60
|
+
### Fixed
|
|
61
|
+
|
|
62
|
+
- `repown help scan` said `--emails` dropped the counts; it keeps them and shows
|
|
63
|
+
exact addresses instead of domains.
|
|
64
|
+
|
|
65
|
+
## [0.1.1] - 2026-09-25
|
|
66
|
+
|
|
67
|
+
- Fixed: `repown use -` (and `accounts add -`, `accounts remove -`, `scan -`) is a
|
|
68
|
+
usage error again. 0.1.0 read the bare `-` as a name and pinned an account called
|
|
69
|
+
"-".
|
|
70
|
+
- Unknown commands and actions now say which `repown help` to run.
|
|
71
|
+
- Published from GitHub Actions through npm trusted publishing, with provenance.
|
|
72
|
+
|
|
10
73
|
## [0.1.0] - 2026-09-25
|
|
11
74
|
|
|
12
75
|
- First release on npm: `npm install -g repown`.
|
|
@@ -23,5 +86,7 @@ commands. How a release is cut: [docs/RELEASING.md](docs/RELEASING.md).
|
|
|
23
86
|
contract for scripts.
|
|
24
87
|
- Runs on Node 20+ on Windows, macOS and Linux, with zero runtime dependencies.
|
|
25
88
|
|
|
26
|
-
[Unreleased]: https://github.com/makubexD/repown/compare/v0.
|
|
89
|
+
[Unreleased]: https://github.com/makubexD/repown/compare/v0.2.0...HEAD
|
|
90
|
+
[0.2.0]: https://github.com/makubexD/repown/compare/v0.1.1...v0.2.0
|
|
91
|
+
[0.1.1]: https://github.com/makubexD/repown/compare/v0.1.0...v0.1.1
|
|
27
92
|
[0.1.0]: https://github.com/makubexD/repown/releases/tag/v0.1.0
|
package/README.md
CHANGED
|
@@ -6,211 +6,371 @@
|
|
|
6
6
|
[](package.json)
|
|
7
7
|
[](LICENSE)
|
|
8
8
|
|
|
9
|
-
**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
**Stop committing and pushing as the wrong account when one machine has two or more.**
|
|
10
|
+
Each repository owns its identity (that's the name: *repo own*), so you move from a work
|
|
11
|
+
repo to a personal one to a client one, on any host or sign-in method, with no switch
|
|
12
|
+
command. A push carrying commits under the wrong identity is refused before it leaves.
|
|
13
|
+
|
|
14
|
+
**Day to day:**
|
|
14
15
|
|
|
15
16
|
```
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
~/code/work $ git push # 🟢 signs in as octo-work
|
|
18
|
+
~/code/personal $ git push # 🟢 signs in as octocat, no switch command
|
|
19
|
+
~/code/personal $ git push # 🔴 refused: a commit authored as octo-work
|
|
20
|
+
~/code/client $ repown status # 🟡 guard off: pushes are not checked
|
|
19
21
|
```
|
|
20
22
|
|
|
21
23
|
> **Status:** pre-1.0: the commands may still change. What changed in each version is in
|
|
22
24
|
> [CHANGELOG.md](CHANGELOG.md).
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
**Contents:** 🤔 [Why repown](#why-repown) · 📦 [Install](#install) ·
|
|
27
|
+
⚡ [Quick start](#quick-start) · ⌨️ [Commands](#commands) ·
|
|
28
|
+
🩺 [Troubleshooting](#troubleshooting) · 🛠️ [Set up by hand](#set-up-by-hand) ·
|
|
29
|
+
🧹 [Uninstall](#uninstall) · 📚 [More docs](#more-docs)
|
|
25
30
|
|
|
26
|
-
|
|
27
|
-
address becomes permanent once it's pushed to a public repository.
|
|
28
|
-
- **`gh auth switch` changes the account for the whole machine.** While `gh` is git's
|
|
29
|
-
credential helper, every switch breaks the *other* account's repositories. An
|
|
30
|
-
SSO-only account has no password to type at the prompt
|
|
31
|
-
([ADR-001](docs/decisions/ADR-001-credential-manager-not-gh.md)).
|
|
31
|
+
## Why repown
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
**The problem:**
|
|
34
34
|
|
|
35
|
-
- **
|
|
36
|
-
|
|
37
|
-
-
|
|
38
|
-
credential
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
-
|
|
35
|
+
- ❌ **Every clone inherits the identity in your global git config.** A commit's author
|
|
36
|
+
address becomes permanent once it's pushed to a public repository.
|
|
37
|
+
- ❌ **`gh auth switch` changes the account for the whole machine.** While `gh` (the GitHub
|
|
38
|
+
CLI) is git's *credential helper* (the program git asks for a password or token), every
|
|
39
|
+
switch breaks the *other* account's repositories. And if your organisation signs you in
|
|
40
|
+
through single sign-on (SSO), there's no password you could type at that prompt anyway
|
|
41
|
+
([ADR-001](docs/decisions/ADR-001-credential-manager-not-gh.md)).
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
work on every host ([ADR-009](docs/decisions/ADR-009-hosts-claim-only-measured.md)).
|
|
45
|
-
- **Guard every push:** `repown guard on` installs a `pre-push` hook that checks the
|
|
46
|
-
commits themselves, not just today's config.
|
|
43
|
+
**What repown does:**
|
|
47
44
|
|
|
48
|
-
**
|
|
45
|
+
- ✅ **Pins each clone.** It writes the commit identity and the push account into that
|
|
46
|
+
clone's own `.git/config`. That's what *pinned* means here: set once, never switched.
|
|
47
|
+
- ✅ **Lets one credential serve each account.**
|
|
48
|
+
[Git Credential Manager](https://github.com/git-ecosystem/git-credential-manager) (GCM)
|
|
49
|
+
stores one sign-in per account and picks the one each clone names. `repown doctor`
|
|
50
|
+
checks GCM is the helper; if gh has become it (`gh auth login` offers that),
|
|
51
|
+
`repown fix` removes gh's entries after showing them. `gh` stays your account store for
|
|
52
|
+
`gh pr create` and `gh api`.
|
|
53
|
+
- ✅ **Guards every push.** A git `pre-push` hook (a script git runs before every push),
|
|
54
|
+
the *guard*, checks the commits being pushed, not just today's config.
|
|
49
55
|
|
|
50
|
-
|
|
56
|
+
**Where it works:**
|
|
51
57
|
|
|
52
|
-
|
|
|
53
|
-
| --- | --- | --- | --- |
|
|
54
|
-
|
|
|
55
|
-
|
|
|
56
|
-
|
|
|
57
|
-
| `gh auth switch` | no | while gh is the helper, only the *active* account | no | Machine-wide: it breaks the other account's repos |
|
|
58
|
-
| **repown** | yes, per clone | yes, per clone (GitHub) | yes, once `repown guard on`: every commit the push would publish | `use` and `guard on` once per clone |
|
|
58
|
+
| | Commit identity | Guard | Push sign-in pinned |
|
|
59
|
+
| --- | --- | --- | --- |
|
|
60
|
+
| GitHub over https | ✅ | ✅ | ✅ (github.com) |
|
|
61
|
+
| GitHub over SSH | ✅ | ✅ | ➖ your key decides which account pushes |
|
|
62
|
+
| Azure DevOps and other hosts | ✅ | ✅ | ❌ not pinned ([ADR-009](docs/decisions/ADR-009-hosts-claim-only-measured.md)) |
|
|
59
63
|
|
|
60
|
-
|
|
61
|
-
credential manager you already have, and leaves `gh` in charge of the GitHub CLI.
|
|
64
|
+
Every scenario, with diagrams: [docs/HOW-IT-WORKS.md](docs/HOW-IT-WORKS.md).
|
|
62
65
|
|
|
63
66
|
## Install
|
|
64
67
|
|
|
65
|
-
|
|
68
|
+
**You need:**
|
|
69
|
+
|
|
70
|
+
- **Node 20+** and **git**, on Windows, macOS or Linux.
|
|
71
|
+
- **Git Credential Manager** for per-account sign-in on GitHub. Git for Windows includes
|
|
72
|
+
it; on macOS and Linux, follow
|
|
73
|
+
[GCM's install guide](https://github.com/git-ecosystem/git-credential-manager/blob/main/docs/install.md).
|
|
74
|
+
- **gh** is optional: repown reads it when it's there.
|
|
66
75
|
|
|
67
76
|
```
|
|
68
77
|
npm install -g repown
|
|
69
78
|
```
|
|
70
79
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
([ADR-003](docs/decisions/ADR-003-hook-calls-installed-cli.md)).
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
([
|
|
80
|
+
- **Install it globally:** the guard calls the installed repown. To try it first,
|
|
81
|
+
`npx repown` runs commands that only read (`repown status`, `repown doctor`,
|
|
82
|
+
`repown scan`), but don't turn the guard on through `npx`: its hook would call a
|
|
83
|
+
temporary copy ([card 12](docs/HOW-IT-WORKS.md#12-uninstall-or-repown-missing)).
|
|
84
|
+
- **Update** with `npm install -g repown@latest`; guarded clones keep working
|
|
85
|
+
([ADR-003](docs/decisions/ADR-003-hook-calls-installed-cli.md)).
|
|
86
|
+
- **What gets installed:** one optional dependency, for the arrow-key prompts (without it,
|
|
87
|
+
`setup` asks with numbered choices), pinned exactly
|
|
88
|
+
([ADR-016](docs/decisions/ADR-016-clack-for-the-setup-wizard.md)). The package is
|
|
89
|
+
published from CI with provenance ([how](SECURITY.md#how-the-package-is-published)).
|
|
81
90
|
|
|
82
|
-
##
|
|
91
|
+
## Quick start
|
|
83
92
|
|
|
84
|
-
|
|
85
|
-
|
|
93
|
+
```
|
|
94
|
+
repown doctor # once per machine: is Git Credential Manager ready for sign-ins?
|
|
95
|
+
cd ~/code/my-repo
|
|
96
|
+
repown # in a terminal: starts the guided setup of this clone
|
|
97
|
+
```
|
|
86
98
|
|
|
87
|
-
|
|
99
|
+
1. **`repown doctor`, once per machine.** It ends with a verdict:
|
|
100
|
+
- 🟢 `ready: each clone signs in as its own account through Git Credential Manager`
|
|
101
|
+
- 🔴 `1 problem: gh answers git's sign-in requests: run repown fix`
|
|
102
|
+
|
|
103
|
+
If gh is the helper, or something is missing, see [Troubleshooting](#troubleshooting).
|
|
104
|
+
2. **Clone as usual,** then from inside a new clone just type **`repown`.** That starts
|
|
105
|
+
the guided setup. **`repown setup`** still works. (Cloning a private repository signs
|
|
106
|
+
in first: pick the account that owns it.) It asks how setup should work. Recommended is
|
|
107
|
+
the default. Answers it fills in still appear in the review.
|
|
108
|
+
|
|
109
|
+
| Question | Recommended | Step by step | Flag |
|
|
110
|
+
| --- | --- | --- | --- |
|
|
111
|
+
| Which account should this clone belong to? | Asked. `repown setup <account>` skips the mode question and uses Recommended, so a recorded account goes straight to the review when nothing else must be asked. A new account also asks where it's hosted, the name and the email. | Asked | `<account>`, `--host`, `--name`, `--email` |
|
|
112
|
+
| Let this clone push to origin's owner? Asked when origin belongs to someone else, like an organisation. | Asked, default Yes. No means the guard refuses pushes there. | Asked, default Yes | `--allow-owner <owner>` |
|
|
113
|
+
| Turn the guard on? | Answers Yes without asking | Asked | `--guard` |
|
|
114
|
+
| Push branches without -u? Only on git 2.37+. It sets `push.autoSetupRemote` in this clone only; the guard still checks that first push. | Answers Yes without asking | Asked, default Yes | `--auto-upstream` |
|
|
115
|
+
| gh. "Switch gh too" makes `gh pr create` match. | Switches without asking when gh already lists the account and the clone is not already pinned to it. A sign-in, which opens a browser, is asked, default No. Skips the question when the clone is already pinned to that account. | Asked | `--gh` |
|
|
116
|
+
| Take git's sign-ins back from gh? Machine-wide. | Asked, default No. Answer Yes if `repown doctor` said gh is the helper, or pushes from your other account's clones fail. | Asked, default No | `--fix` |
|
|
117
|
+
|
|
118
|
+
Step by step asks every question: `--step-by-step`.
|
|
119
|
+
`--no-input` asks nothing ([scripts and CI](docs/CONFIGURATION.md#scripts-and-ci)).
|
|
120
|
+
|
|
121
|
+
- **In your first clone,** it lists the accounts it can already see on GitHub (origin's
|
|
122
|
+
owner, gh's accounts, Git Credential Manager's) and suggests origin's owner when that
|
|
123
|
+
owner is a user, or asks for the login. On GitHub, use your *noreply* address, shown
|
|
124
|
+
at github.com/settings/emails (like `1234+octocat@users.noreply.github.com`).
|
|
125
|
+
- **In later clones,** it lists the accounts it knows: pick one, or **a new account**.
|
|
126
|
+
3. **Check the review, then choose Run them.** Nothing changes before that:
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
◇ Review: nothing has changed yet ───────────────────────────────────────╮
|
|
130
|
+
│ │
|
|
131
|
+
│ This clone will commit and push as octocat. │
|
|
132
|
+
│ │
|
|
133
|
+
│ When you choose Run: │
|
|
134
|
+
│ 1. Let this clone push to octo-org's repositories │
|
|
135
|
+
│ git config --local --add repown.allowOwner octo-org │
|
|
136
|
+
│ 2. Pin this clone to octocat: its commit name, email and push sign-in │
|
|
137
|
+
│ repown use octocat │
|
|
138
|
+
│ 3. Turn on the push guard: each push is checked first │
|
|
139
|
+
│ repown guard on │
|
|
140
|
+
│ 4. Push branches without -u: the first push sets the upstream (this │
|
|
141
|
+
│ clone only) │
|
|
142
|
+
│ git config --local push.autoSetupRemote true │
|
|
143
|
+
│ │
|
|
144
|
+
│ These are ordinary commands: run them yourself, or in a script. │
|
|
145
|
+
│ This clone's settings go in its .git/config, which is never pushed. │
|
|
146
|
+
│ │
|
|
147
|
+
├─────────────────────────────────────────────────────────────────────────╯
|
|
148
|
+
│
|
|
149
|
+
◆ Run these 4 steps?
|
|
150
|
+
│ ● Run them
|
|
151
|
+
│ ○ Back
|
|
152
|
+
│ ○ Change an answer
|
|
153
|
+
│ ○ Decline
|
|
154
|
+
│ ↑/↓ to navigate • Enter: confirm
|
|
155
|
+
└
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
4. **Push.** The first push from each account signs in once: GCM opens a browser, and you
|
|
159
|
+
sign in as *that* clone's account, not whichever you used last. After that, pushes from
|
|
160
|
+
that clone use it without asking. When setup set `push.autoSetupRemote`, the first
|
|
161
|
+
`git push` of a branch without an upstream also creates it on origin. When it did not
|
|
162
|
+
(older git, a version repown could not read, or you answered No), use
|
|
163
|
+
`git push -u origin <branch>` once.
|
|
164
|
+
|
|
165
|
+
**Keys:** ↑/↓ choose, Enter confirms, Esc or Ctrl-C stops with nothing changed. From the
|
|
166
|
+
second question on, each list ends with **← Back**; at a typed answer, enter `<`. In a
|
|
167
|
+
plain terminal the questions come as numbered choices
|
|
168
|
+
([when](docs/CONFIGURATION.md#environment-variables)); there, Ctrl-C stops.
|
|
169
|
+
|
|
170
|
+
**Running it again.** Run `repown` in a clone that's already set up, or `repown setup`
|
|
171
|
+
with no account and no flags, and setup opens on this screen, before any question:
|
|
88
172
|
|
|
89
173
|
```
|
|
90
|
-
|
|
91
|
-
|
|
174
|
+
◇ This clone is already set up ─────────────────────────────────────╮
|
|
175
|
+
│ │
|
|
176
|
+
│ commits as Octo Cat <octocat@users.noreply.github.com> │
|
|
177
|
+
│ pushes as octocat │
|
|
178
|
+
│ guard on: every push is checked before it leaves │
|
|
179
|
+
│ upstream origin/main │
|
|
180
|
+
│ │
|
|
181
|
+
│ Nothing needs to change. │
|
|
182
|
+
│ │
|
|
183
|
+
│ Checked: the settings git uses here are octocat's, as recorded. │
|
|
184
|
+
│ See it any time: repown status (this clone), repown doctor (this │
|
|
185
|
+
│ machine) │
|
|
186
|
+
│ │
|
|
187
|
+
├────────────────────────────────────────────────────────────────────╯
|
|
188
|
+
│
|
|
189
|
+
◆ What now?
|
|
190
|
+
│ ● Done (change nothing)
|
|
191
|
+
│ ○ Use another account
|
|
192
|
+
│ ↑/↓ to navigate • Enter: confirm
|
|
193
|
+
└
|
|
194
|
+
```
|
|
92
195
|
|
|
93
|
-
|
|
94
|
-
|
|
196
|
+
**Done** changes nothing. **Use another account** asks which account this clone should
|
|
197
|
+
use. When gh acts as someone else, a third option is **Sign in to gh as `<account>`** (or
|
|
198
|
+
**Make `<account>` gh's active account** when gh already lists it) and runs
|
|
199
|
+
`repown use <account> --gh`. The upstream line shows the tracked branch (for example
|
|
200
|
+
`origin/main`) when there is one, otherwise `set on the first push (push.autoSetupRemote)`
|
|
201
|
+
when that setting is on, otherwise nothing. It is the same value `repown status` shows,
|
|
202
|
+
and `repown status` shows all of this without asking. Every screen:
|
|
203
|
+
[card 13](docs/HOW-IT-WORKS.md#13-guided-setup).
|
|
95
204
|
|
|
96
|
-
|
|
205
|
+
## Commands
|
|
97
206
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
/path/to/clone/.git/hooks/pre-push
|
|
101
|
-
```
|
|
207
|
+
After setup, **moving between accounts needs no command**: `cd` into any pinned clone,
|
|
208
|
+
then commit and push.
|
|
102
209
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
210
|
+
| When | Command | What it does |
|
|
211
|
+
| --- | --- | --- |
|
|
212
|
+
| Once per machine | `repown doctor` | what serves credentials on this machine, and whether each account is signed in to git and gh |
|
|
213
|
+
| | `repown fix [--dry-run] [--yes]` | undo `gh auth setup-git`, so each clone's pinned account is used; shows what it removes, and the undo, first |
|
|
214
|
+
| Once per clone | `repown setup [<account>]` | guided setup of this clone. Questions, flags and the review: [Quick start](#quick-start). A clone that is already set up opens on that screen |
|
|
215
|
+
| | `repown use <account> [--gh]` | what setup runs: pin this clone to an account. `--gh` switches gh's active account, or signs the account in to gh when needed (in a terminal). `--name` with `--email` skips the registry, the file where repown remembers accounts |
|
|
216
|
+
| | `repown guard on \| off \| status` | install, remove or show the pre-push hook (bare `repown guard` shows it) |
|
|
217
|
+
| Any time | `repown status` | this clone's and this machine's settings, and what to fix. Exits 1 on a problem; warnings alone exit 0 |
|
|
218
|
+
| | `repown scan [dir...] [--emails] [--depth <n>] [--format json]` | every clone under the folders (default: this one, 3 levels deep): owner, host, identity, guard, and which email domains its history has. Changes nothing |
|
|
219
|
+
| Rarely | `repown accounts list \| add \| remove` | the accounts this machine knows (bare `repown accounts` lists them; `add` takes `--name`, `--email`, `--host github\|azdo\|generic`; `list --format json` for scripts) |
|
|
220
|
+
| | `repown off` | unpin this clone, leaving global config alone; warns if the guard is still on |
|
|
106
221
|
|
|
107
|
-
|
|
222
|
+
**Bare `repown`:**
|
|
108
223
|
|
|
109
|
-
|
|
|
224
|
+
| Where | What it does |
|
|
110
225
|
| --- | --- |
|
|
111
|
-
|
|
|
112
|
-
|
|
|
113
|
-
|
|
|
114
|
-
| `user.useConfigOnly` | git refuses to invent an identity from the hostname |
|
|
226
|
+
| A terminal, inside a clone (pinned or not) | Starts `repown setup` |
|
|
227
|
+
| A terminal, outside a clone | Shows help, exit 0 |
|
|
228
|
+
| No terminal, or the output is redirected | Status. Exit 1 outside a clone |
|
|
115
229
|
|
|
116
|
-
|
|
117
|
-
repository, and teammates see nothing.
|
|
118
|
-
|
|
119
|
-
## Day to day
|
|
120
|
-
|
|
121
|
-
**Moving between accounts needs no command.** `cd` into any pinned clone, then commit
|
|
122
|
-
and push. To see who a clone is, run `repown`:
|
|
230
|
+
**Who is this clone?** `repown status` prints:
|
|
123
231
|
|
|
124
232
|
```
|
|
125
|
-
$ repown
|
|
233
|
+
$ repown status
|
|
126
234
|
|
|
235
|
+
repown status · current settings of this clone
|
|
236
|
+
~/code/personal (branch main)
|
|
237
|
+
|
|
238
|
+
This clone
|
|
127
239
|
commits as Octo Cat <octocat@users.noreply.github.com>
|
|
128
240
|
pushes as octocat
|
|
241
|
+
account octocat (recorded)
|
|
129
242
|
origin octocat (GitHub)
|
|
243
|
+
upstream origin/main
|
|
244
|
+
push guard on
|
|
245
|
+
|
|
246
|
+
This machine
|
|
247
|
+
default Octo Work <octo-work@example.invalid>
|
|
130
248
|
helper manager
|
|
131
249
|
gh active octo-work
|
|
132
|
-
push guard on
|
|
133
250
|
|
|
134
|
-
WARN gh active as "octo-work", so `gh pr create` here would act as that account.
|
|
135
|
-
fix: gh auth switch -u octocat
|
|
136
251
|
OK identity this clone is pinned, and its credential mechanism honours it
|
|
252
|
+
NOTE gh active as "octo-work", so `gh pr create` here would act as that account. git pushes are unaffected; this only matters if you use gh here.
|
|
253
|
+
fix: gh auth switch -u octocat
|
|
254
|
+
|
|
255
|
+
ready: commits and pushes use octocat · gh: optional (see the note above)
|
|
137
256
|
```
|
|
138
257
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
258
|
+
Here git is right, and only `gh` commands would act as another account. That line is a
|
|
259
|
+
note, not a warning. Every warning it can print:
|
|
260
|
+
[card 5](docs/HOW-IT-WORKS.md#5-check-where-you-are).
|
|
261
|
+
|
|
262
|
+
- **Help:** `repown --help`, `repown help <command>` (or `repown <command> --help`), and
|
|
263
|
+
`repown help guard on` one level deeper. Help never changes anything.
|
|
264
|
+
- **Every command** takes `--cwd <dir>`. **Version:** `repown --version` (or `-v`).
|
|
265
|
+
|
|
266
|
+
**Exit codes:**
|
|
267
|
+
|
|
268
|
+
| Command | 0 | 1 | 2 | Other |
|
|
269
|
+
| --- | --- | --- | --- | --- |
|
|
270
|
+
| In general | Success | Failure or refusal | Usage error | |
|
|
271
|
+
| `repown scan` | Whatever it finds (read its output or JSON) | | A missing folder or a bad `--depth` | |
|
|
272
|
+
| `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 |
|
|
273
|
+
| `repown status` | Success. Warnings alone exit 0 | A problem | | |
|
|
142
274
|
|
|
143
|
-
|
|
144
|
-
host, identity and guard. It also shows which email domains appear in its history, and
|
|
145
|
-
how often. It never changes anything.
|
|
275
|
+
Every `setup` case: [Scripts and CI](docs/CONFIGURATION.md#scripts-and-ci).
|
|
146
276
|
|
|
147
|
-
|
|
277
|
+
## Troubleshooting
|
|
148
278
|
|
|
149
|
-
| What happened |
|
|
279
|
+
| What happened | What to do |
|
|
150
280
|
| --- | --- |
|
|
151
|
-
|
|
|
152
|
-
|
|
|
153
|
-
|
|
|
154
|
-
| A
|
|
155
|
-
|
|
|
281
|
+
| `repown doctor` says gh is the helper | `repown fix` ([card 1](docs/HOW-IT-WORKS.md#1-set-up-the-machine)) |
|
|
282
|
+
| `repown doctor` shows `GCM` … `not found` | install Git Credential Manager ([Install](#install)), then `repown doctor` again |
|
|
283
|
+
| `repown doctor` shows `helper` … `none configured` | `git credential-manager configure`, then `repown doctor` again |
|
|
284
|
+
| A push asked for a password | `repown status` (this clone) or `repown doctor` (this machine): each names the cause (gh as the helper, or no helper) and the fix |
|
|
285
|
+
| A push failed right after signing in (SSO) | [card 6](docs/HOW-IT-WORKS.md#6-commit-and-first-push) |
|
|
286
|
+
| The guard refused a push | it says which commit and the fix. Most often a commit made before pinning: `git commit --amend --reset-author --no-edit` fixes the last one ([card 8](docs/HOW-IT-WORKS.md#8-push-refused-and-the-fix) for older ones, and every other refusal) |
|
|
287
|
+
| `gh pr create` acts as the wrong account | `gh auth switch -u <account>` when gh lists it, otherwise `repown use <account> --gh` |
|
|
288
|
+
| `git push` says the branch has no upstream | `repown setup --auto-upstream`, or once `git push -u origin <branch>` |
|
|
289
|
+
| The first push opened a browser | Expected, once per account. Git Credential Manager stores it |
|
|
290
|
+
| The guard said the push goes to another owner | if you're a member or collaborator there: `git config --local --add repown.allowOwner <owner>` |
|
|
291
|
+
| The guard said `GH_TOKEN` (or `GITHUB_TOKEN`, `GIT_AUTHOR_EMAIL`, `GIT_COMMITTER_EMAIL`) is set | unset it, then push again: the email variables override the pinned identity, and the token variables make gh serve that token |
|
|
292
|
+
| husky or another tool owns the pre-push hook | have that hook run `repown guard check --remote="$1" --url="$2"`, passing its stdin through; if the hook is committed, make it skip teammates without repown ([card 10](docs/HOW-IT-WORKS.md#10-other-hook-tools)) |
|
|
293
|
+
| An Azure DevOps push is refused as "wrong owner" | the owner there is the organisation: allow it with `git config --local --add repown.allowOwner <organisation>` |
|
|
294
|
+
| "repown cannot be found" on push | [card 12](docs/HOW-IT-WORKS.md#12-uninstall-or-repown-missing) |
|
|
295
|
+
|
|
296
|
+
A refused push:
|
|
156
297
|
|
|
157
|
-
|
|
298
|
+
```
|
|
299
|
+
FAIL guard 1 commit(s) bound for refs/heads/main were not authored as octocat@users.noreply.github.com, or were committed by someone else.
|
|
300
|
+
6e7b31adb someone@example.invalid someone else's commit
|
|
301
|
+
|
|
302
|
+
These addresses become permanent once pushed.
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
Push stopped by the repown identity guard (above).
|
|
306
|
+
Override this one push with: git push --no-verify
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
To push once without the check: `git push --no-verify`, only when you mean to publish
|
|
310
|
+
those addresses. What the guard can't catch (other git clients, submodule pushes):
|
|
311
|
+
[residual risks](docs/decisions/README.md#residual-risks).
|
|
312
|
+
|
|
313
|
+
## Set up by hand
|
|
314
|
+
|
|
315
|
+
The same commands `repown setup` runs, if you'd rather type them:
|
|
316
|
+
|
|
317
|
+
1. **Check the machine, once:** `repown doctor`.
|
|
318
|
+
2. **Record each account, once:**
|
|
319
|
+
`repown accounts add octocat --name "Octo Cat" --email octocat@users.noreply.github.com`.
|
|
320
|
+
Optional: on a terminal, the first `repown use` of an unknown account asks. On GitHub
|
|
321
|
+
it suggests the name from the public profile and the noreply email (through gh)
|
|
322
|
+
([card 2](docs/HOW-IT-WORKS.md#2-remember-an-account)).
|
|
323
|
+
3. **In each clone:** `repown use octocat`, then `repown guard on`
|
|
324
|
+
([card 3](docs/HOW-IT-WORKS.md#3-pin-a-clone)). If the repository belongs to another
|
|
325
|
+
owner, such as an organisation, `use` prints the line that allows it.
|
|
326
|
+
|
|
327
|
+
```
|
|
328
|
+
$ cd ~/code/dotfiles
|
|
329
|
+
$ repown use octocat
|
|
330
|
+
OK identity Octo Cat <octocat@users.noreply.github.com> push-as:octocat
|
|
331
|
+
|
|
332
|
+
No stored credential for "octocat" yet -- the first push signs in
|
|
333
|
+
once, then never again. Verify it afterwards: repown doctor
|
|
334
|
+
|
|
335
|
+
Next: repown guard on (check every push before it leaves)
|
|
336
|
+
|
|
337
|
+
$ repown guard on
|
|
338
|
+
OK guard on -- every push is checked before it leaves
|
|
339
|
+
~/code/dotfiles/.git/hooks/pre-push
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
`.git/config` and `.git/hooks` are never pushed, so teammates see nothing of this setup.
|
|
343
|
+
Every key repown writes:
|
|
344
|
+
[docs/CONFIGURATION.md](docs/CONFIGURATION.md#what-repown-writes).
|
|
345
|
+
|
|
346
|
+
## Uninstall
|
|
347
|
+
|
|
348
|
+
Turn the guard off **first**: a guard that can't find repown refuses every push.
|
|
349
|
+
|
|
350
|
+
```
|
|
351
|
+
repown scan <dir> # the "guard" column shows where it's on
|
|
352
|
+
repown guard off # in each of those clones
|
|
353
|
+
repown off # optional: also drop the pinned identity
|
|
354
|
+
npm uninstall -g repown
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
Left behind, on purpose: the account registry
|
|
358
|
+
([where](docs/CONFIGURATION.md#the-account-registry)), which you can delete, and the
|
|
359
|
+
sign-ins in your OS credential store. If `repown fix` took the helper role from gh and you
|
|
360
|
+
want it back: `gh auth setup-git`. Details, and submodules:
|
|
361
|
+
[card 12](docs/HOW-IT-WORKS.md#12-uninstall-or-repown-missing).
|
|
362
|
+
|
|
363
|
+
## More docs
|
|
158
364
|
|
|
159
|
-
|
|
|
365
|
+
| I want… | Read |
|
|
160
366
|
| --- | --- |
|
|
161
|
-
|
|
|
162
|
-
|
|
|
163
|
-
|
|
|
164
|
-
|
|
|
165
|
-
|
|
|
166
|
-
|
|
|
167
|
-
|
|
|
168
|
-
| `repown scan [dir...] [--emails] [--depth <n>] [--format json]` | audit every clone under the given directories (default: the current one) |
|
|
169
|
-
|
|
170
|
-
- **Help:** `repown --help` lists the commands. `repown help <command>` (or
|
|
171
|
-
`repown <command> --help`) shows a command's options, and `repown help guard on` goes
|
|
172
|
-
one level deeper. Asking for help never changes anything.
|
|
173
|
-
- **Every command:** `--cwd <dir>` works on all of them.
|
|
174
|
-
- **Scripts:** `repown scan --format json` and `repown accounts list --format json` print
|
|
175
|
-
one JSON document on stdout. Those fields are stable; the text layout isn't
|
|
176
|
-
([ADR-014](docs/decisions/ADR-014-json-for-scripts.md)).
|
|
177
|
-
- **Version:** `repown --version`.
|
|
178
|
-
- **Exit codes:** `0` success, `1` failure or refusal, `2` usage error.
|
|
179
|
-
|
|
180
|
-
## Development
|
|
181
|
-
|
|
182
|
-
From a clone (`npm link` puts your working copy on PATH as `repown`):
|
|
183
|
-
|
|
184
|
-
```
|
|
185
|
-
git clone https://github.com/makubexD/repown.git
|
|
186
|
-
cd repown && npm install && npm run build && npm link
|
|
187
|
-
npm test # node's own test runner, no framework
|
|
188
|
-
npm run build # tsc, also the typecheck
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
Cutting a version (maintainers):
|
|
192
|
-
|
|
193
|
-
```
|
|
194
|
-
npm run changelog # draft CHANGELOG.md's Unreleased section from git history, then edit it
|
|
195
|
-
npm run release:patch # or release:minor | release:major | release:beta
|
|
196
|
-
git push --follow-tags # CI publishes to npm (trusted publishing) and creates the GitHub Release
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
`release:*` runs `npm version`, which refuses unless the repository is ready
|
|
200
|
-
(`npm run release:check`), the tests and build pass, and the tarball holds only what
|
|
201
|
-
it should (`npm run pack:check`). It then dates the changelog, commits and tags
|
|
202
|
-
`v<version>` locally. The whole routine is in [docs/RELEASING.md](docs/RELEASING.md);
|
|
203
|
-
what changed in each version is in [CHANGELOG.md](CHANGELOG.md).
|
|
204
|
-
|
|
205
|
-
- **Node:** developing needs Node 22.18+, though running needs only 20
|
|
206
|
-
([ADR-010](docs/decisions/ADR-010-typescript-on-node.md)).
|
|
207
|
-
- **Dependencies:** zero at runtime, by choice.
|
|
208
|
-
- **Demo:** `vhs demo/demo.tape` runs a [VHS](https://github.com/charmbracelet/vhs)
|
|
209
|
-
script with placeholder identities in a throwaway sandbox. No GIF is committed yet,
|
|
210
|
-
because VHS hasn't rendered on the machines tried so far.
|
|
211
|
-
- **Further reading:**
|
|
212
|
-
- [CLAUDE.md](CLAUDE.md) has the contributor rules.
|
|
213
|
-
- [docs/decisions/](docs/decisions/README.md) explains every non-obvious choice.
|
|
367
|
+
| every scenario, with diagrams | [docs/HOW-IT-WORKS.md](docs/HOW-IT-WORKS.md) |
|
|
368
|
+
| environment variables, where accounts are kept, per-clone keys, scripts and JSON | [docs/CONFIGURATION.md](docs/CONFIGURATION.md) |
|
|
369
|
+
| short answers, and how repown compares with `includeIf`, SSH aliases and `gh auth switch` | [docs/FAQ.md](docs/FAQ.md) |
|
|
370
|
+
| to contribute, see where each feature lives in the code, or try it on throwaway repositories | [CONTRIBUTING.md](CONTRIBUTING.md) |
|
|
371
|
+
| to report a vulnerability privately | [SECURITY.md](SECURITY.md) |
|
|
372
|
+
| why it works this way, one ADR per decision | [docs/decisions/](docs/decisions/README.md) |
|
|
373
|
+
| what changed in each version, and how a release is cut | [CHANGELOG.md](CHANGELOG.md), [docs/RELEASING.md](docs/RELEASING.md) |
|
|
214
374
|
|
|
215
375
|
## License
|
|
216
376
|
|