Skip to content

Commit bf6c87d

Browse files
committed
squash: ensure remote repo exists before update
1 parent b384218 commit bf6c87d

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/tmt_web/utils/git_handler.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ def _fetch_remote(common: Common, repo_path: Path, logger: Logger) -> None:
144144

145145
def _update_branch(common: Common, repo_path: Path, branch: str, logger: Logger) -> None:
146146
"""Ensure the specified branch is up to date with its remote counterpart."""
147+
try:
148+
common.run(Command("git", "show-branch", f"origin/{branch}"), cwd=repo_path)
149+
except RunError as err:
150+
logger.fail(f"Branch '{branch}' does not exist in repository '{repo_path}'")
151+
raise GeneralError(f"Branch {branch}' does not exist in repository '{repo_path}'") from err
147152
try:
148153
# Check if the branch is already up to date
149154
common.run(Command("git", "diff", "--quiet", branch, f"origin/{branch}"), cwd=repo_path)

0 commit comments

Comments
 (0)