Skip to content

Commit

Permalink
Avoid false positive in tasks_differ.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphbean committed Mar 7, 2014
1 parent b83864c commit 3b5be9a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions bugwarrior/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,22 @@ def get_normalized_annotation(annotation):
def tasks_differ(left, right):
if set(left) - set(right):
return True

all_keys = set(left.keys()) | set(right.keys())
for k in all_keys:
# We want to allow the user to locally modify their priority,
# annotations, etc, without us setting those values back everytime we
# run... so, ignore these.
if k in ('annotations', 'urgency', 'priority', ):
continue

# If a taskwarrior task has 0 tags, the 'left' value is None.
# If a bugwarrior remote issue has 0 tags, the 'right' is []
# Here, we avoid declaring things are different by checking falsiness
if k in ('tags',):

This comment has been minimized.

Copy link
@kostajh

kostajh Mar 12, 2014

Contributor

@ralphbean and @coddingtonbear Do we need to restrict this check to just tags? I'm also seeing the issue with other fields, for example:

DEBUG:db:0af32e00-ffa7-480f-81ea-2302dc90eb35:acbody has changed from 'None' to ''.

This comment has been minimized.

Copy link
@coddingtonbear

coddingtonbear Mar 12, 2014

Collaborator

Hrm -- yeah -- this and other situations where the type that we save to taskwarrior may not be the same as the type returned from taskwarrior (we automatically serialize appropriate python types to strings for sending off to task) -- those are the situations I was referring to earlier re: perhaps normalizing the data when retrieving it from taskwarrior in taskw. Otherwise, we're going to have a variety of special cases here in tasks_differ.

I think for the moment, what I'm planning to do is write the normalization code into bugwarrior, but we can later consider moving it into taskw as a standard component.

This comment has been minimized.

Copy link
@ralphbean

ralphbean Mar 12, 2014

Author Collaborator

Hm, when we put it into taskw, it should be easy to add some failing tests first at the bottom here:

https://github.com/ralphbean/taskw/blob/develop/taskw/test/test_datas.py#L394-L406

.. and then build up the lib to match the tests.

if not left.get(k) and not right.get(k):
continue

if (
isinstance(left.get(k), (list, tuple))
and isinstance(right.get(k), (list, tuple))
Expand Down

0 comments on commit 3b5be9a

Please sign in to comment.