diff --git a/mdk/commands/tracker.py b/mdk/commands/tracker.py index fc743f7..a2996ba 100644 --- a/mdk/commands/tracker.py +++ b/mdk/commands/tracker.py @@ -33,6 +33,13 @@ class TrackerCommand(Command): _arguments = [ + ( + ['--open'], + { + 'action': 'store_true', + 'help': 'Open issue in browser' + } + ), ( ['-t', '--testing'], { @@ -95,9 +102,14 @@ def run(self, args): if not issue or not re.match('(MDL|mdl)?(-|_)?[1-9]+', issue): raise Exception('Invalid or unknown issue number') - self.Jira = Jira() self.mdl = 'MDL-' + re.sub(r'(MDL|mdl)(-|_)?', '', issue) + if args.open: + Jira.openInBrowser(self.mdl) + return + + self.Jira = Jira() + if args.addlabels: if 'triaged' in args.addlabels: self.argumentError('The label \'triaged\' cannot be added using MDK') diff --git a/mdk/jira.py b/mdk/jira.py index a7bad54..2c056be 100644 --- a/mdk/jira.py +++ b/mdk/jira.py @@ -31,6 +31,7 @@ import logging import os import requests +import webbrowser import mimetypes try: import keyring @@ -398,6 +399,11 @@ def upload(self, key, filepath): return True + @staticmethod + def openInBrowser(key): + jiraurl = C.get('tracker.url').rstrip('/') + url = "{0}/browse/{1}".format(jiraurl, key) + webbrowser.open_new_tab(url) class JiraException(Exception): pass