diff --git a/bugwarrior/docs/common_configuration.rst b/bugwarrior/docs/common_configuration.rst index 1ba71286f..baf53daf8 100644 --- a/bugwarrior/docs/common_configuration.rst +++ b/bugwarrior/docs/common_configuration.rst @@ -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). diff --git a/bugwarrior/docs/configuration.rst b/bugwarrior/docs/configuration.rst index 03b0018c3..d664d9487 100644 --- a/bugwarrior/docs/configuration.rst +++ b/bugwarrior/docs/configuration.rst @@ -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. diff --git a/bugwarrior/services/__init__.py b/bugwarrior/services/__init__.py index 7a16cf27b..1624d8e8c 100644 --- a/bugwarrior/services/__init__.py +++ b/bugwarrior/services/__init__.py @@ -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') @@ -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],