It's better to use hashes instead of IDs which might change, we have support for this since 3000b1b.
Closes #170.
Signed-off-by: Richard Marko rmarko@redhat.com --- config/templates/bugzilla_new_body | 2 +- config/templates/bugzilla_update_comment | 2 +- pyfaf/bugzilla.py | 16 +++++++++++++++- tests/bugzilla | 4 ++-- 4 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/config/templates/bugzilla_new_body b/config/templates/bugzilla_new_body index d6402eb..a4b01f5 100644 --- a/config/templates/bugzilla_new_body +++ b/config/templates/bugzilla_new_body @@ -3,7 +3,7 @@ Description of problem: Faf server recevied number of crash reports for this package.
Problem URL: -{{ server_url }}{% url pyfaf.hub.problems.views.item problem.id %} +{{ server_url }}{% url pyfaf.hub.problems.views.bthash_forward faf_hash %}
Version-Release number of selected component: {{ package.nvra }} diff --git a/config/templates/bugzilla_update_comment b/config/templates/bugzilla_update_comment index 6a1cc6a..c86b2af 100644 --- a/config/templates/bugzilla_update_comment +++ b/config/templates/bugzilla_update_comment @@ -2,6 +2,6 @@ This problem received over {{report_count}} reports. {% if server_url %} Following link might provide more details: -{{ server_url }}{% url pyfaf.hub.problems.views.item problem.id %} +{{ server_url }}{% url pyfaf.hub.problems.views.bthash_forward faf_hash %} {% endif %} {% endautoescape %} diff --git a/pyfaf/bugzilla.py b/pyfaf/bugzilla.py index 4b374d2..4c3a84c 100644 --- a/pyfaf/bugzilla.py +++ b/pyfaf/bugzilla.py @@ -743,6 +743,7 @@ class Bugzilla(object): data['executable'] = report.executables[0].path
data['duphash'] = report.backtraces[0].btp_hash() + data['faf_hash'] = report.backtraces[0].hash
highest_version = -1 highest_release = None @@ -901,9 +902,22 @@ class Bugzilla(object): new_wb = '{0} reports:{1}'.format(bug.whiteboard, current_count)
+ # get top report + if not problem.reports: + logging.warning('Refusing to process problem with no reports.') + continue + + report = problem.sorted_reports[0] + if not report.backtraces: + logging.warning('Refusing to process report with no backtrace.') + continue + + faf_hash = report.backtraces[0].hash + comment = template.render(template_name, dict(report_count=current_count, - problem=problem)) + problem=problem, + faf_hash=faf_hash))
logging.info('Adding comment to bug #{0}.' ' Comment:\n\n{1}\n'.format(bug.id, comment)) diff --git a/tests/bugzilla b/tests/bugzilla index 8cc1fe2..fd6b1fe 100755 --- a/tests/bugzilla +++ b/tests/bugzilla @@ -291,7 +291,7 @@ class BugzillaTestCase(faftests.RealworldCase): self.assertIn('in unknown function', bug['summary'])
self.assertIn('reports count', bug['description']) - self.assertIn('https://example.org/problems/1/', bug['description']) + self.assertIn('https://example.org/problems/bthash/', bug['description']) self.assertIn('server@example.org', bug['description'])
self.assertNotIn('None', bug['summary']) @@ -390,7 +390,7 @@ class BugzillaTestCase(faftests.RealworldCase): break
text = comment.get_lob('content') - self.assertIn('https://example.org/problems/1/', text) + self.assertIn('https://example.org/problems/bthash/', text) self.assertIn(str(prob.reports_count), text)
def test_update_bugs_doesnt_update_too_soon(self):
crash-catcher@lists.fedorahosted.org