public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Mohan Boddu <mboddu@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/fedpkg] 1.48-1: Use PDC instead of Bodhi to get the active release branches
Date: Mon, 10 Aug 2026 21:45:34 GMT	[thread overview]
Message-ID: <178639833446.1.6501338597913207322.rpms-fedpkg-b8aa6f0ebb2d@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : rpms/fedpkg
            Branch : 1.48-1
            Commit : b8aa6f0ebb2d3d5f56bc3e54a0982c31c4c24ce2
            Author : Mohan Boddu <mboddu@redhat.com>
            Date   : 2018-02-27T14:01:18-05:00
            Stats  : +195/-1 in 2 file(s)
            URL    : https://src.fedoraproject.org/rpms/fedpkg/c/b8aa6f0ebb2d3d5f56bc3e54a0982c31c4c24ce2?branch=1.48-1

            Log:
            Use PDC instead of Bodhi to get the active release branches

Signed-off-by: Mohan Boddu <mboddu@redhat.com>

---
diff --git a/0001-fedpkg-request-use-pdc-active-releases.patch b/0001-fedpkg-request-use-pdc-active-releases.patch
new file mode 100644
index 0000000..39b6efb
--- /dev/null
+++ b/0001-fedpkg-request-use-pdc-active-releases.patch
@@ -0,0 +1,189 @@
+From 00aed529cf22796fdae0d23f844221df640cc7c2 Mon Sep 17 00:00:00 2001
+From: mprahl <mprahl@redhat.com>
+Date: Feb 23 2018 03:01:35 +0000
+Subject: Use PDC instead of Bodhi to get the active release branches
+
+
+Fixes #187
+
+Signed-off-by: mprahl <mprahl@redhat.com>
+
+---
+
+diff --git a/fedpkg/cli.py b/fedpkg/cli.py
+index a203b91..e8ff6be 100644
+--- a/fedpkg/cli.py
++++ b/fedpkg/cli.py
+@@ -462,7 +462,7 @@ suggest_reboot=False
+                 raise rpkgError('You must specify a branch if you are not in '
+                                 'a git repository')
+ 
+-        bodhi_url = config.get('{0}.bodhi'.format(name), 'url')
++        pdc_url = config.get('{0}.pdc'.format(name), 'url')
+         if branch:
+             if is_epel(branch):
+                 assert_valid_epel_package(module_name, branch)
+@@ -474,7 +474,7 @@ suggest_reboot=False
+                         'Only characters, numbers, periods, dashes, '
+                         'underscores, and pluses are allowed in module branch '
+                         'names')
+-            release_branches = get_release_branches(bodhi_url)
++            release_branches = get_release_branches(pdc_url)
+             if branch in release_branches:
+                 if service_levels:
+                     raise rpkgError(
+@@ -489,14 +489,13 @@ suggest_reboot=False
+ 
+         # If service levels were provided, verify them
+         if service_levels:
+-            pdc_url = config.get('{0}.pdc'.format(name), 'url')
+             sl_dict = sl_list_to_dict(service_levels)
+             verify_sls(pdc_url, sl_dict)
+ 
+         pagure_url = config.get('{0}.pagure'.format(name), 'url')
+         pagure_token = get_pagure_token(config, name)
+         if all_releases:
+-            release_branches = get_release_branches(bodhi_url)
++            release_branches = get_release_branches(pdc_url)
+             branches = [b for b in release_branches
+                         if re.match(r'^(f\d+)$', b)]
+         else:
+diff --git a/fedpkg/utils.py b/fedpkg/utils.py
+index d241308..b3d704c 100644
+--- a/fedpkg/utils.py
++++ b/fedpkg/utils.py
+@@ -18,7 +18,6 @@ from six.moves.urllib.parse import urlencode
+ from six.moves.configparser import NoSectionError, NoOptionError
+ import requests
+ from requests.exceptions import ConnectionError
+-from fedora.client.bodhi import Bodhi2Client
+ from pyrpkg import rpkgError
+ 
+ 
+@@ -97,26 +96,55 @@ def new_pagure_issue(url, token, title, body):
+         url.rstrip('/'), rv.json()['issue']['id'])
+ 
+ 
+-def get_release_branches(bodhi_url):
++def get_release_branches(url):
+     """
+-    Get the active Fedora release branches from Bodhi
+-    :param bodhi_url: a string of the URL to Bodhi
++    Get the active Fedora release branches from PDC
++    :param url: a string of the URL to PDC
+     :return: a set containing the active Fedora release branches
+     """
+-    bodhi = Bodhi2Client(bodhi_url)
+     branches = set()
+-    page = 1
++    api_url = '{0}/rest_api/v1/product-versions/'.format(url.rstrip('/'))
++    query_args = {
++        'fields': ['short', 'version'],
++        'active': True
++    }
+     while True:
+-        rv = bodhi.send_request('releases', auth=False, params={'page': page})
+-        for release in rv['releases']:
+-            if release['state'] == 'current':
+-                branches.add(release['branch'])
+-        if page < rv['pages']:
+-            page += 1
+-        else:
+-            break
++        try:
++            rv = requests.get(api_url, params=query_args, timeout=60)
++        except ConnectionError as error:
++            error_msg = ('The connection to PDC failed while trying to get '
++                         'the active release branches. The error was: {0}'
++                         .format(str(error)))
++            raise rpkgError(error_msg)
+ 
+-    return branches
++        if not rv.ok:
++            base_error_msg = ('The following error occurred while trying to '
++                              'get the active release branches in PDC: {0}')
++            raise rpkgError(base_error_msg.format(rv.text))
++
++        rv_json = rv.json()
++        for product_version in rv_json['results']:
++            # If the version is not a digit we can ignore it (e.g. rawhide)
++            if not product_version['version'].isdigit():
++                continue
++
++            if product_version['short'] == 'epel':
++                prefix = 'epel'
++                if product_version['version'] == '6':
++                    prefix = 'el'
++                branches.add('{0}{1}'.format(
++                    prefix, product_version['version']))
++            elif product_version['short'] == 'fedora':
++                branches.add('f{0}'.format(product_version['version']))
++
++        if rv_json['next']:
++            # Clear the query_args because they are baked into the "next" URL
++            query_args = {}
++            api_url = rv_json['next']
++        else:
++            # We've gone through every page, so we can return the found
++            # branches
++            return branches
+ 
+ 
+ def sl_list_to_dict(sls):
+diff --git a/test/test_utils.py b/test/test_utils.py
+index cff22bd..7ca395f 100644
+--- a/test/test_utils.py
++++ b/test/test_utils.py
+@@ -115,29 +115,29 @@ class TestUtils(CliTestCase):
+                 assert str(e) == ('The SL "{0}" must expire on June 1st or '
+                                   'December 1st'.format(eol))
+ 
+-    @patch('fedpkg.utils.Bodhi2Client')
+-    def test_get_release_branches(self, mock_bodhi):
++    @patch('requests.get')
++    def test_get_release_branches(self, mock_request_get):
+         """Test that get_release_branches returns all the active Fedora release
+         branches.
+         """
+-        mock_bodhi_client = Mock()
+-        mock_bodhi_client.send_request.return_value = {
+-            u'page': 1,
+-            u'pages': 1,
+-            u'releases': [
+-                {'state': 'current', 'branch': 'el6'},
+-                {'state': 'archived', 'branch': 'f24'},
+-                {'state': 'current', 'branch': 'epel7'},
+-                {'state': 'current', 'branch': 'f25'},
+-                {'state': 'archived', 'branch': 'el5'},
+-                {'state': 'archived', 'branch': 'f23'},
+-                {'state': 'current', 'branch': 'f26'},
+-                {'state': 'pending', 'branch': 'f27m'},
+-                {'state': 'current', 'branch': 'f27'}
+-            ],
+-            u'rows_per_page': 20,
+-            u'total': 11}
+-        mock_bodhi.return_value = mock_bodhi_client
+-        expected = set(['el6', 'epel7', 'f25', 'f26', 'f27'])
+-        actual = utils.get_release_branches('http://bodhi.local')
++        mock_rv = Mock()
++        mock_rv.ok = True
++        # This abbreviated data returned from the product-versions PDC API
++        mock_rv.json.return_value = {
++            'count': 7,
++            'next': None,
++            'previous': None,
++            'results': [
++                {'short': 'epel', 'version': '6'},
++                {'short': 'epel', 'version': '7'},
++                {'short': 'fedora', 'version': '25'},
++                {'short': 'fedora', 'version': '26'},
++                {'short': 'fedora', 'version': '27'},
++                {'short': 'fedora', 'version': '28'},
++                {'short': 'fedora', 'version': 'rawhide'}
++            ]
++        }
++        mock_request_get.return_value = mock_rv
++        expected = set(['el6', 'epel7', 'f25', 'f26', 'f27', 'f28'])
++        actual = utils.get_release_branches('http://pdc.local')
+         self.assertEqual(expected, actual)
+

diff --git a/fedpkg.spec b/fedpkg.spec
index e3843e1..ef5f264 100644
--- a/fedpkg.spec
+++ b/fedpkg.spec
@@ -5,7 +5,7 @@
 
 Name:           fedpkg
 Version:        1.31
-Release:        5%{?dist}
+Release:        6%{?dist}
 Summary:        Fedora utility for working with dist-git
 
 Group:          Applications/System
@@ -14,6 +14,8 @@ URL:            https://pagure.io/fedpkg
 Source0:        https://pagure.io/releases/fedpkg/%{name}-%{version}.tar.bz2
 Patch0:         0001-fix-broken-syntax-in-bash-completion.patch
 # https://pagure.io/fedpkg/pull-request/162
+Patch1:         0001-fedpkg-request-use-pdc-active-releases.patch
+# https://pagure.io/fedpkg/pull-request/188
 
 BuildArch:      noarch
 
@@ -113,6 +115,9 @@ nosetests
 
 
 %changelog
+* Tue Feb 27 2018 Mohan Boddu <mboddu@redhat.com> 1.31-6
+- Use PDC instead of Bodhi to get the active release branches
+
 * Wed Feb 14 2018 Chenxiong Qi <cqi@redhat.com> 1.31-5
 - Backport: fix broken syntax in bash completion
 

                 reply	other threads:[~2026-08-10 21:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178639833446.1.6501338597913207322.rpms-fedpkg-b8aa6f0ebb2d@fedoraproject.org \
    --to=mboddu@redhat.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox