]> git.madduck.net Git - etc/taskwarrior.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Initial commit
authorTomas Babej <tomasbabej@gmail.com>
Mon, 19 Jan 2015 17:33:35 +0000 (18:33 +0100)
committerTomas Babej <tomasbabej@gmail.com>
Mon, 19 Jan 2015 17:33:35 +0000 (18:33 +0100)
on-add-shift-all-recurrence [new file with mode: 0755]

diff --git a/on-add-shift-all-recurrence b/on-add-shift-all-recurrence
new file mode 100755 (executable)
index 0000000..0a0f065
--- /dev/null
@@ -0,0 +1,29 @@
+#!/usr/bin/python
+
+import sys
+from tasklib.task import Task, TaskWarrior
+
+time_attributes = ('wait', 'until', 'scheduled')
+
+def is_new_local_recurrence_child_task(task):
+    # Do not affect tasks not spun by recurrence
+    if not task['parent']:
+        return False
+
+    # Newly created recurrence tasks actually have
+    # modified field copied from the parent, thus
+    # older than entry field (until their ID is generated)
+    if (task['modified'] - task['entry']).total_seconds() < 0:
+        return True
+
+task = Task.from_input()
+tw = TaskWarrior()
+
+if is_new_local_recurrence_child_task(task):
+    parent = tw.tasks.get(uuid=task['parent'])
+    parent_due_shift = task['due'] - parent['due']
+    for attr in time_attributes:
+        if parent[attr]:
+            task[attr] = parent[attr] + parent_due_shift
+
+print task.export_data()