Skip to content

Commit

Permalink
Make newline stripping in annotations configurable.
Browse files Browse the repository at this point in the history
Fixes #637.
  • Loading branch information
ralphbean committed May 6, 2019
1 parent 9f340b1 commit f69bbed
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions bugwarrior/docs/common_configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Optional options include:
annotation. Defaults to ``False``.
* ``annotation_comments``: When ``False`` skips putting issue comments into
annotations. Defaults to ``True``.
* ``annotation_newlines``: When ``False`` strips newlines from comments in
annotations. Defaults to ``False``.
* ``legacy_matching``: Set to ``False`` to instruct Bugwarrior to match
issues using only the issue's unique identifiers (rather than matching
on description).
Expand Down
3 changes: 3 additions & 0 deletions bugwarrior/docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ Example Configuration
# annotations
annotation_comments = True

# Setting this to False will strip newlines from comment annotations
annotation_newlines = False

# Defines whether or not issues should be matched based upon their description.
# In legacy mode, we will attempt to match issues to bugs based upon the
# presence of the '(bw)' marker in the task description.
Expand Down
6 changes: 5 additions & 1 deletion bugwarrior/services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def __init__(self, main_config, main_section, target):
self.inline_links = self._get_config_or_default('inline_links', True, asbool);
self.annotation_links = self._get_config_or_default('annotation_links', not self.inline_links, asbool)
self.annotation_comments = self._get_config_or_default('annotation_comments', True, asbool)
self.annotation_newlines = self._get_config_or_default('annotation_newlines', False, asbool)
self.shorten = self._get_config_or_default('shorten', False, asbool)

self.default_priority = self.config.get('default_priority', 'M')
Expand Down Expand Up @@ -149,7 +150,10 @@ def build_annotations(self, annotations, url):
message = message.strip()
if not message or not author:
continue
message = message.replace('\n', '').replace('\r', '')

if not self.annotation_newlines:
message = message.replace('\n', '').replace('\r', '')

if self.anno_len:
message = '%s%s' % (
message[:self.anno_len],
Expand Down

0 comments on commit f69bbed

Please sign in to comment.