|
3 | 3 | """Bugwarrior service support class for Gitea |
4 | 4 |
|
5 | 5 | Available classes: |
6 | | -- GiteaClient(ServiceClient): Constructs Gitea API strings |
| 6 | +- GiteaClient(Service): Constructs Gitea API strings |
7 | 7 | - GiteaIssue(Issue): TaskWarrior Interface |
8 | | -- GiteaService(IssueService): Engine for firing off requests |
| 8 | +- GiteaService(Issue): Engine for firing off requests |
9 | 9 |
|
10 | 10 | Todo: |
11 | 11 | * Add token support |
|
25 | 25 | from jinja2 import Template |
26 | 26 |
|
27 | 27 | from bugwarrior import config |
28 | | -from bugwarrior.services import IssueService, Issue, ServiceClient |
| 28 | +from bugwarrior.services import Issue, Service, Client |
29 | 29 |
|
30 | 30 | log = logging.getLogger(__name__) # pylint: disable-msg=C0103 |
31 | 31 |
|
@@ -62,7 +62,7 @@ def get(self, key, default=None, to_type=None): |
62 | 62 | return default |
63 | 63 |
|
64 | 64 |
|
65 | | -class GiteaClient(ServiceClient): |
| 65 | +class GiteaClient(Client): |
66 | 66 | """Builds Gitea API strings |
67 | 67 | Args: |
68 | 68 | host (str): remote gitea server |
@@ -263,8 +263,11 @@ class GiteaIssue(Issue): |
263 | 263 | @staticmethod |
264 | 264 | def _normalize_label_to_tag(label): |
265 | 265 | return re.sub(r'[^a-zA-Z0-9]', '_', label) |
| 266 | + def get_tags(self): |
| 267 | + labels = [label['name'] for label in self.record.get('labels', [])] |
| 268 | + return self.get_tags_from_labels(labels) |
266 | 269 |
|
267 | | - def to_taskwarrior(self): |
| 270 | + def to_taskwarrior(self) -> dict: |
268 | 271 | milestone = self.record['milestone'] |
269 | 272 | if milestone: |
270 | 273 | milestone = milestone['title'] |
@@ -302,31 +305,18 @@ def to_taskwarrior(self): |
302 | 305 | self.NAMESPACE: self.extra['namespace'], |
303 | 306 | self.STATE: self.record.get('state', '') |
304 | 307 | } |
305 | | - def get_tags(self): |
306 | | - labels = [label['name'] for label in self.record.get('labels', [])] |
307 | | - return self.get_tags_from_labels(labels) |
308 | | - |
309 | | - def get_default_description(self): |
310 | | - log.info('In get_default_description') |
311 | | - return self.build_default_description( |
312 | | - title=self.record['title'], |
313 | | - url=self.get_processed_url(self.record['url']), |
314 | | - number=self.record['number'], |
315 | | - cls=self.extra['type'], |
316 | | - ) |
317 | | - |
318 | 308 |
|
319 | 309 | def get_default_description(self): |
320 | 310 | log.info('In get_default_description') |
321 | 311 | return self.build_default_description( |
322 | 312 | title=self.record['title'], |
323 | | - url=self.get_processed_url(self.record['url']), |
| 313 | + url=self.record['url'], |
324 | 314 | number=self.record['number'], |
325 | 315 | cls=self.extra['type'], |
326 | 316 | ) |
327 | 317 |
|
328 | 318 |
|
329 | | -class GiteaService(IssueService): |
| 319 | +class GiteaService(Service): |
330 | 320 | ISSUE_CLASS = GiteaIssue |
331 | 321 | CONFIG_SCHEMA = GiteaConfig |
332 | 322 | CONFIG_PREFIX = 'gitea' |
@@ -455,7 +445,7 @@ def annotations(self, tag, issue, issue_obj): |
455 | 445 | ) for c in comments) |
456 | 446 | annotations_result = self.build_annotations( |
457 | 447 | annotations, |
458 | | - issue_obj.get_processed_url(url)) |
| 448 | + url) |
459 | 449 | log.info('annotations: {}'.format(annotations_result)) |
460 | 450 | return annotations_result |
461 | 451 |
|
@@ -573,6 +563,9 @@ def issues(self): |
573 | 563 | 'annotations': [issue['body']], |
574 | 564 | 'namespace': self.username, |
575 | 565 | } |
576 | | - issue_obj.update_extra(extra) |
| 566 | + issue_obj.extra.update(extra) |
577 | 567 | yield issue_obj |
578 | 568 |
|
| 569 | + |
| 570 | + |
| 571 | + |
0 commit comments