Expand description
Commit identity derived from the GitHub account selected for a repository.
Rust counterpart of src/core/git-identity.ts. The account switcher governs
the GitHub API (pull requests, issues, CI) while plain git commit would
otherwise use the machine’s user.email — letting a commit be authored by
one account and its pull request opened by another with nothing saying so.
Scoped to the repository on purpose: gh auth switch would change identity
for every terminal and every other repo on the machine.
Structs§
- GitIdentity
State - Machine
Identity - What
git config user.*resolves to in a working tree.
Functions§
- commit_
email - The address a commit should carry. GitHub’s own address is preferred over a
guess; the id-qualified
noreplyform still attributes the commit when the account keeps its email private. - https_
remote_ host - Host of an HTTPS git remote, or None when the remote is SSH or unparseable.
- identity_
env - Environment that pins a commit’s author and committer. Passed per command
rather than written to
git config, so nothing about the machine changes. - machine_
identity - repository_
for_ cwd - The registered repository owning
cwd, or None when there is not a clear one. An ambiguous or nested directory is None here rather than an error: the caller falls back to the machine’s identity, which is what git would have done anyway. - resolve_
identity_ for_ cwd resolve_identity_statefor callers that only know a working directory — the MCP tools and the CLI, which take acwdrather than a repository name. An unregistered or ambiguous directory resolves to “no selection”, which keeps the machine identity in charge.- resolve_
identity_ state - resolve_
push_ credential - Token to push the selected account with, or None to leave the machine’s credential helper in charge.
- resolve_
selected_ identity - Identity for the repository’s selected account, from the config cache when possible and the GitHub API otherwise.