Skip to content

Commit

Permalink
Dry Run: forking non-existent repo should fail
Browse files Browse the repository at this point in the history
  • Loading branch information
ytausch committed Jul 28, 2024
1 parent 7e4e0c0 commit 7ec73c3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions conda_forge_tick/git_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,11 @@ def fork(self, owner: str, repo_name: str):
logger.debug(f"Fork of {repo_name} already exists. Doing nothing.")
return

if not self.does_repository_exist(owner, repo_name):
raise RepositoryNotFoundError(
f"Cannot fork non-existing repository {owner}/{repo_name}."
)

logger.debug(
f"Dry Run: Creating fork of {owner}/{repo_name} for user {self._USER}."
)
Expand Down
7 changes: 4 additions & 3 deletions tests/test_git_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1772,14 +1772,15 @@ def test_dry_run_backend_fork(caplog):

backend = DryRunBackend()

backend.fork("UPSTREAM_OWNER", "REPO")
backend.fork("conda-forge", "pytest-feedstock")
assert (
"Dry Run: Creating fork of UPSTREAM_OWNER/REPO for user auto-tick-bot-dry-run"
"Dry Run: Creating fork of conda-forge/pytest-feedstock for user auto-tick-bot-dry-run"
in caplog.text
)

# this should not raise an error
backend.fork("UPSTREAM_OWNER", "REPO")
with pytest.raises(RepositoryNotFoundError):
backend.fork("conda-forge", "this-repository-does-not-exist")


def test_dry_run_backend_sync_default_branch(caplog):
Expand Down

0 comments on commit 7ec73c3

Please sign in to comment.