|
29 | 29 | import json |
30 | 30 | import subprocess |
31 | 31 | import sys |
| 32 | +import shlex |
32 | 33 |
|
33 | 34 | # Hook should extract all the following for use as Timewarrior tags: |
34 | 35 | # UUID |
@@ -88,19 +89,21 @@ def main(old, new): |
88 | 89 | subprocess.call(['timew', start_or_stop] + tags + [':yes']) |
89 | 90 |
|
90 | 91 | # Modifications to task other than start/stop |
91 | | - elif 'start' in new and 'start' in old: |
92 | | - old_tags = extract_tags_from(old) |
93 | | - new_tags = extract_tags_from(new) |
| 92 | + old_tags = extract_tags_from(old) |
| 93 | + new_tags = extract_tags_from(new) |
94 | 94 |
|
95 | | - if old_tags != new_tags: |
96 | | - subprocess.call(['timew', 'untag', '@1'] + old_tags + [':yes']) |
97 | | - subprocess.call(['timew', 'tag', '@1'] + new_tags + [':yes']) |
| 95 | + if old_tags != new_tags: |
| 96 | + ids = subprocess.check_output(['timew', 'get', 'dom.tracked.ids', old['description']], stderr=subprocess.STDOUT).decode() |
| 97 | + ids = shlex.split(ids) |
98 | 98 |
|
99 | | - old_annotation = extract_annotation_from(old) |
100 | | - new_annotation = extract_annotation_from(new) |
| 99 | + subprocess.call(['timew', 'untag'] + ids + old_tags + [':yes']) |
| 100 | + subprocess.call(['timew', 'tag'] + ids + new_tags + [':yes']) |
101 | 101 |
|
102 | | - if old_annotation != new_annotation: |
103 | | - subprocess.call(['timew', 'annotate', '@1', new_annotation]) |
| 102 | + old_annotation = extract_annotation_from(old) |
| 103 | + new_annotation = extract_annotation_from(new) |
| 104 | + |
| 105 | + if old_annotation != new_annotation: |
| 106 | + subprocess.call(['timew', 'annotate', '@1', new_annotation]) |
104 | 107 |
|
105 | 108 |
|
106 | 109 | if __name__ == "__main__": |
|
0 commit comments