Skip to content

feat: add whoami and doctor so a wrong identity stops being invisible - #9

Merged
s403o merged 1 commit into
mainfrom
pr/3-whoami-doctor
Jul 30, 2026
Merged

s403o merged 1 commit into
mainfrom
pr/3-whoami-doctor

Conversation

@s403o

@s403o s403o commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Reopened against main — the original #4 was auto-closed when its base branch was deleted on merge.

Why

Git gives you no way to ask which rule matched. An includeIf that never fires produces no warning, no error, and exit status 0 — it silently falls through. So every wrong-identity failure presents to the user as nothing at all.

What this adds

gitmeright whoami — the resolved identity for this repo, which rule matched, and the key in use. When nothing matches it says why, specifically:

profile   ✗ none matched

git will refuse to commit here — that is deliberate.

rules checked:
  ✗ personal     host matches, org does not (expects s403o/)
  ✗ work         different host (expects gitlab.com)

Exits non-zero on a miss, so it is scriptable.

gitmeright doctor — ten read-only checks, each with an actionable remedy: git version against the 2.36/2.13 floors, every profile resolved against a fixture repo, rules that can never match, IdentitiesOnly presence, key existence and mode, ~/.ssh permissions, duplicate or missing includes, and a global [user] that would silently shadow every profile.

--online connects to each host and reports which account actually answered — the check that catches the failure where user.email is right but ssh authenticates as someone else.

Testing

64 tests green, 15 new. A broken state is constructed per check, asserting doctor flags precisely that one. Both commands are read-only and there are tests asserting they write nothing.

One bug these tests caught during development: doctor reported a mode-644 key as an "incomplete pair", because ssh-keygen refuses to read a world-readable key. Permissions are now checked before readability so the message points at the real fault.

Copilot AI review requested due to automatic review settings July 30, 2026 21:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@s403o
s403o merged commit 036fb7f into main Jul 30, 2026
7 checks passed
@s403o
s403o deleted the pr/3-whoami-doctor branch July 30, 2026 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants