Loading build/tools/roomservice.py +14 −10 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import json import netrc import os import re import subprocess import sys import urllib.error import urllib.parse Loading Loading @@ -61,10 +62,6 @@ try: except: githubauth = None def add_auth(githubreq): if githubauth: githubreq.add_header("Authorization","Basic %s" % githubauth) if not depsonly: githubreq = urllib.request.Request("https://raw.githubusercontent.com/LineageOS/mirror/main/default.xml") try: Loading Loading @@ -269,10 +266,17 @@ def get_default_or_fallback_revision(repo_name): print("Default revision: %s" % default_revision) print("Checking branch info") githubreq = urllib.request.Request("https://api.github.com/repos/LineageOS/" + repo_name + "/branches") add_auth(githubreq) result = json.loads(urllib.request.urlopen(githubreq, timeout=5).read().decode()) if has_branch(result, default_revision): try: stdout = subprocess.run( ["git", "ls-remote", "-b", "https://:@github.com/LineageOS/" + repo_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ).stdout.decode() branches = [x.split("refs/heads/")[-1] for x in stdout.splitlines()] except: return "" if default_revision in branches: return default_revision fallbacks = [ get_default_revision_no_minor() ] Loading @@ -280,13 +284,13 @@ def get_default_or_fallback_revision(repo_name): fallbacks += list(filter(bool, os.getenv('ROOMSERVICE_BRANCHES').split(' '))) for fallback in fallbacks: if has_branch(result, fallback): if fallback in branches: print("Using fallback branch: %s" % fallback) return fallback print("Default revision %s not found in %s. Bailing." % (default_revision, repo_name)) print("Branches found:") for branch in [branch['name'] for branch in result]: for branch in branches: print(branch) print("Use the ROOMSERVICE_BRANCHES environment variable to specify a list of fallback branches.") return "" Loading Loading
build/tools/roomservice.py +14 −10 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import json import netrc import os import re import subprocess import sys import urllib.error import urllib.parse Loading Loading @@ -61,10 +62,6 @@ try: except: githubauth = None def add_auth(githubreq): if githubauth: githubreq.add_header("Authorization","Basic %s" % githubauth) if not depsonly: githubreq = urllib.request.Request("https://raw.githubusercontent.com/LineageOS/mirror/main/default.xml") try: Loading Loading @@ -269,10 +266,17 @@ def get_default_or_fallback_revision(repo_name): print("Default revision: %s" % default_revision) print("Checking branch info") githubreq = urllib.request.Request("https://api.github.com/repos/LineageOS/" + repo_name + "/branches") add_auth(githubreq) result = json.loads(urllib.request.urlopen(githubreq, timeout=5).read().decode()) if has_branch(result, default_revision): try: stdout = subprocess.run( ["git", "ls-remote", "-b", "https://:@github.com/LineageOS/" + repo_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ).stdout.decode() branches = [x.split("refs/heads/")[-1] for x in stdout.splitlines()] except: return "" if default_revision in branches: return default_revision fallbacks = [ get_default_revision_no_minor() ] Loading @@ -280,13 +284,13 @@ def get_default_or_fallback_revision(repo_name): fallbacks += list(filter(bool, os.getenv('ROOMSERVICE_BRANCHES').split(' '))) for fallback in fallbacks: if has_branch(result, fallback): if fallback in branches: print("Using fallback branch: %s" % fallback) return fallback print("Default revision %s not found in %s. Bailing." % (default_revision, repo_name)) print("Branches found:") for branch in [branch['name'] for branch in result]: for branch in branches: print(branch) print("Use the ROOMSERVICE_BRANCHES environment variable to specify a list of fallback branches.") return "" Loading