diff --git a/common/copr_common/helpers.py b/common/copr_common/helpers.py index d4fb4c0a1..2ee56ca43 100644 --- a/common/copr_common/helpers.py +++ b/common/copr_common/helpers.py @@ -22,3 +22,22 @@ def script_requires_user(username): ) sys.stderr.write(msg) sys.exit(1) + + +def chroot_to_branch(chroot): + """ + Get a git branch name from chroot. Follow the fedora naming standard. + """ + name, version, _arch = chroot.rsplit("-", 2) + if name == "fedora": + if version == "rawhide": + return "master" + abbrev = "f" + elif name == "epel" and int(version) <= 6: + abbrev = "el" + elif name == "mageia" and version == "cauldron": + abbrev = "cauldron" + version = "" + elif name == "mageia": + abbrev = "mga" + return "{}{}".format(abbrev, version) diff --git a/frontend/copr-frontend.spec b/frontend/copr-frontend.spec index ffea0cc27..be61777f5 100644 --- a/frontend/copr-frontend.spec +++ b/frontend/copr-frontend.spec @@ -4,7 +4,7 @@ # https://fedoraproject.org/wiki/Packaging:Guidelines#Packaging_of_Additional_RPM_Macros %global macrosdir %(d=%{_rpmconfigdir}/macros.d; [ -d $d ] || d=%{_sysconfdir}/rpm; echo $d) -%global copr_common_version 0.15.1.dev +%global copr_common_version 0.19.1.dev # Please bump the %%flavor_guard version every-time some incompatible change # happens (since the last release) in %%flavor_files set of files. Those files diff --git a/frontend/coprs_frontend/alembic/versions/bf4b5dc74740_map_mock_croots_to_dits_git_branch.py b/frontend/coprs_frontend/alembic/versions/bf4b5dc74740_map_mock_croots_to_dits_git_branch.py index 81d7e9295..49c74e836 100644 --- a/frontend/coprs_frontend/alembic/versions/bf4b5dc74740_map_mock_croots_to_dits_git_branch.py +++ b/frontend/coprs_frontend/alembic/versions/bf4b5dc74740_map_mock_croots_to_dits_git_branch.py @@ -10,15 +10,16 @@ revision = 'bf4b5dc74740' down_revision = '38ea34def9a' +# pylint: disable=wrong-import-position from alembic import op import sqlalchemy as sa from sqlalchemy.orm import sessionmaker +from copr_common.helpers import chroot_to_branch import sys, os sys.path.append(os.getcwd()) from coprs.models import MockChroot -from coprs.helpers import chroot_to_branch from coprs.logic.coprs_logic import BranchesLogic def upgrade(): diff --git a/frontend/coprs_frontend/commands/create_chroot.py b/frontend/coprs_frontend/commands/create_chroot.py index e7b9b73e3..4715d251f 100644 --- a/frontend/coprs_frontend/commands/create_chroot.py +++ b/frontend/coprs_frontend/commands/create_chroot.py @@ -1,8 +1,8 @@ import click +from copr_common.helpers import chroot_to_branch from coprs import exceptions from coprs import db -from coprs.helpers import chroot_to_branch from coprs.logic import coprs_logic diff --git a/frontend/coprs_frontend/coprs/helpers.py b/frontend/coprs_frontend/coprs/helpers.py index 7fc0524f9..8ed0e1a98 100644 --- a/frontend/coprs_frontend/coprs/helpers.py +++ b/frontend/coprs_frontend/coprs/helpers.py @@ -315,25 +315,6 @@ def url_for_other_page(self, request, page): return flask.url_for(request.endpoint, **args) -def chroot_to_branch(chroot): - """ - Get a git branch name from chroot. Follow the fedora naming standard. - """ - os, version, arch = chroot.rsplit("-", 2) - if os == "fedora": - if version == "rawhide": - return "master" - os = "f" - elif os == "epel" and int(version) <= 6: - os = "el" - elif os == "mageia" and version == "cauldron": - os = "cauldron" - version = "" - elif os == "mageia": - os = "mga" - return "{}{}".format(os, version) - - def parse_package_name(pkg): """ Parse package name from possibly incomplete nvra string. diff --git a/rpmbuild/copr-rpmbuild.spec b/rpmbuild/copr-rpmbuild.spec index b077c8724..6dd84494a 100644 --- a/rpmbuild/copr-rpmbuild.spec +++ b/rpmbuild/copr-rpmbuild.spec @@ -4,7 +4,7 @@ %global rpm_python python3-rpm %global sitelib %python3_sitelib -%global copr_common_version 0.12.1.dev +%global copr_common_version 0.19.1.dev # do not build debuginfo sub-packages %define debug_package %nil diff --git a/rpmbuild/copr_rpmbuild/automation/fedora_review.py b/rpmbuild/copr_rpmbuild/automation/fedora_review.py index c73f14499..08ee98fff 100644 --- a/rpmbuild/copr_rpmbuild/automation/fedora_review.py +++ b/rpmbuild/copr_rpmbuild/automation/fedora_review.py @@ -10,6 +10,7 @@ import os import shutil +from copr_common.helpers import chroot_to_branch from copr_rpmbuild.helpers import run_cmd from copr_rpmbuild.automation.base import AutomationTool @@ -39,10 +40,12 @@ def run(self): """ Run `fedora-review` tool inside the `resultdir` """ + branch = chroot_to_branch(self.task["chroot"]) cmd = [ "fedora-review", "--no-colors", "--prebuilt", "--rpm-spec", "--name", self.package_name, "--mock-config", self.mock_config_file, + "--define", "DISTTAG={0}".format(branch), ] try: