Repository navigation
Description
Problem
Commits on refs/notes/ai are written through git fast-import with a hard-coded committer identity. There are three different placeholder identities in the current code, and none of them can be configured:
git-ai <git-ai@local>:src/git/refs.rs#L507and#L569git-ai <git-ai@noreply>:src/git/refs.rs#L900git-ai <git-ai@localhost>:src/git/notes_api.rs#L347
Many organizations enforce a committer-email pattern on every pushed ref through server-side push rules (for example GitLab's "Commit committer's email" push rule, or a pre-receive hook). With such a rule in place, pushing refs/notes/ai is rejected:
remote: GitLab: Committer's email 'git-ai@local' does not follow the pattern '<company pattern>'
! [remote rejected] refs/notes/ai -> refs/notes/ai (pre-receive hook declined)
The only workaround is to rewrite the notes history before every push, because each new note written through the fast-import path brings the placeholder identity back. In the same repository, notes written through the other paths already use the repository's configured identity, so refs/notes/ai ends up with a mix of identities.
This was reported before in #1376, which was closed as out of scope because enterprise requirements for git notes are many and sometimes mutually exclusive. This request is narrower: one opt-in setting, with no change in behavior for anyone who doesn't set it.
Proposal
Make the committer of notes commits configurable, for example:
- a
notes_committersetting (name/email) in~/.git-ai/config.json, settable withgit-ai config set notes_committer.email ..., and/or - an option to use the repository's effective identity (
git var GIT_COMMITTER_IDENT), the same fallback the existingauthoroverride already uses.
The default can stay git-ai <git-ai@local>. Using a single identity in all three places above would also be an improvement by itself.
The identity does not affect authorship data
I rewrote the committer and author of every git-ai@local notes commit in a repository (183 of 862 notes commits) to the repository user's identity, keeping the notes tree byte-identical. git-ai stats returned identical results for all 177 commits on the branch, both after that rewrite and after collapsing the whole notes history into a single commit. Attribution comes from the note contents, not from the commits that store them, so a configurable committer doesn't put the accounting at risk.
Environment
- git-ai 1.7.6, Linux x86_64
notes_backend.kind:git_notes
Activity