Merge pull request #3117 from joaommartins/bugfix/check-default-branch-name-in-tests

Fix test_git_diff to use dynamic branch name
This commit is contained in:
Koichi ITO 2025-12-11 14:47:08 +09:00 • committed by GitHub
commit 44afe4c5d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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