Fix test_git_diff to use dynamic branch name

This commit is contained in:
João M. Martins
2025-12-10 10:11:46 +11:00
parent decb360cb7
commit 1b5f64e7e4

View File

@@ -143,13 +143,15 @@ def test_git_diff_staged_empty(test_repository):
assert result == ""
def test_git_diff(test_repository):
# Get the default branch name (could be "main" or "master")
default_branch = test_repository.active_branch.name
test_repository.git.checkout("-b", "feature-diff")
file_path = Path(test_repository.working_dir) / "test.txt"
file_path.write_text("feature changes")
test_repository.index.add(["test.txt"])
test_repository.index.commit("feature commit")
result = git_diff(test_repository, "master")
result = git_diff(test_repository, default_branch)
assert "test.txt" in result
assert "feature changes" in result