Skip to content

Make the committer identity of refs/notes/ai commits configurable #2491

Open

Description

@camcima

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:

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_committer setting (name / email) in ~/.git-ai/config.json, settable with git-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 existing author override 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions