From 6cd5bf12375abb348e4fab00d158a8215412f137 Mon Sep 17 00:00:00 2001 From: "Dustin J. Mitchell" Date: Sun, 28 May 2023 16:58:48 +0000 Subject: [PATCH] Update "modified" on modification --- src/TDB2.cpp | 3 +++ src/Task.cpp | 2 +- test/tw-3102.t | 13 +++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100755 test/tw-3102.t diff --git a/src/TDB2.cpp b/src/TDB2.cpp index 220cd15c3..90e9202ba 100644 --- a/src/TDB2.cpp +++ b/src/TDB2.cpp @@ -133,6 +133,9 @@ void TDB2::add (Task& task) // they have been unmodified for a long time. void TDB2::modify (Task& task) { + // All locally modified tasks are timestamped, implicitly overwriting any + // changes the user or hooks tried to apply to the "modified" attribute. + task.setAsNow ("modified"); task.validate (false); auto uuid = task.get ("uuid"); diff --git a/src/Task.cpp b/src/Task.cpp index 9f2b52298..c9728996e 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -1826,7 +1826,7 @@ void Task::validate (bool applyDefault /* = true */) if ((status == Task::pending) && (get ("end") != "")) remove ("end"); - // Provide an entry date unless user already specified one. + // Provide a modified date unless user already specified one. if (! has ("modified") || get ("modified") == "") setAsNow ("modified"); diff --git a/test/tw-3102.t b/test/tw-3102.t new file mode 100755 index 000000000..ae6943f89 --- /dev/null +++ b/test/tw-3102.t @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +. bash_tap_tw.sh + +task add modtest modified:yesterday +old_modified=`task _get 1.modified` +echo $old_modified + +task 1 start +new_modified=`task _get 1.modified` +echo $new_modified + +# `task start` should have updated modified +[[ $old_modified != $new_modified ]]