#34 Pagure might respond without CI results, adapt to it
Merged 3 years ago by frantisekz. Opened 3 years ago by frantisekz.

file modified
+7 -3
@@ -298,10 +298,14 @@ 

      resp_pr_ci_result = get_json("https://src.fedoraproject.org/api/0/rpms/%s/pull-request/%s/flag" % (package, pr_id))

      if not resp_pr_ci_result:

          return None

-     # Pagure returns PR results sorted from newest to latest, so we can pick just the first result

-     if resp_pr_ci_result["flags"][0]["status"] not in ("failure", "success"):

+     # Pagure might not have CI results at all, return None in such cases

+     try:

+         # Pagure returns PR results sorted from newest to latest, so we can pick just the first result

+         if resp_pr_ci_result["flags"][0]["status"] not in ("failure", "success"):

+             return None

+         return resp_pr_ci_result["flags"][0]["status"]

+     except IndexError:

          return None

-     return resp_pr_ci_result["flags"][0]["status"]

  

  

  def get_package_prs(package):

no initial comment

Pull-Request has been merged by frantisekz

3 years ago
Metadata