diff --git a/bugwarrior/README.rst b/bugwarrior/README.rst index b763df1f8..d73d36fc5 100644 --- a/bugwarrior/README.rst +++ b/bugwarrior/README.rst @@ -72,3 +72,4 @@ Contributors - BinaryBabel (contributed support for YouTrack) - Matthew Cengia (contributed extra support for Trello) - Andrew Demas (contributed support for PivotalTracker) +- Stephan Meijer (contributed fixes for JIRA, extra support for Gmail) diff --git a/bugwarrior/docs/configuration.rst b/bugwarrior/docs/configuration.rst index 550200643..727893022 100644 --- a/bugwarrior/docs/configuration.rst +++ b/bugwarrior/docs/configuration.rst @@ -189,6 +189,7 @@ Example Configuration service = gmail gmail.query = label:action OR label:readme gmail.login_name = you@example.com + gmail.project_name = example [pivotaltracker] service = pivotaltracker diff --git a/bugwarrior/services/gmail.py b/bugwarrior/services/gmail.py index c1cd24d42..35e967249 100644 --- a/bugwarrior/services/gmail.py +++ b/bugwarrior/services/gmail.py @@ -74,6 +74,7 @@ def to_taskwarrior(self): 'entry': self.get_entry(), 'tags': [label for label in self.extra['labels'] if label not in self.EXCLUDE_LABELS], 'priority': self.origin['default_priority'], + 'project': self.origin['project_name'], self.THREAD_ID: self.record['id'], self.SUBJECT: self.extra['subject'], self.URL: self.extra['url'], @@ -124,6 +125,8 @@ def __init__(self, *args, **kw): 'gmail_credentials_%s.pickle' % (credentials_name,)) self.gmail_api = self.build_api() + self.project_name = self.config.get('project_name', None) + def get_config_path(self, varname, default_path=None): return os.path.expanduser(self.config.get(varname, default_path)) @@ -167,7 +170,7 @@ def get_credentials(self): def get_labels(self): result = self.gmail_api.users().labels().list(userId=self.login_name).execute() - return {label['id']: label['name'] for label in result['labels']} + return { label['id']: label['name'] for label in result['labels'] } def get_threads(self): thread_service = self.gmail_api.users().threads() @@ -194,6 +197,9 @@ def issues(self): yield issue + def get_service_metadata(self): + return { 'project_name': self.project_name } + def thread_extras(thread, labels): name, address = thread_last_sender(thread) last_message_id = thread_last_message_id(thread) diff --git a/tests/test_gmail.py b/tests/test_gmail.py index 3a0182095..1dbb6be2b 100644 --- a/tests/test_gmail.py +++ b/tests/test_gmail.py @@ -109,6 +109,7 @@ class TestGmailIssue(AbstractServiceTest, ServiceTest): SERVICE_CONFIG = { 'gmail.add_tags': 'added', 'gmail.login_name': 'test@example.com', + 'gmail.project_name': 'test_project' } def setUp(self): @@ -144,6 +145,7 @@ def test_to_taskwarrior(self): 'gmailurl': 'https://mail.google.com/mail/u/0/#all/1234', 'gmaillabels': 'CATEGORY_PERSONAL IMPORTANT postit sticky', 'priority': u'M', + 'project': 'test_project', 'gmaillastsenderaddr': 'foobar@example.com'} taskwarrior = issue.to_taskwarrior() @@ -162,6 +164,7 @@ def test_issues(self): 'gmaillastsender': 'Foo Bar', 'description': u'(bw)Is#1234 - Regarding Bugwarrior .. https://mail.google.com/mail/u/0/#all/1234', 'priority': u'M', + 'project': 'test_project', 'tags': {'added', 'postit', 'sticky'}, 'gmailsubject': 'Regarding Bugwarrior', 'gmailurl': 'https://mail.google.com/mail/u/0/#all/1234',