From dfdfe46030090dd0b67628d46537b98662736033 Mon Sep 17 00:00:00 2001 From: "D. Paolella" Date: Tue, 26 Apr 2022 12:48:06 +0200 Subject: [PATCH] When choosing the public branch, make sure it exists on -priv as well --- doozerlib/cli/images_streams.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/doozerlib/cli/images_streams.py b/doozerlib/cli/images_streams.py index 3d62eb647..9902c5f21 100644 --- a/doozerlib/cli/images_streams.py +++ b/doozerlib/cli/images_streams.py @@ -718,10 +718,15 @@ def check_if_upstream_image_exists(upstream_image): # For the latter style, always open directly against named branch if public_branch.startswith('release-') and prs_in_master: public_branches, _ = exectools.cmd_assert(f'git ls-remote --heads {public_repo_url}', strip=True) - lines = public_branches.splitlines() - if [bl for bl in lines if bl.endswith('/main')]: + public_branches = public_branches.splitlines() + priv_branches, _ = exectools.cmd_assert(f'git ls-remote --heads {source_repo_url}', strip=True) + priv_branches = priv_branches.splitlines() + + if [bl for bl in public_branches if bl.endswith('/main')] and \ + [bl for bl in priv_branches if bl.endswith('/main')]: public_branch = 'main' - elif [bl for bl in lines if bl.endswith('/master')]: + elif [bl for bl in public_branches if bl.endswith('/master')] and \ + [bl for bl in priv_branches if bl.endswith('/master')]: public_branch = 'master' else: # There are ways of determining default branch without using naming conventions, but as of today, we don't need it.