Add trigger and workdir fields to post_notes_updated hook payload #1045
Add trigger and workdir fields to post_notes_updated hook payload #1045cnhnwt wants to merge 2 commits intogit-ai-project:mainfrom
Conversation
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.
|
@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: |
|
@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. |
@svarlamov Could you please review or implement this related request? We really need this functionality. Thank you so much! |
|
@cnhnwt I think this looks fine, but can you remove the |
@svarlamov I've removed the trigger field as requested.Please take a look. |
Summary
This PR extends the post_notes_updated hook mechanism to provide richer context to hook scripts.
Changes
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"
}