mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-26 06:37:20 +02:00
Logic Bug
- Fixed logic bug in bulk and recurring task duplication.
This commit is contained in:
parent
4feb1e2121
commit
d11c1bfe51
1 changed files with 40 additions and 17 deletions
|
@ -25,11 +25,11 @@
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
#define L10N // Localization complete.
|
#define L10N // Localization complete.
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
#include <Permission.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <util.h>
|
#include <util.h>
|
||||||
#include <i18n.h>
|
#include <i18n.h>
|
||||||
|
@ -64,12 +64,17 @@ int CmdDuplicate::execute (std::string& output)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply the command line modifications to the completed task.
|
// Apply the command line modifications to the new task.
|
||||||
A3 modifications = context.a3.extract_modifications ();
|
A3 modifications = context.a3.extract_modifications ();
|
||||||
|
|
||||||
|
Permission permission;
|
||||||
|
if (filtered.size () > (size_t) context.config.getInteger ("bulk"))
|
||||||
|
permission.bigSequence ();
|
||||||
|
|
||||||
std::vector <Task>::iterator task;
|
std::vector <Task>::iterator task;
|
||||||
for (task = filtered.begin (); task != filtered.end (); ++task)
|
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||||
{
|
{
|
||||||
|
// Duplicate the specified task.
|
||||||
Task dup (*task);
|
Task dup (*task);
|
||||||
dup.set ("uuid", uuid ()); // Needs a new UUID.
|
dup.set ("uuid", uuid ()); // Needs a new UUID.
|
||||||
dup.setStatus (Task::pending); // Does not inherit status.
|
dup.setStatus (Task::pending); // Does not inherit status.
|
||||||
|
@ -78,7 +83,7 @@ int CmdDuplicate::execute (std::string& output)
|
||||||
dup.remove ("entry"); // Does not inherit entry date.
|
dup.remove ("entry"); // Does not inherit entry date.
|
||||||
|
|
||||||
// Recurring tasks are duplicated and downgraded to regular tasks.
|
// Recurring tasks are duplicated and downgraded to regular tasks.
|
||||||
if (task->getStatus () == Task::recurring)
|
if (dup.has ("parent"))
|
||||||
{
|
{
|
||||||
dup.remove ("parent");
|
dup.remove ("parent");
|
||||||
dup.remove ("recur");
|
dup.remove ("recur");
|
||||||
|
@ -91,26 +96,44 @@ int CmdDuplicate::execute (std::string& output)
|
||||||
}
|
}
|
||||||
|
|
||||||
modify_task_annotate (dup, modifications);
|
modify_task_annotate (dup, modifications);
|
||||||
context.tdb2.add (dup);
|
|
||||||
++count;
|
|
||||||
|
|
||||||
if (context.verbose ("affected") ||
|
if (permission.confirmed (dup,
|
||||||
context.config.getBoolean ("echo.command")) // Deprecated 2.0
|
format (STRING_CMD_DONE_QUESTION,
|
||||||
out << format (STRING_CMD_DUPLICATE_DONE,
|
task->id,
|
||||||
task->id,
|
task->get ("description"))))
|
||||||
task->get ("description"))
|
{
|
||||||
<< "\n";
|
context.tdb2.add (dup);
|
||||||
|
++count;
|
||||||
|
|
||||||
// TODO This should be a call in to feedback.cpp.
|
if (context.verbose ("affected") ||
|
||||||
if (context.verbose ("new-id"))
|
context.config.getBoolean ("echo.command")) // Deprecated 2.0
|
||||||
out << format (STRING_CMD_ADD_FEEDBACK, context.tdb2.next_id ()) + "\n";
|
out << format (STRING_CMD_DUPLICATE_DUP,
|
||||||
|
task->id,
|
||||||
|
task->get ("description"))
|
||||||
|
<< "\n";
|
||||||
|
|
||||||
context.footnote (onProjectChange (dup));
|
if (context.verbose ("new-id"))
|
||||||
|
out << format (STRING_CMD_ADD_FEEDBACK, context.tdb2.next_id ()) + "\n";
|
||||||
|
|
||||||
|
context.footnote (onProjectChange (*task, false));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
out << STRING_CMD_DUPLICATE_NOT << "\n";
|
||||||
|
rc = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Add count summary, like the 'done' command.
|
|
||||||
|
|
||||||
context.tdb2.commit ();
|
context.tdb2.commit ();
|
||||||
|
|
||||||
|
if (context.verbose ("affected") ||
|
||||||
|
context.config.getBoolean ("echo.command")) // Deprecated 2.0
|
||||||
|
out << format ((count == 1
|
||||||
|
? STRING_CMD_DUPLICATE_DUP_1
|
||||||
|
: STRING_CMD_DUPLICATE_DUP_N),
|
||||||
|
count)
|
||||||
|
<< "\n";
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue