Skip to content

Commit

Permalink
Support branch aliases in releasers
Browse files Browse the repository at this point in the history
Fix #430
  • Loading branch information
FrostyX committed Jan 15, 2024
1 parent 9fd0c5a commit 16fbe18
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
35 changes: 33 additions & 2 deletions src/tito/release/distgit.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
import sys
import tempfile

try:
# Optional dependency available on Fedora and EPEL9+
# Without it, branch aliases in releasers.conf won't work.
from fedora_distro_aliases import get_distro_aliases
except ImportError:
get_distro_aliases = None

from tito.common import (
run_command,
debug,
Expand Down Expand Up @@ -56,8 +63,7 @@ def __init__(self, name=None, tag=None, build_dir=None,
else:
self.cli_tool = "fedpkg"

self.git_branches = \
self.releaser_config.get(self.target, "branches").split(" ")
self.git_branches = self._branches()

# check .tito/releasers.conf
if self.releaser_config.has_option(self.target, "remote_git_name"):
Expand Down Expand Up @@ -86,6 +92,31 @@ def release(self, dry_run=False, no_build=False, scratch=False):
self.no_build = no_build
self._git_release()

def _branches(self):
names = self.releaser_config.get(self.target, "branches").split(" ")

# This is a bit hacky because our inheritence hierarchy is messed up.
# RHEL, and CentOS releasers inherits from the Fedora releaser instead
# of all of them having a common ancestor. For now, we only want the
# support for branch aliases in the `FedoraGitReleaser`. There is no
# reason to query Fedora PDC in RHEL and CentOS releasers.
if self.cli_tool != "fedpkg":
return names

if not get_distro_aliases:
warn_out("Missing optional dependency `fedora-distro-aliases'")
warn_out("Branch aliases in releasers.conf won't be evaluated.")
return names

aliases = get_distro_aliases()
result = []
for name in names:
branches = [name]
if name in aliases:
branches = [x.branch for x in aliases[name]]
result.extend(branches)
return result

def _get_build_target_for_branch(self, branch):
if branch in self.build_targets:
return self.build_targets[branch]
Expand Down
1 change: 1 addition & 0 deletions tito.spec
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Requires: python3-setuptools
Requires: python3-bugzilla
Requires: python3-blessed
Requires: rpm-python3
Recommends: python3-fedora-distro-aliases
%else
BuildRequires: python2-devel
BuildRequires: python-setuptools
Expand Down

0 comments on commit 16fbe18

Please sign in to comment.