Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to ignore certain users comments #1039

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions bugwarrior/services/gerrit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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):
Expand Down Expand Up @@ -151,6 +155,9 @@ def annotations(self, change):
else:
username = item['author']['_account_id']
# Gerrit messages are really messy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment was about the cleaning of the message below. You should move it below your addition or, perhaps better, delete it.

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'])\
Expand Down
15 changes: 11 additions & 4 deletions bugwarrior/services/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down
Loading