Skip to content

Commit 238f055

Browse files
committed
cli: convert outputformat %{external_bugs} to full URLs
Resolves: #65
1 parent f535954 commit 238f055

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

bugzilla/_cli.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,14 @@ def bug_field(matchobj):
713713
val += ("\n* %s - %s:\n%s\n" % (c['time'],
714714
c.get("creator", c.get("author", "")), c['text']))
715715

716+
elif fieldname == "external_bugs":
717+
val = ""
718+
for e in getattr(b, "external_bugs", []):
719+
url = e["type"]["full_url"].replace("%id%", e["ext_bz_bug_id"])
720+
if not val:
721+
val += "\n"
722+
val += "External bug: %s\n" % url
723+
716724
elif fieldname == "__unicode__":
717725
val = b.__unicode__()
718726
else:

tests/ro_functional.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,3 +337,10 @@ def testExtraFields(self):
337337
bug = bz.getbug(720773, include_fields=["summary"])
338338
self.assertTrue("summary" in dir(bug))
339339
self.assertTrue("comments" not in dir(bug))
340+
341+
def testExternalBugsOutput(self):
342+
out = self.clicomm('query --bug_id 989253 '
343+
'--outputformat="%{external_bugs}"')
344+
expect = ("http://bugzilla.gnome.org/show_bug.cgi?id=703421\n" +
345+
"External bug: https://bugs.launchpad.net/bugs/1203576")
346+
self.assertTrue(expect in out)

0 commit comments

Comments
 (0)