Skip to content

Commit

Permalink
Merge pull request #76 from lmacken/feature/longer
Browse files Browse the repository at this point in the history
Make the annotation and description length configurable.
  • Loading branch information
ralphbean committed Jul 9, 2013
2 parents 72a8514 + 9f3c5c7 commit 8feb690
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions bugwarrior/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 10 additions & 4 deletions bugwarrior/services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ def __init__(self, config, target, shorten):
self.config = config
self.target = target
self.shorten = shorten

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
Expand All @@ -30,7 +37,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),
Expand All @@ -41,10 +48,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):
Expand Down

0 comments on commit 8feb690

Please sign in to comment.