Skip to content

Add Change-Id trailer to commit message hook#28

Merged
jserv merged 1 commit intomainfrom
restrict
Apr 19, 2026
Merged

Add Change-Id trailer to commit message hook#28
jserv merged 1 commit intomainfrom
restrict

Conversation

@jserv
Copy link
Copy Markdown
Contributor

@jserv jserv commented Apr 19, 2026

Append a deterministic Gerrit-style Change-Id to every commit message: hash of tree, parent, author/committer identity, and cleaned message body. The awk block inserts the trailer in the footer, respecting existing trailer ordering.

Handles core.commentChar (including 'auto'), validates the generated hash, and fails loudly on write errors instead of silently proceeding.

Change-Id: Id606a2c2b9deae4f6bd10093cfe506fe9203da1a


Summary by cubic

Add a deterministic Gerrit-style Change-Id to each commit message to ensure stable change tracking. Inserts the trailer in the footer without disturbing existing trailers.

  • New Features

    • Generate Change-Id from tree, parent, author/committer, and cleaned message body.
    • Skip when a valid Change-Id exists or the message is empty; ignore comments and stop at diffs; drop Signed-off-by.
    • Respect core.commentChar (including auto) during parsing.
    • Validate the 40-hex hash and abort on compute/write errors.
  • Bug Fixes

    • Replace early exit with a loop break so the hook continues after validation and appends the Change-Id.

Written for commit 0000195. Summary will update on new commits.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="scripts/commit-msg.hook">

<violation number="1" location="scripts/commit-msg.hook:401">
P2: Change-Id hash generation ignores `core.commentChar` by stripping only `#` comments.</violation>

<violation number="2" location="scripts/commit-msg.hook:444">
P1: The script does not check whether the awk rewrite succeeded before moving the temp file into place.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread scripts/commit-msg.hook
Comment thread scripts/commit-msg.hook Outdated
Append a deterministic Gerrit-style Change-Id to every commit message:
hash of tree, parent, author/committer identity, and cleaned message
body. The awk block inserts the trailer in the footer, respecting
existing trailer ordering.

Handles core.commentChar (including 'auto'), validates the generated
hash, and fails loudly on write errors instead of silently proceeding.

Change-Id: Id606a2c2b9deae4f6bd10093cfe506fe9203da1a
@jserv jserv merged commit 97f6904 into main Apr 19, 2026
5 checks passed
@jserv jserv deleted the restrict branch April 19, 2026 04:54
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.

1 participant