diff --git a/bugwarrior/services/gerrit.py b/bugwarrior/services/gerrit.py index 30c35600..0b61b9a1 100644 --- a/bugwarrior/services/gerrit.py +++ b/bugwarrior/services/gerrit.py @@ -7,6 +7,9 @@ from bugwarrior import config from bugwarrior.services import IssueService, Issue, ServiceClient +import logging +log = logging.getLogger(__name__) + class GerritConfig(config.ServiceConfig): service: typing_extensions.Literal['gerrit'] @@ -16,6 +19,7 @@ class GerritConfig(config.ServiceConfig): ssl_ca_path: typing.Optional[config.ExpandedPath] = None query: str = 'is:open+is:reviewer' + ignore_user_comments: config.ConfigList = config.ConfigList([]) class GerritIssue(Issue): @@ -151,6 +155,9 @@ def annotations(self, change): else: username = item['author']['_account_id'] # Gerrit messages are really messy + if username in self.config.ignore_user_comments: + log.debug(" ignoring comment from %s", username) + continue message = item['message']\ .lstrip('Patch Set ')\ .lstrip("%s:" % item['_revision_number'])\ diff --git a/bugwarrior/services/github.py b/bugwarrior/services/github.py index 89037550..676f9c69 100644 --- a/bugwarrior/services/github.py +++ b/bugwarrior/services/github.py @@ -40,6 +40,7 @@ class GithubConfig(config.ServiceConfig): body_length: int = sys.maxsize project_owner_prefix: bool = False issue_urls: config.ConfigList = config.ConfigList([]) + ignore_user_comments: config.ConfigList = config.ConfigList([]) @pydantic.root_validator def deprecate_password(cls, values): @@ -389,10 +390,16 @@ def annotations(self, tag, issue, issue_obj): if self.main_config.annotation_comments: comments = self._comments(tag, issue['number']) log.debug(" got comments for %s", issue['html_url']) - annotations = (( - c['user']['login'], - c['body'], - ) for c in comments) + annotations = [] + for c in comments: + login = c['user']['login'] + if login in self.config.ignore_user_comments: + log.debug(" ignoring comment from %s", login) + continue + annotations.append(( + login, + c['body'], + )) return self.build_annotations( annotations, issue_obj.get_processed_url(url)