From 38cb46eb99325c0b147f2f4bda4d707908dc1a07 Mon Sep 17 00:00:00 2001 From: Luca Beltrame Date: Sat, 15 Jan 2022 09:33:00 +0100 Subject: [PATCH] Simplify ls-remote call This should also be faster to execute on many pacakges --- obs/update_unstable.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/obs/update_unstable.py b/obs/update_unstable.py index 1fda970..a1f600e 100755 --- a/obs/update_unstable.py +++ b/obs/update_unstable.py @@ -75,20 +75,12 @@ def project_exists(project: str) -> bool: return False -def lsremote(url: str) -> Dict[str, str]: - - remote_refs = {} - gitcmd = git.cmd.Git() - for ref in gitcmd.ls_remote(url).split('\n'): - hash_ref_list = ref.split('\t') - remote_refs[hash_ref_list[1]] = hash_ref_list[0] - - return remote_refs - - def get_remote_hash(url: str, branch: str = "master") -> str: - refs = "refs/heads/{}".format(branch) - return lsremote(url)[refs] + + gitcmd = git.cmd.Git() + revision = gitcmd.ls_remote(url, branch, quiet=True, refs=True) + git_hash, branch = revision.split("\t") + return git_hash def trigger_update(repository: str, package_name: str,