From 5d3809f1753110262158356e18e4388e386f2397 Mon Sep 17 00:00:00 2001 From: Emanuele Aina <emanuele.aina@collabora.com> Date: Mon, 15 Mar 2021 15:57:43 +0100 Subject: [PATCH] pkg-merge-upstream-to-downstreams: Ensure local downstream branch is created In some cases the current code ensures that a local downstream branch, for instance `apertis/v2021` or `apertis/v2021-updates`, is available if a corresponding ref exists in the `origin` remote. However, in some other cases the local ref is not created, creating an annoying inconsistency. For instance it is never created for development branches like `apertis/v2022dev1`. Even for stable branches, when merging from a security branch like `debian/buster-security` and a `origin/apertis/v2021-security` remote ref is available, the local `apertis/v2021-security` ref is not created. Tweak the code to always ensure there's a local ref for the selected downstream branch. Signed-off-by: Emanuele Aina <emanuele.aina@collabora.com> --- .../usr/bin/apertis-pkg-merge-upstream-to-downstreams | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/package-source-builder/overlay/usr/bin/apertis-pkg-merge-upstream-to-downstreams b/package-source-builder/overlay/usr/bin/apertis-pkg-merge-upstream-to-downstreams index d7c928c..1428651 100755 --- a/package-source-builder/overlay/usr/bin/apertis-pkg-merge-upstream-to-downstreams +++ b/package-source-builder/overlay/usr/bin/apertis-pkg-merge-upstream-to-downstreams @@ -17,9 +17,7 @@ def parse_ref(ref: str) -> str: return git('rev-parse', '-q', '--verify', ref + '^{commit}', _ok_code=[0, 1]).strip('\n') def ensure_branch(name: str, fallbacks: list) -> str: - if parse_ref(f'origin/{name}'): - return name - for b in fallbacks: + for b in [name, *fallbacks]: commit = parse_ref(f'origin/{b}') if commit: print(f'Setting branch {name} to point to {b} ({commit:.7})') @@ -43,7 +41,7 @@ def existing_upstream_branches(upstream: str): def get_matching_downstream_branch(downstream: str, upstream: str): if re.search(r'(dev[0-9]|pre)$', downstream): - return downstream + return ensure_branch(downstream, []) else: if upstream.endswith('-security'): return ensure_branch(f'{downstream}-security', [f'{downstream}-updates', downstream]) -- GitLab