From a76cd92bcb955fa9e687aaca2d3841bd16fef570 Mon Sep 17 00:00:00 2001 From: Caleb Connolly Date: Sun, 19 May 2024 00:57:29 +0200 Subject: [PATCH] pmb.config: support ssh urls for (pm)aports (MR 2252) HTTP auth is heavily discouraged, and becoming annoying to set up and use. Let folks reconfigure pmaports origin remote using the SSH URL. Signed-off-by: Caleb Connolly --- pmb/config/__init__.py | 6 ++++-- pmb/helpers/git.py | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pmb/config/__init__.py b/pmb/config/__init__.py index f7eb40dc..6d1ae953 100644 --- a/pmb/config/__init__.py +++ b/pmb/config/__init__.py @@ -1108,8 +1108,10 @@ flashers = { # GIT # git_repos = { - "aports_upstream": "https://gitlab.alpinelinux.org/alpine/aports.git", - "pmaports": "https://gitlab.com/postmarketOS/pmaports.git", + "aports_upstream": ["https://gitlab.alpinelinux.org/alpine/aports.git", + "git@gitlab.alpinelinux.org:alpine/aports.git"], + "pmaports": ["https://gitlab.com/postmarketOS/pmaports.git", + "git@gitlab.com:postmarketos/pmaports.git"], } # diff --git a/pmb/helpers/git.py b/pmb/helpers/git.py index a896ba3a..8a1bbaf7 100644 --- a/pmb/helpers/git.py +++ b/pmb/helpers/git.py @@ -38,7 +38,7 @@ def clone(args, name_repo): path = get_path(args, name_repo) if not os.path.exists(path): # Build git command - url = pmb.config.git_repos[name_repo] + url = pmb.config.git_repos[name_repo][0] command = ["git", "clone"] command += [url, path] @@ -90,15 +90,15 @@ def get_upstream_remote(args, name_repo): Usually "origin", but the user may have set up their git repository differently. """ - url = pmb.config.git_repos[name_repo] + urls = pmb.config.git_repos[name_repo] path = get_path(args, name_repo) command = ["git", "remote", "-v"] output = pmb.helpers.run.user(args, command, path, output_return=True) for line in output.split("\n"): - if url in line: + if any(u in line for u in urls): return line.split("\t", 1)[0] - raise RuntimeError("{}: could not find remote name for URL '{}' in git" - " repository: {}".format(name_repo, url, path)) + raise RuntimeError("{}: could not find remote name for any URL '{}' in git" + " repository: {}".format(name_repo, urls, path)) def parse_channels_cfg(args):