2 # Copyright © 2020 - 2022 Collabora Ltd.
4 # Tomeu Vizoso <tomeu.vizoso@collabora.com>
5 # David Heidelberg <david.heidelberg@collabora.com>
7 # SPDX-License-Identifier: MIT
8 '''Shared functions between the scripts.'''
12 from typing import Optional
15 def get_gitlab_project(glab, name: str):
16 """Finds a specified gitlab project for given user"""
18 username = glab.user.username
19 return glab.projects.get(f"{username}/mesa")
22 def read_token(token_arg: Optional[str]) -> str:
23 """pick token from args or file"""
27 open(os.path.expanduser("~/.config/gitlab-token"), encoding="utf-8")
33 def wait_for_pipeline(project, sha: str):
34 """await until pipeline appears in Gitlab"""
35 print("⏲ for the pipeline to appear..", end="")
37 pipelines = project.pipelines.list(sha=sha)
41 print("", end=".", flush=True)