1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-10-23 08:42:15 +02:00

Fix gitea_api.Git.get_branch_head() to raise a proper exception if the HEAD cannot be retrieved

This commit is contained in:
2025-10-10 13:39:07 +02:00
parent fc83822d79
commit 07acc067f0

View File

@@ -156,7 +156,10 @@ class Git:
if not branch:
branch = self.current_branch
return self._run_git(["rev-parse", f"refs/heads/{branch}"])
try:
return self._run_git(["rev-parse", f"refs/heads/{branch}"], mute_stderr=True)
except subprocess.CalledProcessError:
raise exceptions.GitObsRuntimeError(f"Unable to retrieve HEAD from branch '{branch}'. Does the branch exist?")
def branch_exists(self, branch: str) -> bool:
try: