diff options
| author | Mohamed Hegazy <8000722+mhegazy@users.noreply.github.com> | 2026-11-06 11:41:47 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-06 11:41:47 -0800 |
| commit | 385e32d91174c6955f5cc52f9a84da314fddb3a0 (patch) | |
| tree | 8631aa6bda52834cc13e5bc3bcbdbadd786718fc /plugins/security-guidance/tests | |
| parent | 83b5049e23ad084de27a63ddec2b9af3a52cdc60 (diff) | |
| parent | 64e2f0cbf3f9c076a2709428e92fdb77e4da6f04 (diff) | |
Merge pull request #7000 from anthropics/mhegazy/sg-index-copy-all-gitlinks
security-guidance: drop every gitlink from the index copy
Diffstat (limited to 'plugins/security-guidance/tests')
| -rw-r--r-- | plugins/security-guidance/tests/test_nested_repos.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/plugins/security-guidance/tests/test_nested_repos.py b/plugins/security-guidance/tests/test_nested_repos.py index 8357abf1..6fdcdad6 100644 --- a/plugins/security-guidance/tests/test_nested_repos.py +++ b/plugins/security-guidance/tests/test_nested_repos.py @@ -318,8 +318,9 @@ def test_untracked_file_name_is_not_read_as_a_pattern(outer, git_env): assert name in copy and "other.py" not in copy -def test_gitlink_without_a_repository_stays_in_the_copy(outer, marker, git_env): - """A submodule that is not checked out: an empty directory.""" +def test_gitlink_without_a_repository_is_removed_from_the_copy(outer, marker, git_env): + """A submodule that is not checked out: an empty directory. Its entry goes + too, since a `.git` can appear there before git runs.""" nested = _record_nested_repo(outer, marker) # Moved, not deleted: git's object files are read-only on Windows. nested.rename(outer.parent / "moved-away") @@ -330,9 +331,16 @@ def test_gitlink_without_a_repository_stays_in_the_copy(outer, marker, git_env): copy = _index_entries(outer, env) baseline = diffstate.capture_git_baseline(str(outer)) - assert "160000" in copy - assert baseline and baseline != git(outer, "rev-parse", "HEAD").strip() - assert diffstate.last_baseline_fail == 0 + assert "160000" not in copy + assert "160000" in git(outer, "ls-files", "-s") + head = git(outer, "rev-parse", "HEAD").strip() + version = tuple(int(n) for n in git(outer, "--version").split()[2].split(".")[:2]) + if version >= (2, 34): + assert baseline and baseline != head + assert diffstate.last_baseline_fail == 0 + else: # `git stash create` fails on the empty directory + assert baseline == head + assert diffstate.last_baseline_fail == 1 def test_gitlinks_listed_by_a_git_without_sparse_listing(outer, marker, git_env, monkeypatch): |
