Skip to content

Add trigger and workdir fields to post_notes_updated hook payload #1045

Open
cnhnwt wants to merge 2 commits intogit-ai-project:mainfrom
cnhnwt:note_hook_add_param
Open

Add trigger and workdir fields to post_notes_updated hook payload #1045
cnhnwt wants to merge 2 commits intogit-ai-project:mainfrom
cnhnwt:note_hook_add_param

Conversation

@cnhnwt
Copy link
Copy Markdown

@cnhnwt cnhnwt commented Apr 10, 2026

Summary

This PR extends the post_notes_updated hook mechanism to provide richer context to hook scripts.

Changes

  • Added a trigger parameter to post_notes_updated and post_notes_updated_single, allowing callers to identify which code path fired the hook.
  • Added workdir to the RepoHookContext struct, populated from the repository's working directory via repo.workdir().
  • Both trigger and workdir are now included in each entry of the JSON payload sent to configured git_ai_hooks.post_notes_updated shell commands.
  • Updated all three call sites in refs.rs with descriptive trigger values: notes_add, notes_add_batch, and notes_add_blob_batch.

Motivation

Hook scripts previously had no way to distinguish which operation triggered the hook, nor did they receive the local repository path. This made it difficult to implement integrations that need to
report events to external services with full context.

Payload example

{
"commit_sha": "abc123",
"repo_url": "git@github.com:org/repo.git",
"repo_name": "repo",
"branch": "main",
"is_default_branch": true,
"note_content": "...",
"trigger": "notes_add",
"workdir": "/home/user/projects/my-repo"
}


Open with Devin

Extend `post_notes_updated` and `post_notes_updated_single` with a
`trigger` parameter so callers can identify which code path fired the
hook. Also populate `workdir` from the repository's working directory.

Both fields are now included in the JSON payload sent to configured
`git_ai_hooks.post_notes_updated` shell commands, giving hook scripts
richer context about the event source and repository location.
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

@svarlamov
Copy link
Copy Markdown
Member

@cnhnwt I think we could add the workdir, but what's that used for? Would it be more useful to get the git dir?

Also, can you explain the rationale behind receiving the name of the function (ex: notes_add_blob_batch)? This is an internal implementation detail of Git AI that is likely to change as Git AI evolves.

@cnhnwt
Copy link
Copy Markdown
Author

cnhnwt commented Apr 12, 2026

@svarlamov You are right. The workdir is indeed the local Git project directory. Since the hook is executed via a child thread, external programs can no longer access the raw data for processing. I added workdir and trigger to improve extensibility and provide this missing context. Specifically, passing the trigger makes it easier to identify the exact execution scenario of the hook.

@cnhnwt
Copy link
Copy Markdown
Author

cnhnwt commented Apr 14, 2026

@cnhnwt I think we could add the workdir, but what's that used for? Would it be more useful to get the git dir?

Also, can you explain the rationale behind receiving the name of the function (ex: notes_add_blob_batch)? This is an internal implementation detail of Git AI that is likely to change as Git AI evolves.

@svarlamov Could you please review or implement this related request? We really need this functionality. Thank you so much!

@svarlamov
Copy link
Copy Markdown
Member

@cnhnwt I think this looks fine, but can you remove the trigger field before I get this through? This isn't something I think should be user-facing because it's just an internal implementation detail. It doesn't actually imply anything about the operations themselves.

@cnhnwt
Copy link
Copy Markdown
Author

cnhnwt commented Apr 15, 2026

@cnhnwt I think this looks fine, but can you remove the trigger field before I get this through? This isn't something I think should be user-facing because it's just an internal implementation detail. It doesn't actually imply anything about the operations themselves.

@svarlamov I've removed the trigger field as requested.Please take a look.

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.

2 participants