Skip to content

tests: make bad-tag recovery test portable across Git versions #350

Description

@OllieinCanada

Summary

git_ops::tests::test_ensure_remote_bad_tag_recovery fails consistently with
Git 2.25.1 because git fetch --prune --no-tags succeeds without inspecting or
removing the deliberately corrupt local tag.

The recovery logic is entered only when fetch fails with stderr containing
fatal: bad object refs/tags/. On this Git version that diagnostic is not
produced, so ensure_remote() returns successfully while
.git/refs/tags/bad-tag remains and the final assertion fails.

Reproduction

On current main at 8ac8e51fd79c8560404efe62d0c9ce38defce5af:

cargo test --release --lib \
  git_ops::tests::test_ensure_remote_bad_tag_recovery -- --exact

Result:

test git_ops::tests::test_ensure_remote_bad_tag_recovery ... FAILED

Bad tag should have been deleted by recovery logic

The failure also causes make check-pr to fail locally.

Environment

  • Rust 1.90.0
  • Git 2.25.1
  • WSL Ubuntu

Expected behavior

The test should deterministically exercise the recovery path across supported
Git versions, or the repository should document and enforce a minimum Git
version that produces the expected fetch failure.

This was discovered while validating an unrelated NNTP whitespace fix. That
change does not modify src/git_ops.rs, and the failure reproduces when this
test is run alone.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions