Skip to content

Commit

Permalink
Add a github UDA for user field
Browse files Browse the repository at this point in the history
  • Loading branch information
stbenjam committed Oct 17, 2016
1 parent df88fc8 commit 9c2cb4a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions bugwarrior/docs/services/github.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,5 @@ Provided UDA Fields
+---------------------+---------------------+---------------------+
| ``githubrepo`` | username/reponame | Text (string) |
+---------------------+---------------------+---------------------+
| ``githubuser`` | User created by | Text (string) |
+---------------------+---------------------+---------------------+
6 changes: 6 additions & 0 deletions bugwarrior/services/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class GithubIssue(Issue):
REPO = 'githubrepo'
TYPE = 'githubtype'
NUMBER = 'githubnumber'
USER = 'githubuser'

UDAS = {
TITLE: {
Expand Down Expand Up @@ -146,6 +147,10 @@ class GithubIssue(Issue):
'type': 'numeric',
'label': 'Github Issue/PR #',
},
USER: {
'type': 'string',
'label': 'Github User',
},
}
UNIQUE_KEY = (URL, TYPE,)

Expand Down Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion tests/test_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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)

0 comments on commit 9c2cb4a

Please sign in to comment.