Skip to content
Snippets Groups Projects
Commit 5d3809f1 authored by Emanuele Aina's avatar Emanuele Aina
Browse files

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's avatarEmanuele Aina <emanuele.aina@collabora.com>
parent ea996247
No related branches found
No related tags found
2 merge requests!182pkg-merge: Always submit a new MR, even with conflicts,!93WIP: documentation-builder: Rebase on Apertis instead of Debian Buster
......@@ -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])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment