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

Issue:
Remove unscalable items from the testcase JSON
See #270.  There may be some unsustainable information included in the testcase json that will need to be removed.



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
@@ -1806,8 +1806,9 @@ def requested_tag(self):
                 'Unable to determine requested tag for %s.' % self.title)
         return tag
 
-    def __json__(self, *args, **kwargs):
-        result = super(Update, self).__json__(*args, **kwargs)
+    def __json__(self, request=None, anonymize=False):
+        result = super(Update, self).__json__(
+            request=request, anonymize=anonymize)
         # Duplicate alias as updateid for backwards compat with bodhi1
         result['updateid'] = result['alias']
         # Also, put the update submitter's name in the same place we put
@@ -1815,9 +1816,17 @@ def __json__(self, *args, **kwargs):
         result['submitter'] = result['user']['name']
 
         # For https://github.com/fedora-infra/bodhi/issues/270, throw the JSON
-        # of the test cases in our output as well.
+        # of the test cases in our output as well but take extra care to
+        # short-circuit some of the insane recursion for
+        # https://github.com/fedora-infra/bodhi/issues/343
+        seen = [Package, TestCaseKarma]
         result['test_cases'] = [
-            test.__json__(*args, **kwargs) for test in self.full_test_cases
+            test._to_json(
+                obj=test,
+                seen=seen,
+                request=request,
+                anonymize=anonymize)
+            for test in self.full_test_cases
         ]
 
         return result


Test patch:
Repository: fedora-infra/bodhi

Issue:
Large update can be partially tagged before ejected from push.
In the case of this large KDE update https://bodhi.fedoraproject.org/updates/FEDORA-2015-14271 (issue #504) one of the builds was not tagged properly, and was not ejected until a number of builds were queued up to have tags added.

The part of the code responsible for this bug is in the `_determine_tag_actions` in `masher.py`:

``` python
for build in update.builds:                                   
    from_tag = None                                           
    tags = build.get_tags()                                   
    for tag in tags:                                          
        if tag in tag_types[status]:                          
            from_tag = tag                                    
            break                                             
    else:                                                     
        reason = 'Cannot find relevant tag for %s: %s' % (    
            build.nvr, tags)                                  
        self.eject_from_mash(update, reason)                  
        break                                                 

    if self.skip_mash:                                        
        self.add_tags.append((update.requested_tag, build.nvr)
    else:                                                     
        self.move_tags.append((from_tag, update.requested_tag,
                               build.nvr))                    
```

So a bunch of builds in the update get to `self.add_tags`, but once ejected those are never removed. Ideally, I think we should look for relevant tags in the previous `verify_updates` method.



Discussion:

Resolving patch:
diff --git a/bodhi/consumers/masher.py b/bodhi/consumers/masher.py
--- a/bodhi/consumers/masher.py
+++ b/bodhi/consumers/masher.py
@@ -505,6 +505,9 @@ def determine_and_perform_tag_actions(self):
     def _determine_tag_actions(self):
         tag_types, tag_rels = Release.get_tags()
         for update in sorted_updates(self.updates):
+            add_tags = []
+            move_tags = []
+
             if update.status is UpdateStatus.testing:
                 status = 'testing'
             else:
@@ -524,10 +527,13 @@ def _determine_tag_actions(self):
                     break
 
                 if self.skip_mash:
-                    self.add_tags.append((update.requested_tag, build.nvr))
+                    add_tags.append((update.requested_tag, build.nvr))
                 else:
-                    self.move_tags.append((from_tag, update.requested_tag,
-                                           build.nvr))
+                    move_tags.append((from_tag, update.requested_tag,
+                                      build.nvr))
+            else:
+                self.add_tags.extend(add_tags)
+                self.move_tags.extend(move_tags)
 
     def _perform_tag_actions(self):
         self.koji.multicall = True


Test patch:
Repository: fedora-infra/bodhi

Issue:
Setup custom loggers per masher thread with the koji tag as a prefix
Right now it's difficult to differentiate which thread in the masher logs corresponds with which koji tag. We should have them setup a `[tagname]` logging prefix so it's clear which thread each message is from.



Discussion:

Resolving patch:
diff --git a/bodhi/consumers/masher.py b/bodhi/consumers/masher.py
--- a/bodhi/consumers/masher.py
+++ b/bodhi/consumers/masher.py
@@ -260,6 +260,10 @@ def work(self):
                               .filter_by(name=self.release).one()
         self.id = getattr(self.release, '%s_tag' % self.request.value)
 
+        # Set our thread's "name" so it shows up nicely in the logs.
+        # https://docs.python.org/2/library/threading.html#thread-objects
+        self.name = self.id
+
         # For 'pending' branched releases, we only want to perform repo-related
         # tasks for testing updates. For stable updates, we should just add the
         # dist_tag and do everything else other than mashing/updateinfo, since
@@ -902,6 +906,9 @@ def __init__(self, tag, outputdir, comps, previous, log):
             mash_cmd += ' -p {}'.format(previous)
         self.mash_cmd = mash_cmd.format(outputdir=outputdir, config=mash_conf,
                                         compsfile=comps, tag=self.tag).split()
+        # Set our thread's "name" so it shows up nicely in the logs.
+        # https://docs.python.org/2/library/threading.html#thread-objects
+        self.name = tag
 
     def run(self):
         start = time.time()


Test patch:
Repository: fedora-infra/bodhi

Issue:
Should not offer to push to testing on stable update
When I visit https://bodhi.fedoraproject.org/updates/FEDORA-2015-15193 I see a "Push to testing" button in the upper right next to edit.  This shouldn't be offered as the update is already pushed to stable.



Discussion:
Another example: https://bodhi.fedoraproject.org/updates/rpm-mpi-hooks-3-2.fc23%2Cmathgl-2.3-10.fc23%2Celpa-2015.05.001-2.fc23%2Cfreefem%2B%2B-3.31-7.3.fc23%2Cnetcdf-4.3.3.1-5.fc23%2CMUMPS-5.0.1-2.fc23%2Cgpaw-0.11.0.13004-15.fc23%2Cga-5.3b-18.fc23%2Cvalgrind-3.10.1-19.fc23%2Cboost-1.58.0-6.fc23%2Cdl_poly-1.9.20140324-14.fc23%2Chpl-2.1-13.fc23%2Cnetgen-mesher-5.3.1-8.fc23%2Cespresso-3.3.0-7.fc23%2Cscotch-6.0.4-5.fc23%2Chdf5-1.8.15-6.patch1.fc23%2Cscalapack-2.0.2-10.fc23%2Cgromacs-5.0.6-6.fc23%2Cscorep-1.4.2-2.fc23%2Csundials-2.6.2-4.fc23%2CRay-2.3.1-11.fc23%2Corsa-0.7.0-33.fc23%2Celk-3.1.12-14.fc23%2Cmpich-3.1.4-5.fc23%2Copenmpi-1.8.8-3.fc23%2Cmpi4py-1.3.1-14.fc23%2Cpypar-2.1.5_108-11.fc23%2Cparaview-4.3.1-11.fc23


Resolving patch:
diff --git a/alembic/versions/2defe1107259_set_the_pushed_flag.py b/alembic/versions/2defe1107259_set_the_pushed_flag.py
new file mode 100644
--- /dev/null
+++ b/alembic/versions/2defe1107259_set_the_pushed_flag.py
@@ -0,0 +1,47 @@
+"""Set the pushed flag.
+
+Revision ID: 2defe1107259
+Revises: 70a58ae9f90
+Create Date: 2015-09-11 15:39:03.656516
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '2defe1107259'
+down_revision = '70a58ae9f90'
+
+from alembic import op
+import sqlalchemy as sa
+
+import transaction
+
+import logging
+log = logging.getLogger('alembic.migration')
+
+from bodhi.models import DBSession, Base, Update
+
+def upgrade():
+    log.warn("Skipping.  Do this by hand by uncommenting and running in tmux.")
+    #log.info("Getting session for data upgrade.")
+    #engine = op.get_bind().engine
+    #DBSession.configure(bind=engine)
+    #Base.metadata.bind = engine
+
+    #with transaction.manager:
+    #    log.info("Querying for all updates with pushed!=True.")
+    #    query = DBSession.query(Update).filter(Update.pushed!=True)
+    #    total = query.count()
+    #    log.info(" %i" % total)
+    #    log.info("OK")
+    #    for i, update in enumerate(query.yield_per(1000).enable_eagerloads(False)):
+    #        if i % 100 == 0:
+    #            log.info(" Considering update (%i/%i) %r" % (
+    #                i, total, update.title))
+    #        if update.date_stable or update.date_testing:
+    #            update.pushed = True
+    #    log.info("Done.  Committing..")
+
+
+def downgrade():
+    # NOPE!
+    pass
diff --git a/bodhi/models/models.py b/bodhi/models/models.py
--- a/bodhi/models/models.py
+++ b/bodhi/models/models.py
@@ -1187,6 +1187,7 @@ def request_complete(self):
             self.date_stable = now
         self.request = None
         self.date_pushed = now
+        self.pushed = True
 
     def modify_bugs(self):
         """ Comment on and close this updates bugs as necessary


Test patch:
Repository: fedora-infra/bodhi

Issue:
Unable to revoke request from unpushed update
It errors out and says that I can only revoke a request from a pending or testing update.



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
@@ -1537,10 +1537,11 @@ def revoke(self):
             raise BodhiException(
                 "Can only revoke an update with an existing request")
 
-        if self.status not in [UpdateStatus.pending, UpdateStatus.testing]:
+        if self.status not in [UpdateStatus.pending, UpdateStatus.testing,
+                               UpdateStatus.obsolete, UpdateStatus.unpushed]:
             raise BodhiException(
-                "Can only revoke a pending or testing update, not "
-                "one that is %s" % self.status.description)
+                "Can only revoke a pending, testing, unpushed, or obsolete "
+                "update, not one that is %s" % self.status.description)
 
         # Remove the 'pending' koji tags from this update so taskotron stops
         # evalulating them.


Test patch:
Repository: fedora-infra/bodhi

Issue:
Removing pending tag from ejected updates
When an update is ejected from a push, the `request` is removed, which means we should probably remove the `-pending` tag as well so Taskotron doesn't get confused.



Discussion:

Resolving patch:
diff --git a/bodhi/consumers/masher.py b/bodhi/consumers/masher.py
--- a/bodhi/consumers/masher.py
+++ b/bodhi/consumers/masher.py
@@ -422,6 +422,13 @@ def eject_from_mash(self, update, reason):
         text = '%s ejected from the push because %r' % (update.title, reason)
         log.warn(text)
         update.comment(text, author=u'bodhi')
+        # Remove the pending tag as well
+        if update.request is UpdateRequest.stable:
+            update.remove_tag(update.release.pending_stable_tag,
+                              koji=self.koji)
+        elif update.request is UpdateRequest.testing:
+            update.remove_tag(update.release.pending_testing_tag,
+                              koji=self.koji)
         update.request = None
         if update in self.state['updates']:
             self.state['updates'].remove(update)


Test patch:
Repository: fedora-infra/bodhi

Issue:
API: provide URL for updates
When I run an API query for updates, for each update I get a dict (well, a `Munch`, fine) with lots of useful keys, but none that gives the update's URL. This would be rather handy. It's relatively easy to construct it from the client instance's `base_url` attribute, but it requires your app to have some random magic knowledge - that the URL is `{0}updates/{1}.format(client.base_url, update['updateid'])` - and it's a bit awkward if the place where you want to use the URL has the update dict but doesn't have access to the client instance (you have to add the URL to the update dicts when you initially get them). It'd be nice if this was just there.



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
@@ -584,7 +584,7 @@ def unpush(self, koji):
 class Update(Base):
     __tablename__ = 'updates'
     __exclude_columns__ = ('id', 'user_id', 'release_id', 'cves')
-    __include_extras__ = ('meets_testing_requirements',)
+    __include_extras__ = ('meets_testing_requirements', 'url',)
     __get_by__ = ('title', 'alias')
 
     title = Column(UnicodeText, default=None, index=True)
@@ -1233,7 +1233,7 @@ def get_url(self):
             path.append(quote(self.title))
         return os.path.join(*path)
 
-    def abs_url(self):
+    def abs_url(self, request=None):
         """ Return the absolute URL to this update """
         base = config['base_address']
         return os.path.join(base, self.get_url())


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
@@ -428,6 +428,9 @@ def test_list_updates(self):
         body = res.json_body
         self.assertEquals(len(body['updates']), 1)
 
+        alias = u'FEDORA-%s-a3bbe1a8f2' % YEAR
+        baseurl = 'http://0.0.0.0:6543'
+
         up = body['updates'][0]
         self.assertEquals(up['title'], u'bodhi-2.0-1.fc17')
         self.assertEquals(up['status'], u'pending')
@@ -444,8 +447,9 @@ def test_list_updates(self):
         self.assertEquals(up['date_modified'], None)
         self.assertEquals(up['date_pushed'], None)
         self.assertEquals(up['locked'], False)
-        self.assertEquals(up['alias'], u'FEDORA-%s-a3bbe1a8f2' % YEAR)
+        self.assertEquals(up['alias'], alias)
         self.assertEquals(up['karma'], 1)
+        self.assertEquals(up['url'], '%s/updates/%s' % (baseurl, alias))
 
     def test_list_updates_jsonp(self):
         res = self.app.get('/updates/',
Repository: fedora-infra/bodhi

Issue:
CSRF tokens do not match - but no advice
I get this quite often after trying to submit a Bodhi comment:
![bodhi](https://cloud.githubusercontent.com/assets/755451/10606096/a3e1812e-7730-11e5-86cb-37409e396b7a.png)

I suppose the reason is that I tend to keep several Bodhi updates open at the same time and leave them open for quite long before I add the comment (I actually need to test stuff, before commenting:)).

If it is not technically possible to eliminate or reduce the likelihood of this issue, OK. But let's make the error message at least helpful. Could you replace it with something like this?

> Error adding comment - CSRF tokens do not match. This happens if you have the page open for a long time. Please reload the page and try to add the comment again. Make sure to save your feedback somewhere before reloading.

Also, it would be helpful to make this more visible. The floating bars in the right corner are not very visible. For errors like these, it would be better to show it in the center of the screen with an OK button and dim the rest of the screen, or maybe show it in a highly visible bar above the Comment box or the Add Comment button.

Thanks!



Discussion:

Resolving patch:
diff --git a/bodhi/validators.py b/bodhi/validators.py
--- a/bodhi/validators.py
+++ b/bodhi/validators.py
@@ -34,13 +34,18 @@
 import bodhi.schemas
 
 
+csrf_error_message = """CSRF tokens do not match.  This happens if you have
+the page open for a long time. Please reload the page and try to submit your
+data again. Make sure to save your input somewhere before reloading.
+""".replace('\n', ' ')
+
 # This one is a colander validator which is different from the cornice
 # validators defined elsehwere.
 def validate_csrf_token(node, value):
     request = pyramid.threadlocal.get_current_request()
     expected = request.session.get_csrf_token()
     if value != expected:
-        raise colander.Invalid(node, 'CSRF tokens do not match')
+        raise colander.Invalid(node, csrf_error_message)
 
 
 def cache_nvrs(request, build):


Test patch:
Repository: fedora-infra/bodhi

Issue:
[RFE] Add override button when an update for a build is created
Hi,

when I update a golang package in Fedora it is always followed by override of its build. Would it be possible to add a button to open a page (bodhi.fedoraproject.org/overrides/new) with override form filled with package name, build and bug id?

Jan



Discussion:

Resolving patch:
diff --git a/bodhi/views/generic.py b/bodhi/views/generic.py
--- a/bodhi/views/generic.py
+++ b/bodhi/views/generic.py
@@ -186,10 +186,11 @@ def masher_status(request):
 @view_config(route_name='new_override', renderer='override.html')
 def new_override(request):
     """ Returns the new buildroot override form """
+    nvr = request.params.get('nvr')
     user = authenticated_userid(request)
     if not user:
         raise HTTPForbidden("You must be logged in.")
-    return dict()
+    return dict(nvr=nvr)
 
 
 @view_config(route_name='api_version', renderer='json')


Test patch:
Repository: fedora-infra/bodhi

Issue:
List of testcases should be sorted
The list of testcases at

https://bodhi.fedoraproject.org/updates/FEDORA-2015-5c8ff15dc9

is not sorted, making it harder to find testcases again.



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
@@ -1758,7 +1758,7 @@ def test_cases(self):
         for build in self.builds:
             for test in build.package.test_cases:
                 tests.add(test.name)
-        return list(tests)
+        return sorted(list(tests))
 
     @property
     def full_test_cases(self):
@@ -1766,7 +1766,7 @@ def full_test_cases(self):
         for build in self.builds:
             for test in build.package.test_cases:
                 tests.add(test)
-        return list(tests)
+        return sorted(list(tests))
 
     @property
     def requested_tag(self):


Test patch:
Repository: fedora-infra/bodhi

Issue:
Missing unit tests for abrt
I received an email from an ABRT developer mentioning that some of their unit tests were not appearing in their updates.



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
@@ -430,9 +430,10 @@ def fetch_test_cases(self, db):
         wiki = MediaWiki(config.get('wiki_url', 'https://fedoraproject.org/w/api.php'))
         cat_page = 'Category:Package %s test cases' % self.name
 
-        def list_categorymembers(wiki, cat_page, limit=10):
+        def list_categorymembers(wiki, cat_page, limit=500):
             # Build query arguments and call wiki
-            query = dict(action='query', list='categorymembers', cmtitle=cat_page)
+            query = dict(action='query', list='categorymembers',
+                         cmtitle=cat_page, cmlimit=limit)
             response = wiki.call(query)
             members = [entry['title'] for entry in
                        response.get('query',{}).get('categorymembers',{})


Test patch:
Repository: fedora-infra/bodhi

Issue:
Bodhi doesn't send emails to the update submitter
When I submit an update, I never get any emails about the update afterwards. I need to comment on the update to start getting email from bodhi. Please make it so that update submitters get those emails as well.

Recent example: https://bodhi.fedoraproject.org/updates/FEDORA-2015-48362b03d1 , haven't gotten a single email about it.



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
@@ -1565,7 +1565,7 @@ def get_maintainers(self):
         Return a list of User objects that have commit access to all of the
         packages that are contained within this update.
         """
-        people = set()
+        people = set([self.user])
         for build in self.builds:
             if build.package.committers:
                 for committer in build.package.committers:


Test patch:
Repository: fedora-infra/bodhi

Issue:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 95: ordinal not in range(128) 
If I click the following 3 links for the ibus-typing-booster-1.2.15-1
updates on

https://bodhi.fedoraproject.org/users/mfabian

ibus-typing-booster-1.2.15-1.fc23
https://bodhi.fedoraproject.org/updates/FEDORA-2015-c97e8a4bd5

ibus-typing-booster-1.2.15-1.fc22
https://bodhi.fedoraproject.org/updates/FEDORA-2015-ccb91a63a8

ibus-typing-booster-1.2.15-1.fc21
https://bodhi.fedoraproject.org/updates/FEDORA-2015-2c65f7392a

I get a Python backtrace:

500 Server Error

Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/pyramid_mako/**init**.py", line 148, in **call** result = template.render_unicode(**system) File "/usr/lib/python2.7/site-packages/mako/template.py", line 452, in render_unicode as_unicode=True) File "/usr/lib/python2.7/site-packages/mako/runtime.py", line 784, in _render return context._pop_buffer().getvalue() File "/usr/lib/python2.7/site-packages/mako/util.py", line 150, in getvalue return self.delim.join(self.data) UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 95: ordinal not in range(128)



Discussion:
I see the same problem for these ibus-table updates:

https://bodhi.fedoraproject.org/updates/FEDORA-2015-67b99c3223
https://bodhi.fedoraproject.org/updates/FEDORA-2015-300e8d7e09
https://bodhi.fedoraproject.org/updates/FEDORA-2015-3de4709749


Resolving patch:
diff --git a/bodhi/util.py b/bodhi/util.py
--- a/bodhi/util.py
+++ b/bodhi/util.py
@@ -41,7 +41,6 @@
 from zope.sqlalchemy import ZopeTransactionExtension
 from pyramid.i18n import TranslationStringFactory
 from pyramid.settings import asbool
-from kitchen.text.converters import to_bytes
 
 from . import log, buildsys
 from .exceptions import RepodataException
@@ -477,7 +476,7 @@ def bug_link(context, bug, short=False):
     if not short:
         if bug.title:
             # We're good...
-            link = link + " " + to_bytes(bug.title)
+            link = link + " " + bug.title
         else:
             # Otherwise, the backend is async grabbing the title from rhbz, so
             link = link + " <img class='spinner' src='static/img/spinner.gif'>"


Test patch:
diff --git a/bodhi/tests/models/test_models.py b/bodhi/tests/models/test_models.py
--- a/bodhi/tests/models/test_models.py
+++ b/bodhi/tests/models/test_models.py
@@ -386,7 +386,7 @@ def test_unicode_bug_title(self):
         bug.title = u'foo\xe9bar'
         from bodhi.util import bug_link
         link = bug_link(None, bug)
-        eq_(link, "<a target='_blank' href='https://bugzilla.redhat.com/show_bug.cgi?id=1'>#1</a> foo\xc3\xa9bar")
+        eq_(link, u"<a target='_blank' href='https://bugzilla.redhat.com/show_bug.cgi?id=1'>#1</a> foo\xe9bar")
 
     def test_set_request_untested_stable(self):
         """