mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-19 08:11:16 +00:00
build_manifest.py: Split the hostname resolution from the requests
This commit is contained in:
parent
9c53cd0db0
commit
6772fa76aa
1 changed files with 13 additions and 1 deletions
|
@ -35,11 +35,23 @@ MANIFEST_TEMPLATE: str = """<?xml version="1.0" encoding="UTF-8"?>
|
|||
|
||||
def request(path: str) -> Dict[str, str]:
|
||||
gitlab_header: Dict[str, str] = {'JOB_TOKEN': os.environ["CI_JOB_TOKEN"]}
|
||||
base_url: str = urlparse(os.environ('CI_PROJECT_URL')).hostname
|
||||
base_url: str = get_hostname(os.environ['CI_PROJECT_URL'])
|
||||
|
||||
return requests.get(f"https://{base_url}/api/v4/" + path, headers=gitlab_header).json()
|
||||
|
||||
|
||||
def get_hostname(url: str) -> str:
|
||||
return urlparse(url).hostname
|
||||
|
||||
|
||||
def test_get_hostname():
|
||||
gitlab = 'https://gitlab.com/example/a_project'
|
||||
assert get_hostname(gitlab) == 'gitlab.com'
|
||||
|
||||
fdo = 'https://gitlab.freedesktop.org/example/a_project'
|
||||
assert get_hostname(fdo) == 'gitlab.freedesktop.org'
|
||||
|
||||
|
||||
def find_repository_sha(module: str, branchname: str) -> Tuple[str, str]:
|
||||
for project in request('projects?search=' + module):
|
||||
if project['name'] != module:
|
||||
|
|
Loading…
Reference in a new issue