]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
suite.util.find_git_parents: Fix KeyError 1958/head
authorZack Cerza <zack@redhat.com>
Fri, 14 Jun 2024 19:06:43 +0000 (13:06 -0600)
committerZack Cerza <zack@redhat.com>
Fri, 14 Jun 2024 19:08:22 +0000 (13:08 -0600)
And clean up the code a bit

Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/suite/util.py

index e1d311593175f52d5153d7be2be4d78da2d17b9e..5300c65617ed2d8836fc96a65aefd12da920872b 100644 (file)
@@ -348,15 +348,19 @@ def find_git_parents(project: str, sha1: str, count=1):
         return []
 
     def get_sha1s(project, committish, count):
-        url = '/'.join((base_url, '%s.git' % project,
-                       'history/?committish=%s&count=%d' % (committish, count)))
+        url = '/'.join((
+            base_url,
+            f"{project}.git",
+            f"history/?committish={committish}&count={count}"
+        ))
         resp = requests.get(url)
         resp.raise_for_status()
         sha1s = resp.json()['sha1s']
         if len(sha1s) != count:
-            log.debug('got response: %s', resp.json())
-            log.error('can''t find %d parents of %s in %s: %s',
-                       int(count), sha1, project, resp.json()['error'])
+            resp_json = resp.json()
+            err_msg = resp_json.get("error") or resp_json.get("err")
+            log.debug(f"Got response: {resp_json}")
+            log.error(f"Can't find {count} parents of {sha1} in {project}: {err_msg}")
         return sha1s
 
     # index 0 will be the commit whose parents we want to find.