diff --git a/pmb/helpers/git.py b/pmb/helpers/git.py index 2a32fe59..2dfdd255 100644 --- a/pmb/helpers/git.py +++ b/pmb/helpers/git.py @@ -97,8 +97,11 @@ def get_upstream_remote(args, name_repo): for line in output.split("\n"): if url in line: return line.split("\t", 1)[0] - raise RuntimeError("{}: could not find remote name for URL '{}' in git" - " repository: {}".format(name_repo, url, path)) + + # Fallback (e.g. when pmaports CI clones a different URL as origin) + logging.verbose(f"{name_repo}: could not find remote name for URL '{url}'," + f" assuming 'origin'") + return "origin" def parse_channels_cfg(args): diff --git a/test/test_helpers_git.py b/test/test_helpers_git.py index 4861cff6..c7e48994 100644 --- a/test/test_helpers_git.py +++ b/test/test_helpers_git.py @@ -101,10 +101,8 @@ def test_get_upstream_remote(args, monkeypatch, tmpdir): run_git(["init", "."]) run_git(["commit", "--allow-empty", "-m", "commit on master"]) - # No upstream remote - with pytest.raises(RuntimeError) as e: - func(args, name_repo) - assert "could not find remote name for URL" in str(e.value) + # Missing upstream remote, fall back to "origin" + assert func(args, name_repo) == "origin" run_git(["remote", "add", "hello", url]) assert func(args, name_repo) == "hello"