Skip to content

Commit

Permalink
gitlab: add uda for work-in-progress flag
Browse files Browse the repository at this point in the history
  • Loading branch information
mathstuf committed Aug 24, 2015
1 parent 170b45b commit fe940c2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions bugwarrior/docs/services/gitlab.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,5 @@ Provided UDA Fields
+-----------------------+-----------------------+---------------------+
| ``gitlabdownvotes`` | Number of downvotes | Numeric |
+-----------------------+-----------------------+---------------------+
| ``gitlabwip`` | Work-in-Progress flag | Numeric |
+-----------------------+-----------------------+---------------------+
8 changes: 8 additions & 0 deletions bugwarrior/services/gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class GitlabIssue(Issue):
STATE = 'gitlabstate'
UPVOTES = 'gitlabupvotes'
DOWNVOTES = 'gitlabdownvotes'
WORK_IN_PROGRESS = 'gitlabwip'

UDAS = {
TITLE: {
Expand Down Expand Up @@ -72,6 +73,10 @@ class GitlabIssue(Issue):
'type': 'numeric',
'label': 'Gitlab Downvotes',
},
WORK_IN_PROGRESS: {
'type': 'numeric',
'label': 'Gitlab MR Work-In-Progress Flag',
},
}
UNIQUE_KEY = (REPO, TYPE, NUMBER,)

Expand All @@ -87,6 +92,7 @@ def to_taskwarrior(self):
state = self.record['state']
upvotes = self.record['upvotes']
downvotes = self.record['downvotes']
work_in_progress = self.record.get('work_in_progress', 0)
else:
priority = self.origin['default_priority']
milestone = self.record['milestone']
Expand All @@ -95,6 +101,7 @@ def to_taskwarrior(self):
state = self.record['state']
upvotes = 0
downvotes = 0
work_in_progress = 0

if milestone:
milestone = milestone['title']
Expand All @@ -121,6 +128,7 @@ def to_taskwarrior(self):
self.STATE: state,
self.UPVOTES: upvotes,
self.DOWNVOTES: downvotes,
self.WORK_IN_PROGRESS: work_in_progress,
}

def get_tags(self):
Expand Down
4 changes: 3 additions & 1 deletion tests/test_gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class TestGitlabIssue(ServiceTest):
},
"state": "opened",
"updated_at": arbitrary_updated.isoformat(),
"created_at": arbitrary_created.isoformat()
"created_at": arbitrary_created.isoformat(),
"work_in_progress": True
}
arbitrary_extra = {
'issue_url': 'https://gitlab.example.com/arbitrary_username/project/issues/3',
Expand Down Expand Up @@ -98,6 +99,7 @@ def test_to_taskwarrior(self):
issue.MILESTONE: self.arbitrary_issue['milestone']['title'],
issue.UPVOTES: 0,
issue.DOWNVOTES: 0,
issue.WORK_IN_PROGRESS: 0,
}
actual_output = issue.to_taskwarrior()

Expand Down

0 comments on commit fe940c2

Please sign in to comment.