From 9c2cb4ab07a03504fb64cd7a2fd16f7dc6d8eb77 Mon Sep 17 00:00:00 2001 From: Stephen Benjamin Date: Mon, 17 Oct 2016 14:01:29 -0400 Subject: [PATCH] Add a github UDA for user field --- bugwarrior/docs/services/github.rst | 2 ++ bugwarrior/services/github.py | 6 ++++++ tests/test_github.py | 5 ++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/bugwarrior/docs/services/github.rst b/bugwarrior/docs/services/github.rst index 6e5515637..150b1230d 100644 --- a/bugwarrior/docs/services/github.rst +++ b/bugwarrior/docs/services/github.rst @@ -135,3 +135,5 @@ Provided UDA Fields +---------------------+---------------------+---------------------+ | ``githubrepo`` | username/reponame | Text (string) | +---------------------+---------------------+---------------------+ +| ``githubuser`` | User created by | Text (string) | ++---------------------+---------------------+---------------------+ diff --git a/bugwarrior/services/github.py b/bugwarrior/services/github.py index 3dd70914a..e28caa736 100644 --- a/bugwarrior/services/github.py +++ b/bugwarrior/services/github.py @@ -108,6 +108,7 @@ class GithubIssue(Issue): REPO = 'githubrepo' TYPE = 'githubtype' NUMBER = 'githubnumber' + USER = 'githubuser' UDAS = { TITLE: { @@ -146,6 +147,10 @@ class GithubIssue(Issue): 'type': 'numeric', 'label': 'Github Issue/PR #', }, + USER: { + 'type': 'string', + 'label': 'Github User', + }, } UNIQUE_KEY = (URL, TYPE,) @@ -175,6 +180,7 @@ def to_taskwarrior(self): self.URL: self.record['html_url'], self.REPO: self.record['repo'], self.TYPE: self.extra['type'], + self.USER: self.record['user']['login'], self.TITLE: self.record['title'], self.BODY: body, self.MILESTONE: milestone, diff --git a/tests/test_github.py b/tests/test_github.py index 2b7f06ab8..d345f39f4 100644 --- a/tests/test_github.py +++ b/tests/test_github.py @@ -26,6 +26,7 @@ class TestGithubIssue(AbstractServiceTest, ServiceTest): 'url': 'https://api.github.com/repos/arbitrary_username/arbitrary_repo/issues/1', 'number': 10, 'body': 'Something', + 'user': {'login': 'arbitrary_login'}, 'milestone': {'title': 'alpha'}, 'labels': [{'name': 'bugfix'}], 'created_at': arbitrary_created.isoformat(), @@ -71,6 +72,7 @@ def test_to_taskwarrior(self): issue.CREATED_AT: self.arbitrary_created, issue.BODY: self.arbitrary_issue['body'], issue.MILESTONE: self.arbitrary_issue['milestone']['title'], + issue.USER: self.arbitrary_issue['user']['login'], } actual_output = issue.to_taskwarrior() @@ -121,8 +123,9 @@ def test_issues(self): 'githubtype': 'issue', 'githubupdatedat': self.arbitrary_updated, 'githuburl': u'http://whanot.com/', + 'githubuser': u'arbitrary_login', 'priority': 'M', - 'project': 'arbitrary_repo', + 'project': 'arbitrary_login', 'tags': []} self.assertEqual(issue.get_taskwarrior_record(), expected)