diff options
| author | Octavian Guzu <oct@anthropic.com> | 2026-09-09 16:46:55 +0000 |
|---|---|---|
| committer | Octavian Guzu <oct@anthropic.com> | 2026-09-09 16:46:55 +0000 |
| commit | f03d41e2c96f30b7b59a05566e998e6236a943e7 (patch) | |
| tree | f3c27a2016de7fca17e3546fb50b0cd81e29edcc /plugins/security-guidance/hooks/gitutil.py | |
| parent | 0b2f3e30a9c6f6e5ed7ca72408ffb957103174ca (diff) | |
Adjust SubagentStop handling and repository precedence
- SubagentStop reviews without consuming or advancing the session's
Stop state; an identical diff is not reviewed twice.
- SubagentStop from a different working tree than the project is skipped.
- An explicit `git -C <dir>` / `cd <dir>` naming another repository takes
precedence over the hook cwd.
- Narrows the `git -C … commit` matcher; keeps Windows path separators
when tokenizing; adds `--no-textconv` to diff/show invocations.
- Adds tests.
:house: Remote-Dev: homespace
Diffstat (limited to 'plugins/security-guidance/hooks/gitutil.py')
| -rw-r--r-- | plugins/security-guidance/hooks/gitutil.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/plugins/security-guidance/hooks/gitutil.py b/plugins/security-guidance/hooks/gitutil.py index 4d771b42..de04bfeb 100644 --- a/plugins/security-guidance/hooks/gitutil.py +++ b/plugins/security-guidance/hooks/gitutil.py @@ -238,7 +238,7 @@ def _git_diff_range(repo_root, base, head="HEAD"): # raw UTF-8, not C-quoted. Required by the downstream # parse_diff_into_files / extract_file_paths_from_diff regex. r = subprocess.run( - [*GIT_CMD, "diff", "-p", "--no-color", "--no-ext-diff", base, head], + [*GIT_CMD, "diff", "-p", "--no-color", "--no-ext-diff", "--no-textconv", base, head], cwd=repo_root, capture_output=True, timeout=30, ) if r.returncode != 0: @@ -481,7 +481,7 @@ def get_git_diff(cwd, baseline_sha, full_context=False, paths=None, untracked_pa return "" # core.quotePath=false comes from GIT_CMD globally (see definition). - cmd = [*GIT_CMD, "diff", "--no-color", "--no-ext-diff", baseline_sha] + (["--unified=99999"] if full_context else []) + pathspec + cmd = [*GIT_CMD, "diff", "--no-color", "--no-ext-diff", "--no-textconv", baseline_sha] + (["--unified=99999"] if full_context else []) + pathspec try: with _temp_index(cwd, untracked_paths) as env: # env is None when no index could be found (bare repo / not a |
