Skip to content

Commit

Permalink
Strip links when doing legacy comparisons.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphbean committed Mar 5, 2014
1 parent bbf5e29 commit e29f5c6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion bugwarrior/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,18 @@ def hamdist(str1, str2):
def find_local_uuid(tw, keys, issue, legacy_matching=True):
if not issue['description']:
raise ValueError('Issue %s has no description.' % issue)

possibilities = set([])

if legacy_matching:
legacy_description = issue.get_default_description().rsplit('..', 1)[0]
results = tw.filter_tasks({
'description.startswith': issue.get_default_description()
'description.startswith': legacy_description,
})
possibilities = possibilities | set([
task['uuid'] for task in results
])

for service, key_list in six.iteritems(keys):
for key in key_list:
if key in issue:
Expand All @@ -122,15 +126,18 @@ def find_local_uuid(tw, keys, issue, legacy_matching=True):
possibilities = possibilities | set([
task['uuid'] for task in results
])

if len(possibilities) == 1:
return possibilities.pop()

if len(possibilities) > 1:
raise MultipleMatches(
"Issue %s matched multiple IDs: %s" % (
issue,
possibilities
)
)

raise NotFound(
"No issue was found matching %s" % issue
)
Expand Down

0 comments on commit e29f5c6

Please sign in to comment.