diff options
| author | Mohamed Hegazy <8000722+mhegazy@users.noreply.github.com> | 2026-11-05 14:26:44 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-05 14:26:44 -0800 |
| commit | b3af021db53c814a266d87128d6f2711ed2c98f6 (patch) | |
| tree | 4df7df081bb8bcb8aab338a9b59c57d750360d0f /plugins/security-guidance/hooks/gitutil.py | |
| parent | d2061194e0d13fe4532e9bb14d01887df8284dc2 (diff) | |
| parent | f1b930f0368e0e0a096442eaa9c1c951b8076b71 (diff) | |
Merge pull request #6922 from anthropics/mhegazy/sg-prompt-snapshot
security-guidance: take the turn baseline without git stash create
Diffstat (limited to 'plugins/security-guidance/hooks/gitutil.py')
| -rw-r--r-- | plugins/security-guidance/hooks/gitutil.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/plugins/security-guidance/hooks/gitutil.py b/plugins/security-guidance/hooks/gitutil.py index 041778b3..747b95a8 100644 --- a/plugins/security-guidance/hooks/gitutil.py +++ b/plugins/security-guidance/hooks/gitutil.py @@ -911,6 +911,11 @@ def _gitlink_paths(top, env): return found +# True when the last _drop_gitlinks call removed at least one gitlink, so the +# index copy and HEAD can no longer have the same tree even on a clean tree. +last_dropped_gitlinks = False + + def _drop_gitlinks(top, env, tmp_index): """Remove the gitlink (mode 160000) entry of every nested repository from the index copy that `env` names, never from the real index, before @@ -922,6 +927,8 @@ def _drop_gitlinks(top, env, tmp_index): `git stash create` fails on the empty directory. `top` is the work tree's top directory. Returns True on success, False on any failure; the copy must not be used then.""" + global last_dropped_gitlinks + last_dropped_gitlinks = False try: if not _may_have_gitlinks(tmp_index): return True @@ -946,6 +953,7 @@ def _drop_gitlinks(top, env, tmp_index): return False # Keep the mtime the copy came with; see _copied_index. os.utime(tmp_index, ns=(mtime_ns, mtime_ns)) + last_dropped_gitlinks = True debug_log(f"gitlink entries (nested repositories) removed from the " f"index copy: {len(nested)}; their contents are not reviewed") return True |
