public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/rpkg] 1.70-1: Fix construct anongiturl for chain-build
@ 2026-08-10 21:43 Chenxiong Qi
  0 siblings, 0 replies; only message in thread
From: Chenxiong Qi @ 2026-08-10 21:43 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/rpkg
            Branch : 1.70-1
            Commit : 3ea94e6134098e340acafb1dad53bca91ac2c84e
            Author : Chenxiong Qi <cqi@redhat.com>
            Date   : 2017-11-08T17:43:45+08:00
            Stats  : +129/-1 in 3 file(s)
            URL    : https://src.fedoraproject.org/rpms/rpkg/c/3ea94e6134098e340acafb1dad53bca91ac2c84e?branch=1.70-1

            Log:
            Fix construct anongiturl for chain-build

Signed-off-by: Chenxiong Qi <cqi@redhat.com>

---
diff --git a/0001-Fix-construct-anongiturl-for-chain-build.patch b/0001-Fix-construct-anongiturl-for-chain-build.patch
new file mode 100644
index 0000000..f4a8f63
--- /dev/null
+++ b/0001-Fix-construct-anongiturl-for-chain-build.patch
@@ -0,0 +1,87 @@
+From 6373f0f785918e6e15e6541ad8f195c48e29002f Mon Sep 17 00:00:00 2001
+From: Chenxiong Qi <cqi@redhat.com>
+Date: Wed, 8 Nov 2017 11:11:26 +0800
+Subject: [PATCH 1/2] Fix construct anongiturl for chain-build
+
+Signed-off-by: Chenxiong Qi <cqi@redhat.com>
+---
+ pyrpkg/__init__.py     | 19 +++++++++++++++----
+ pyrpkg/cli.py          |  5 ++++-
+ tests/test_commands.py | 14 ++++++++++++++
+ 3 files changed, 33 insertions(+), 5 deletions(-)
+
+diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py
+index 527133e..253b454 100644
+--- a/pyrpkg/__init__.py
++++ b/pyrpkg/__init__.py
+@@ -1882,11 +1882,22 @@ class Commands(object):
+             raise rpkgError('Packages in destination tag %(dest_tag_name)s are not inherited by'
+                             ' build tag %(build_tag_name)s' % build_target)
+ 
+-    def construct_build_url(self):
+-        """Construct build URL with namespaced anongiturl and commit hash"""
++    def construct_build_url(self, module_name=None, commit_hash=None):
++        """Construct build URL with namespaced anongiturl and commit hash
++
++        :param str module_name: name of the module part of the build URL. If
++            omitted, module name with namespace will be guessed from current
++            repository. The given module name will be used in URL directly
++            without guessing namespace.
++        :param str commit_hash: the commit hash appended to build URL. It
++            omitted, the latest commit hash got from current repository will be
++            used.
++        :return: URL built from anongiturl.
++        :rtype: str
++        """
+         return '{0}?#{1}'.format(
+-            self._get_namespace_anongiturl(self.ns_module_name),
+-            self.commithash)
++            self._get_namespace_anongiturl(module_name or self.ns_module_name),
++            commit_hash or self.commithash)
+ 
+     def build(self, skip_tag=False, scratch=False, background=False,
+               url=None, chain=None, arches=None, sets=False, nvr_check=True):
+diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py
+index 24c97d1..c8ce3d7 100644
+--- a/pyrpkg/cli.py
++++ b/pyrpkg/cli.py
+@@ -1156,7 +1156,10 @@ see API KEY section of copr-cli(1) man page.
+             else:
+                 # Figure out the scm url to build from package name
+                 hash = self.cmd.get_latest_commit(component, self.cmd.branch_merge)
+-                url = self.cmd.anongiturl % {'module': component} + '#%s' % hash
++                # Passing given package name to module_name parameter directly without
++                # guessing namespace as no way to guess that. rpms/ will be
++                # added by default if namespace is not given.
++                url = self.cmd.construct_build_url(component, hash)
+                 # If there are no ':' in the chain list, treat each object as
+                 # an individual chain
+                 if ':' in self.args.package:
+diff --git a/tests/test_commands.py b/tests/test_commands.py
+index 2641b90..ca63377 100644
+--- a/tests/test_commands.py
++++ b/tests/test_commands.py
+@@ -697,6 +697,20 @@ class TestConstructBuildURL(CommandTestCase):
+             commithash.return_value)
+         self.assertEqual(expected_url, url)
+ 
++    def test_construct_with_given_module_name_and_hash(self):
++        cmd = self.make_commands()
++
++        anongiturl = 'https://src.example.com/%(module)s'
++        with patch.object(cmd, 'anongiturl', new=anongiturl):
++            for module_name in ('extra-cmake-modules',
++                                'rpms/kf5-kfilemetadata'):
++                url = cmd.construct_build_url(module_name, '123456')
++
++                expected_url = '{0}?#{1}'.format(
++                    anongiturl % {'module': module_name},
++                    '123456')
++                self.assertEqual(expected_url, url)
++
+ 
+ class TestCleanupTmpDir(CommandTestCase):
+     """Test Commands._cleanup_tmp_dir for mockbuild command"""
+-- 
+2.9.5
+

diff --git a/0002-Fix-giturl-as-well-by-calling-construct_build_url.patch b/0002-Fix-giturl-as-well-by-calling-construct_build_url.patch
new file mode 100644
index 0000000..f9884fb
--- /dev/null
+++ b/0002-Fix-giturl-as-well-by-calling-construct_build_url.patch
@@ -0,0 +1,33 @@
+From 511ae50a2c5ef327e8b19f429fb2fbf483633eb4 Mon Sep 17 00:00:00 2001
+From: Chenxiong Qi <cqi@redhat.com>
+Date: Wed, 8 Nov 2017 12:18:28 +0800
+Subject: [PATCH 2/2] Fix giturl as well by calling construct_build_url
+
+Make giturl command call construct_build_url instead of constructing
+URL from anongiturl directly. This should be useful for downstream
+client tools to return correct build URL specific to their own build
+environment configuration.
+
+Signed-off-by: Chenxiong Qi <cqi@redhat.com>
+---
+ pyrpkg/__init__.py | 4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py
+index 253b454..7783ef4 100644
+--- a/pyrpkg/__init__.py
++++ b/pyrpkg/__init__.py
+@@ -2109,9 +2109,7 @@ class Commands(object):
+     def giturl(self):
+         """Return the git url that would be used for building"""
+         self.check_repo(is_dirty=False, all_pushed=False)
+-        url = self._get_namespace_anongiturl(self.ns_module_name) + \
+-            '?#%s' % self.commithash
+-        return url
++        return self.construct_build_url()
+ 
+     def koji_upload(self, file, path, callback=None):
+         """Upload a file to koji
+-- 
+2.9.5
+

diff --git a/rpkg.spec b/rpkg.spec
index c8a5b15..d6b549b 100644
--- a/rpkg.spec
+++ b/rpkg.spec
@@ -3,12 +3,14 @@
 
 Name:           rpkg
 Version:        1.51
-Release:        1%{?dist}
+Release:        2%{?dist}
 
 Summary:        Python library for interacting with rpm+git
 License:        GPLv2+ and LGPLv2
 URL:            https://pagure.io/rpkg
 Source0:        https://pagure.io/releases/rpkg/%{name}-%{version}.tar.gz
+Patch0:         0001-Fix-construct-anongiturl-for-chain-build.patch
+Patch1:         0002-Fix-giturl-as-well-by-calling-construct_build_url.patch
 BuildArch:      noarch
 
 
@@ -91,6 +93,8 @@ A python library for managing RPM package sources in a git repository.
 
 %prep
 %setup -q
+%patch0 -p1
+%patch1 -p1
 
 
 %build
@@ -140,6 +144,10 @@ rm -rf $RPM_BUILD_ROOT
 
 
 %changelog
+* Wed Nov 08 2017 Chenxiong Qi <cqi@redhat.com> - 1.51-2
+- Backport: Fix construct anongiturl for chain-build
+- Backport: Fix giturl as well by calling construct_build_url
+
 * Fri Oct 20 2017 Chenxiong Qi <cqi@redhat.com> - 1.51-1
 - Ignore TestModulesCli if openidc-client is unavailable (cqi)
 - Port mbs-build to rpkg (mprahl)

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-08-10 21:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-10 21:43 [rpms/rpkg] 1.70-1: Fix construct anongiturl for chain-build Chenxiong Qi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox