From 92e8a3668e00eef478442e06f99cda13f887005e Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Thu, 26 Feb 2026 14:00:09 +0100 Subject: [PATCH] Update gitea_api.Git.get_branch_head() to take optional argument 'remote' --- osc/gitea_api/git.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/osc/gitea_api/git.py b/osc/gitea_api/git.py index 9f34fa05..23c63a19 100644 --- a/osc/gitea_api/git.py +++ b/osc/gitea_api/git.py @@ -186,10 +186,16 @@ class Git: except subprocess.CalledProcessError: return False - def get_branch_head(self, branch: Optional[str] = None) -> str: + def get_branch_head(self, branch: Optional[str] = None, *, remote: Optional[str] = None) -> str: if not branch: branch = self.current_branch + if remote: + try: + return self._run_git(["rev-parse", f"refs/remotes/{remote}/{branch}"], mute_stderr=True) + except subprocess.CalledProcessError: + raise exceptions.GitObsRuntimeError(f"Unable to retrieve HEAD from remote '{remote}', branch '{branch}'. Does the branch exist?") + try: return self._run_git(["rev-parse", f"refs/heads/{branch}"], mute_stderr=True) except subprocess.CalledProcessError: