internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: fedora-infra/bodhi

Issue:
add a link to https://apps.fedoraproject.org/packages/*
Hi there,

almost every time a see a package that I don't know about, I have to go to https://apps.fedoraproject.org/packages/ to understand if i'm able to test or not.

Can you please add one link in the main pages/list ? 

Example : 
global package page : https://bodhi.fedoraproject.org/updates/?packages=kanatest
detailed build page : https://bodhi.fedoraproject.org/updates/kanatest-0.4.8-16.fc23



Discussion:
Oh!  We should have that link already with the little 'fedmenu' button on the bottom right.. but for some reason its missing.  Maybe it got commented out?  We should bring that back.

Oh, I see.  It is there on the single update page, but not in the updates list.  We can likely add it there when `packages=kanatest` is in the url.


Resolving patch:
diff --git a/bodhi/services/updates.py b/bodhi/services/updates.py
--- a/bodhi/services/updates.py
+++ b/bodhi/services/updates.py
@@ -213,6 +213,10 @@ def query_updates(request):
         query = query.join(Update.builds).join(Build.package)
         query = query.filter(or_(*[Package.name==pkg for pkg in packages]))
 
+    package = None
+    if packages and len(packages):
+        package = packages[0]
+
     builds = data.get('builds')
     if builds is not None:
         query = query.join(Update.builds)
@@ -302,6 +306,7 @@ def query_updates(request):
         chrome=data.get('chrome'),
         display_user=data.get('display_user', False),
         display_request=data.get('display_request', True),
+        package=package,
     )
 
 


Test patch:
Repository: fedora-infra/bodhi

Issue:
New Update dialog: strange order of severity options
"medium - urgent - high" order is quite unusual and raises question
whether it's intentional or not.



Discussion:

Resolving patch:
diff --git a/bodhi/services/updates.py b/bodhi/services/updates.py
--- a/bodhi/services/updates.py
+++ b/bodhi/services/updates.py
@@ -25,6 +25,7 @@
 import bodhi.schemas
 import bodhi.security
 import bodhi.services.errors
+import bodhi.util
 from bodhi.validators import (
     validate_nvrs,
     validate_uniqueness,
@@ -92,7 +93,7 @@ def get_update_for_editing(request):
     return dict(
         update=request.validated['update'],
         types=reversed(bodhi.models.UpdateType.values()),
-        severities=reversed(bodhi.models.UpdateSeverity.values()),
+        severities=sorted(bodhi.models.UpdateSeverity.values(), key=bodhi.util.sort_severity),
         suggestions=reversed(bodhi.models.UpdateSuggestion.values()),
     )
 
diff --git a/bodhi/util.py b/bodhi/util.py
--- a/bodhi/util.py
+++ b/bodhi/util.py
@@ -612,3 +612,15 @@ def __call__(self):
             session.close()
 
 transactional_session_maker = TransactionalSessionMaker
+
+def sort_severity(value):
+    """ Sorts UpdateSeverity by severity importance"""
+    value_map = {
+        'unspecified': 1,
+        'low': 2,
+        'medium': 3,
+        'high': 4,
+        'urgent': 5
+    }
+
+    return value_map.get(value, 99)
diff --git a/bodhi/views/generic.py b/bodhi/views/generic.py
--- a/bodhi/views/generic.py
+++ b/bodhi/views/generic.py
@@ -98,7 +98,7 @@ def new_update(request):
     return dict(
         update=None,
         types=reversed(bodhi.models.UpdateType.values()),
-        severities=reversed(bodhi.models.UpdateSeverity.values()),
+        severities=sorted(bodhi.models.UpdateSeverity.values(), key=bodhi.util.sort_severity),
         suggestions=reversed(bodhi.models.UpdateSuggestion.values()),
     )
 


Test patch:
Repository: fedora-infra/bodhi

Issue:
bodhi obsoletes existing "pending stable" updates when submitting a newer package for testing
Specifically, I had two packages in updates testing which I submitted for stable:
mozilla-noscript-2.9-1.fc23
mozilla-noscript-2.9-1.fc22

When I submitted a new set of packages for testing:
mozilla-noscript-2.9.0.2-1.fc23
mozilla-noscript-2.9.0.2-1.fc22
the previous ones got obsoleted and the new updates inherited their changelogs and bugs.



Discussion:

Resolving patch:
diff --git a/bodhi/models/models.py b/bodhi/models/models.py
--- a/bodhi/models/models.py
+++ b/bodhi/models/models.py
@@ -882,6 +882,8 @@ def obsolete_older_updates(self, request):
                      Build.package == build.package,
                      Update.locked == False,
                      Update.release == self.release,
+                     or_(Update.request == UpdateStatus.testing,
+                         Update.request == None),
                      or_(Update.status == UpdateStatus.testing,
                          Update.status == UpdateStatus.pending))
             ).all():


Test patch:
diff --git a/bodhi/tests/functional/test_updates.py b/bodhi/tests/functional/test_updates.py
--- a/bodhi/tests/functional/test_updates.py
+++ b/bodhi/tests/functional/test_updates.py
@@ -1810,6 +1810,25 @@ def test_obsoletion_unlocked_with_open_request(self, publish, *args):
         self.assertEquals(up.status, UpdateStatus.obsolete)
         self.assertEquals(up.request, None)
 
+    @mock.patch(**mock_valid_requirements)
+    @mock.patch('bodhi.notifications.publish')
+    def test_obsoletion_unlocked_with_open_stable_request(self, publish, *args):
+        """ Ensure that we don't obsolete updates that have a stable request """
+        nvr = 'bodhi-2.0.0-2.fc17'
+        args = self.get_update(nvr)
+        self.app.post_json('/updates/', args)
+        up = self.db.query(Update).filter_by(title=nvr).one()
+        up.request = UpdateRequest.stable
+        self.db.flush()
+
+        args = self.get_update('bodhi-2.0.0-3.fc17')
+        r = self.app.post_json('/updates/', args).json_body
+        self.assertEquals(r['request'], 'testing')
+
+        up = self.db.query(Update).filter_by(title=nvr).one()
+        self.assertEquals(up.status, UpdateStatus.pending)
+        self.assertEquals(up.request, UpdateRequest.stable)
+
     @mock.patch(**mock_taskotron_results)
     @mock.patch(**mock_valid_requirements)
     def test_invalid_request(self, *args):
Repository: fedora-infra/bodhi

Issue:
[RFE] Display time to stable
It would be great if, in addition to displaying time at which an update was submitted to testing, the time remaining until the update can be pushed to stable were displayed.  Thanks!



Discussion:
@lmacken @ralphbean I would like to work on it. :) 


Resolving patch:
diff --git a/bodhi/models/models.py b/bodhi/models/models.py
--- a/bodhi/models/models.py
+++ b/bodhi/models/models.py
@@ -1756,6 +1756,16 @@ def met_testing_requirements(self):
                 return True
         return False
 
+    @property
+    def days_to_stable(self):
+        """ Return the number of days until an update can be pushed to stable """
+        for comment in self.comments:
+            if comment.user.name == 'bodhi' and \
+                'can be pushed to stable now if the ' \
+                'maintainer wishes' in comment.text:
+                return (comment.timestamp - self.date_submitted).days
+        return 0
+
     @property
     def days_in_testing(self):
         """ Return the number of days that this update has been in testing """


Test patch:
Repository: fedora-infra/bodhi

Issue:
Unpushing an update with a stable request doesn't remove the Stable request
I unpushed https://bodhi.fedoraproject.org/updates/FEDORA-2016-76e0d3a68e because it was the only button I could press to make sure the update didn't go to stable (why wasn't it automatically removed from stable request once it got -1 karma?), but now the status is:
Request stable
Status  unpushed

I would have expected the request to be removed as well on unpush.



Discussion:

Resolving patch:
diff --git a/bodhi/models/models.py b/bodhi/models/models.py
--- a/bodhi/models/models.py
+++ b/bodhi/models/models.py
@@ -1547,6 +1547,7 @@ def unpush(self, db):
 
         self.pushed = False
         self.status = UpdateStatus.unpushed
+        self.request = None
 
     def revoke(self):
         """ Remove pending request for this update """


Test patch:
diff --git a/bodhi/tests/functional/test_updates.py b/bodhi/tests/functional/test_updates.py
--- a/bodhi/tests/functional/test_updates.py
+++ b/bodhi/tests/functional/test_updates.py
@@ -1913,6 +1913,26 @@ def test_revoke_action_for_testing_request(self, publish, *args):
         publish.assert_called_with(
                 topic='update.request.revoke', msg=mock.ANY)
 
+    @mock.patch(**mock_taskotron_results)
+    @mock.patch(**mock_valid_requirements)
+    @mock.patch('bodhi.notifications.publish')
+    def test_request_after_unpush(self, publish, *args):
+        """Test request of this update after unpushing"""
+        args = self.get_update('bodhi-2.0.0-3.fc17')
+        resp = self.app.post_json('/updates/', args)
+        up = self.db.query(Update).filter_by(title=resp.json['title']).one()
+        up.status = UpdateStatus.testing
+        up.request = UpdateRequest.stable
+        self.db.flush()
+
+        resp = self.app.post_json(
+            '/updates/%s/request' % args['builds'],
+            {'request': 'unpush', 'csrf_token': self.get_csrf_token()})
+        eq_(resp.json['update']['request'], None)
+        eq_(resp.json['update']['status'], 'unpushed')
+        publish.assert_called_with(
+                topic='update.request.unpush', msg=mock.ANY)
+
     @mock.patch(**mock_taskotron_results)
     @mock.patch(**mock_valid_requirements)
     def test_invalid_stable_request(self, *args):
Repository: fedora-infra/bodhi

Issue:
Screwy validator messages
I just tried to submit an update for a nvr that never got built.  It failed (correctly) but I got these error messages back:
- Invalid tag: fedmsg-0.16.1-4.fc21 tagged with `[u'f23-updates-candidate', u'epel7-testing-candidate', u'dist-6E-epel-testing-candidate', u'dist-5E-epel-testing-candidate', u'f22-updates-candidate', u'f21-updates-candidate']`
- Cannot find release associated with build: fedmsg-0.16.1-4.fc21, tags: `[]`

The first one seems backwards.  It seems to be saying that that nvr **is** tagged with those tags, but the case is actually the opposite.  The nvr **is not** tagged with any of those.  We just need to change the wording.

The second one is also screwy.  Bodhi cannot find a release associated with that build that has "no" tags?  We should just say that we couldn't find any tags associated with that nvr.  That's more clear.

These should be pretty simple to add into `bodhi/validators.py`.



Discussion:
hey @ralphbean  I would like to fix it , how can i reproduce the bug.

@farhaanbukhsh check the first line: ;-)

> I just tried to submit an update for a nvr that never got built. 

There is lots of nvr in  https://github.com/fedora-infra/bodhi/blob/develop/bodhi/validators.py  getting confused on which line to fix. Need some help please

Try grepping for some parts of the error messages.  "Invalid tag" and "Cannot find release".

hey, @ralphbean i would like to fix this bug.

@rahulbajaj0509 @farhaanbukhsh are you guys going to fix this ? because i am interested in fixing this. just confirming in order to prevent duplicate effort :)


Resolving patch:
diff --git a/bodhi/validators.py b/bodhi/validators.py
--- a/bodhi/validators.py
+++ b/bodhi/validators.py
@@ -164,7 +164,12 @@ def validate_build_tags(request):
                 if not build_rel:
                     raise KeyError("Couldn't find release from build tags")
             except KeyError:
-                msg = 'Cannot find release associated with build: {}, tags: {}'.format(build, tags)
+                if tags:
+                    msg = 'Cannot find release associated with build: ' + \
+                        '{}, tags: {}'.format(build, tags)
+                else:
+                    msg = 'Cannot find any tags associated with build: ' + \
+                        '{}'.format(build)
                 log.warn(msg)
                 request.errors.add('body', 'builds', msg)
                 return
@@ -180,8 +185,9 @@ def validate_build_tags(request):
                 valid = True
                 break
         if not valid:
-            request.errors.add('body', 'builds', 'Invalid tag: {} tagged with '
-                               '{}'.format(build, valid_tags))
+            request.errors.add('body', 'builds',
+                'Invalid tag: {} not tagged with any of the following tags '
+                '{}'.format(build, valid_tags))
 
 
 def validate_tags(request):


Test patch:
Repository: fedora-infra/bodhi

Issue:
Add a --version flag to the bodhi CLI
The bodhi 1 CLI had a --version flag, but the CLI lost that flag during the bodhi 2 dev cycle. As we plan to roll bodhi 2 out to Fedora Rawhide and EL 7, but not to EL 6 or Fedora 23-25, we will need to add a --version flag to the Bodhi 2 CLI so that fedpkg can tell which Bodhi CLI it is interacting with. The fedpkg developers keep fedpkg at the same version across releases, while in Bodhi we'd prefer to offer API stability to our users (with the exception that we will be releasing Bodhi 2 to EPEL 7 soon).

It should be simple to add a --version flag to the new CLI, and then patch fedpkg to use this flag to determine whether it is interacting with Bodhi 1 or Bodhi 2.



Discussion:

Resolving patch:
diff --git a/bodhi/cli.py b/bodhi/cli.py
--- a/bodhi/cli.py
+++ b/bodhi/cli.py
@@ -25,6 +25,7 @@
 
 
 @click.group()
+@click.version_option(message='%(version)s')
 def cli():
     pass
 


Test patch:
Repository: fedora-infra/bodhi

Issue:
Add a log statement to masher when reusing cached updateinfo, and change generating statement to info
Basically, in https://github.com/fedora-infra/bodhi/blob/2.2.0/bodhi/server/metadata.py#L79-L81 change

```
    self._load_cached_updateinfo()
else:
    log.debug("Generating new updateinfo.xml")
```

to

```
    log.info('Restoring cached updateinfo.xml')
    self._load_cached_updateinfo()
else:
    log.info("Generating new updateinfo.xml")
```



Discussion:

Resolving patch:
diff --git a/bodhi/server/metadata.py b/bodhi/server/metadata.py
--- a/bodhi/server/metadata.py
+++ b/bodhi/server/metadata.py
@@ -76,9 +76,10 @@ def __init__(self, release, request, db, path):
         self.cached_repodata = os.path.join(self.repo, '..', self.tag +
                                             '.repocache', 'repodata/')
         if os.path.isdir(self.cached_repodata):
+            log.info('Loading cached updateinfo.xml')
             self._load_cached_updateinfo()
         else:
-            log.debug("Generating new updateinfo.xml")
+            log.info("Generating new updateinfo.xml")
             self.uinfo = cr.UpdateInfo()
             for update in self.updates:
                 if update.alias:


Test patch:
Repository: fedora-infra/bodhi

Issue:
Update comments should not allow NULL values in the comment text
We had a problem in production where update comments were NULL, causing some template rendering to fail. There's not a good reason for update comments ot be NULL vs. empty string, so let's change that column to disallow NULL and write a migration to apply that change on upgrade. The migration will need to first change all NULL values to empty string.



Discussion:
I believe this update might have a NULL comment from Bodhi:

https://bodhi.fedoraproject.org/updates/FEDORA-2016-0ab60daf6d


Resolving patch:
diff --git a/alembic/versions/37f38ddc4c8d_.py b/alembic/versions/37f38ddc4c8d_.py
new file mode 100644
--- /dev/null
+++ b/alembic/versions/37f38ddc4c8d_.py
@@ -0,0 +1,32 @@
+"""Do not allow NULL values in the text column of the comments table.
+
+Revision ID: 37f38ddc4c8d
+Revises: 4df1fcd59050
+Create Date: 2016-09-21 19:51:04.946521
+
+"""
+
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '37f38ddc4c8d'
+down_revision = '4df1fcd59050'
+
+
+def upgrade():
+    """
+    We will need to set all existing NULL comments to "", then change the column to disallow NULL comments.
+    """
+    # Build a fake mini version of the comments table so we can form an UPDATE statement.
+    comments = sa.sql.table('comments', sa.sql.column('text', sa.UnicodeText))
+    # Set existing NULL comments to "".
+    op.execute(comments.update().where(comments.c.text==None).values({'text': op.inline_literal('')}))
+
+    # Disallow new NULL comments.
+    op.alter_column('comments', 'text', existing_type=sa.TEXT(), nullable=False)
+
+
+def downgrade():
+    op.alter_column('comments', 'text', existing_type=sa.TEXT(), nullable=True)
diff --git a/bodhi/server/models/models.py b/bodhi/server/models/models.py
--- a/bodhi/server/models/models.py
+++ b/bodhi/server/models/models.py
@@ -1925,7 +1925,7 @@ class Comment(Base):
 
     karma = Column(Integer, default=0)
     karma_critpath = Column(Integer, default=0)
-    text = Column(UnicodeText)
+    text = Column(UnicodeText, nullable=False)
     anonymous = Column(Boolean, default=False)
     timestamp = Column(DateTime, default=datetime.utcnow)
 


Test patch:
Repository: fedora-infra/bodhi

Issue:
bodhi's server package doesn't build with setuptools 28.0
setuptools 28.0 made a change that causes an exclusion on a package to also exclude all subpackages:

https://github.com/pypa/setuptools/pull/733

Unfortunately, bodhi's setup.py was relying on the previous behavior to exclude the bodhi package (i.e., the bodhi/**init**.py, which belongs to the common package) and now the setup.py is not installing the server's code anymore.

We will need to find a way to work around this change that works in both the new and old setuptool versions.



Discussion:
It seems that the 28.0 release of setuptools also changes the behaviour of the `include` argument such that it will not include subpackages if their superpackages are not also part of the include list. Though I could just not use `find_packages()` for Bodhi, I'd prefer to keep using if I can so that any future new packages automatically get included. Thus, I think I will just use something like:

```
server_packages = find_packages(include=['bodhi', 'bodhi.server', 'bodhi.server.*'])
server_packages.remove('bodhi')
```


Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -143,6 +143,12 @@
 
 
 setuptools.command.egg_info.manifest_maker.template = 'SERVER_MANIFEST.in'
+# Due to https://github.com/pypa/setuptools/issues/808, we need to include the bodhi superpackage
+# and then remove it if we want find_packages() to find the bodhi.server package and its
+# subpackages without including the bodhi top level package.
+server_packages = find_packages(
+    exclude=['bodhi.client', 'bodhi.client.*', 'bodhi.tests', 'bodhi.tests.*'])
+server_packages.remove('bodhi')
 
 
 setup(name='bodhi-server',
@@ -160,8 +166,7 @@
       platforms=PLATFORMS,
       url=URL,
       keywords='web fedora pyramid',
-      packages=find_packages(
-          exclude=['bodhi', 'bodhi.client', 'bodhi.client.*', 'bodhi.tests', 'bodhi.tests.*']),
+      packages=server_packages,
       include_package_data=True,
 #      script_args=sys.argv.extend(['--template', 'TEST']),
       zip_safe=False,


Test patch:
Repository: fedora-infra/bodhi

Issue:
GET on /masher/ errors with a 404 response
GET on `/masher` works, but GET on `/masher/` returns an HTTP 404 error code. We should add a route to allow the trailing slash on this URL.



Discussion:

Resolving patch:
diff --git a/bodhi/server/__init__.py b/bodhi/server/__init__.py
--- a/bodhi/server/__init__.py
+++ b/bodhi/server/__init__.py
@@ -191,7 +191,7 @@ def main(global_config, testing=None, session=None, **settings):
 
     # Metrics
     config.add_route('metrics', '/metrics')
-    config.add_route('masher_status', '/masher')
+    config.add_route('masher_status', '/masher/')
 
     # Auto-completion search
     config.add_route('search_packages', '/search/packages')


Test patch:
Repository: fedora-infra/bodhi

Issue:
Autokarma should not be None
Came to know about the issue when I was working on #1027 
We need to make sure that `Autokarma` cannot be `None`. It should be either `True` or `False`.

![screenshot from 2016-10-19 10-44-14](https://cloud.githubusercontent.com/assets/13337039/19506418/073349ce-95e9-11e6-8627-6b9f6b8a348f.png)



Discussion:
We need to adjust the migration script for the same.


Resolving patch:
diff --git a/alembic/versions/4f2f825bcf4a_disallow_null_values_in_autokarma.py b/alembic/versions/4f2f825bcf4a_disallow_null_values_in_autokarma.py
new file mode 100644
--- /dev/null
+++ b/alembic/versions/4f2f825bcf4a_disallow_null_values_in_autokarma.py
@@ -0,0 +1,34 @@
+"""Disallow NULL values in autokarma.
+
+Revision ID: 4f2f825bcf4a
+Revises: 06aa0e8aa5d2
+Create Date: 2016-10-19 15:09:50.884185
+
+"""
+
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '4f2f825bcf4a'
+down_revision = '06aa0e8aa5d2'
+
+
+def upgrade():
+    """
+    Find all records with autokarma set to NULL and change them to be False, then disallow further NULL values.
+    """
+    # Build a fake mini version of the updates table so we can form an UPDATE statement.
+    updates = sa.sql.table('updates', sa.sql.column('autokarma', sa.Boolean))
+    # Set records with NULL autokarma to False.
+    op.execute(updates.update().where(updates.c.autokarma == None).values({'autokarma': False}))
+    # Finally, disallow new NULL values.
+    op.alter_column('updates', 'autokarma', existing_type=sa.BOOLEAN(), nullable=False)
+
+
+def downgrade():
+    """
+    Re-allow NULL values. We can't know which False's used to be NULL because that information is lost.
+    """
+    op.alter_column('updates', 'autokarma', existing_type=sa.BOOLEAN(), nullable=True)
diff --git a/bodhi/server/models/models.py b/bodhi/server/models/models.py
--- a/bodhi/server/models/models.py
+++ b/bodhi/server/models/models.py
@@ -603,7 +603,7 @@ class Update(Base):
 
     title = Column(UnicodeText, unique=True, default=None, index=True)
 
-    autokarma = Column(Boolean, default=True)
+    autokarma = Column(Boolean, default=True, nullable=False)
     stable_karma = Column(Integer, nullable=True)
     unstable_karma = Column(Integer, nullable=True)
     requirements = Column(UnicodeText)


Test patch:
diff --git a/bodhi/tests/server/models/test_models.py b/bodhi/tests/server/models/test_models.py
--- a/bodhi/tests/server/models/test_models.py
+++ b/bodhi/tests/server/models/test_models.py
@@ -222,6 +222,14 @@ def get_update(self, name=u'TurboGears-1.0.8-3.fc11'):
             ))
         return self.klass(**attrs)
 
+    def test_autokarma_not_nullable(self):
+        """Assert that the autokarma column does not allow NULL values.
+
+        For history about why this is important, see
+        https://github.com/fedora-infra/bodhi/issues/1048
+        """
+        eq_(model.Update.__table__.columns['autokarma'].nullable, False)
+
     def test_builds(self):
         eq_(len(self.obj.builds), 1)
         eq_(self.obj.builds[0].nvr, u'TurboGears-1.0.8-3.fc11')