Skip to content

Commit

Permalink
test: ignore denyCurrentBranch in git repo fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
shtrom committed Jan 9, 2025
1 parent 9bad9a5 commit de30640
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lando/api/tests/test_landings.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ def test_integrated_execute_job(
revisions = [
create_patch_revision(number, **kwargs) for number, kwargs in revisions_params
]

job_params = {
"status": LandingJobStatus.IN_PROGRESS,
"requester_email": "[email protected]",
Expand Down
15 changes: 15 additions & 0 deletions src/lando/main/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
def git_repo_seed(request) -> Path:
return Path(__file__).parent / "data" / "test-repo.patch"


@pytest.fixture
def git_repo(tmp_path: Path, git_repo_seed: Path) -> Path:
"""
Expand All @@ -23,6 +24,7 @@ def git_repo(tmp_path: Path, git_repo_seed: Path) -> Path:
subprocess.run(["git", "init", repo_dir], check=True)
subprocess.run(["git", "branch", "-m", "main"], check=True, cwd=repo_dir)
_git_setup_user(repo_dir)
_git_ignore_denyCurrentBranch(repo_dir)
subprocess.run(["git", "am", str(git_repo_seed)], check=True, cwd=repo_dir)
subprocess.run(["git", "show"], check=True, cwd=repo_dir)
subprocess.run(["git", "branch"], check=True, cwd=repo_dir)
Expand All @@ -42,3 +44,16 @@ def _git_setup_user(repo_dir: Path):
check=True,
cwd=repo_dir,
)


def _git_ignore_denyCurrentBranch(repo_dir: Path):
"""Disable error when pushing to this non-bare repo.
This is a sane protection in general, but it gets in the way of the tests here,
where we just want a target, and don't care much about the final state of this
target after everything is done."""
subprocess.run(
["git", "config", "receive.denyCurrentBranch", "ignore"],
check=True,
cwd=repo_dir,
)

0 comments on commit de30640

Please sign in to comment.