From 5dc896661a9a4f8f8703ab71eaac3b882b8c43ef Mon Sep 17 00:00:00 2001 From: Luke Macken Date: Thu, 4 Jul 2013 16:51:51 -0400 Subject: [PATCH 1/2] Make the annotation and description length configurable. --- bugwarrior/README.rst | 4 ++++ bugwarrior/services/__init__.py | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bugwarrior/README.rst b/bugwarrior/README.rst index bd646ddd1..05d63f9a3 100644 --- a/bugwarrior/README.rst +++ b/bugwarrior/README.rst @@ -57,6 +57,10 @@ Create a ``~/.bugwarriorrc`` file with the following contents. # https://github.com/ralphbean/bugwarrior/issues #multiprocessing = False + # Configure the default description or annotation length. + #annotation_length = 45 + #description_length = 35 + # This section is for configuring notifications when bugwarrior-pull runs, # and when issues are created, updated, or deleted by bugwarrior-pull. # Three backend are currently suported: diff --git a/bugwarrior/services/__init__.py b/bugwarrior/services/__init__.py index 795f4340e..7bc0ba9f7 100644 --- a/bugwarrior/services/__init__.py +++ b/bugwarrior/services/__init__.py @@ -16,6 +16,8 @@ def __init__(self, config, target, shorten): self.config = config self.target = target self.shorten = shorten + self.desc_len = self.config.getint('general', 'description_length') + self.anno_len = self.config.getint('general', 'annotation_length') log.name(target).info("Working on [{0}]", self.target) @@ -30,7 +32,7 @@ def validate_config(cls, config, target): def format_annotation(self, created, user, body): if not body: body = '' - body = body.replace('\n', '').replace('\r', '')[:45] + body = body.replace('\n', '').replace('\r', '')[:self.anno_len] return ( "annotation_%i" % time.mktime(created.timetuple()), "@%s - %s..." % (user, body), @@ -41,10 +43,9 @@ def description(self, title, url, number, cls="issue"): 'issue': 'Is', 'pull_request': 'PR', } - # TODO -- get the '35' here from the config. return "%s%s#%s - %s .. %s" % ( MARKUP, cls_markup[cls], str(number), - title[:35], self.shorten(url) + title[:self.desc_len], self.shorten(url) ) def include(self, issue): From 9f3c5c7dde67af2301ff9eb0065bca4f8eacfb5e Mon Sep 17 00:00:00 2001 From: Luke Macken Date: Tue, 9 Jul 2013 13:41:45 -0400 Subject: [PATCH 2/2] Set default description and annotation lengths --- bugwarrior/services/__init__.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bugwarrior/services/__init__.py b/bugwarrior/services/__init__.py index 7bc0ba9f7..348eead60 100644 --- a/bugwarrior/services/__init__.py +++ b/bugwarrior/services/__init__.py @@ -16,9 +16,14 @@ def __init__(self, config, target, shorten): self.config = config self.target = target self.shorten = shorten - self.desc_len = self.config.getint('general', 'description_length') - self.anno_len = self.config.getint('general', 'annotation_length') - + if config.has_option('general', 'description_length'): + self.desc_len = self.config.getint('general', 'description_length') + else: + self.desc_len = 35 + if config.has_option('general', 'annotation_length'): + self.anno_len = self.config.getint('general', 'annotation_length') + else: + self.anno_len = 45 log.name(target).info("Working on [{0}]", self.target) @classmethod