Skip to main content

Module git_identity

Module git_identity 

Source
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§

GitIdentityState
MachineIdentity
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 noreply form 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_state for callers that only know a working directory — the MCP tools and the CLI, which take a cwd rather 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.