mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Import: Skip unchanged tasks
- Re-importing the same file will now lead to no task changes. Previously the "modified:" attribute got updated each time an already imported file was imported again.
This commit is contained in:
parent
9d6067e2fe
commit
2a56e41fa9
1 changed files with 19 additions and 6 deletions
|
@ -112,19 +112,32 @@ int CmdImport::import (std::vector <std::string>& lines)
|
|||
Task task (object);
|
||||
|
||||
// Check whether the imported task is new or a modified existing task.
|
||||
Task dummy;
|
||||
if (context.tdb2.get (task.get ("uuid"), dummy))
|
||||
Task before;
|
||||
if (context.tdb2.get (task.get ("uuid"), before))
|
||||
{
|
||||
context.tdb2.modify (task);
|
||||
std::cout << " mod ";
|
||||
// "modified:" is automatically set to the current time when a task is
|
||||
// changed. If the imported task has a modification timestamp we need
|
||||
// to ignore it in taskDiff() in order to check for meaningful
|
||||
// differences. Setting it to the previous value achieves just that.
|
||||
task.set ("modified", before.get ("modified"));
|
||||
if (taskDiff (before, task))
|
||||
{
|
||||
context.tdb2.modify (task);
|
||||
std::cout << " mod ";
|
||||
++count;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << " skip ";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
context.tdb2.add (task);
|
||||
std::cout << " add ";
|
||||
std::cout << " add ";
|
||||
++count;
|
||||
}
|
||||
|
||||
++count;
|
||||
std::cout << task.get ("uuid")
|
||||
<< " "
|
||||
<< task.get ("description")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue