mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
feedback: Use task identifiers instead of IDs
During construction of a feedback string for a dependency change, a list of IDs of the dependencies was used. However, if the tasks being referred to are already deleted / completed, their respective IDs are all 0s. Use shortened UUIDs in such case.
This commit is contained in:
parent
6f819af367
commit
f3147a512c
3 changed files with 45 additions and 22 deletions
16
src/Task.cpp
16
src/Task.cpp
|
@ -1177,6 +1177,22 @@ void Task::getDependencies (std::vector <std::string>& all) const
|
|||
all.clear ();
|
||||
split (all, get ("depends"), ',');
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Task::getDependencies (std::vector <Task>& all) const
|
||||
{
|
||||
std::vector <std::string> deps;
|
||||
split (deps, get ("depends"), ',');
|
||||
|
||||
all.clear ();
|
||||
|
||||
for (auto& dep : deps)
|
||||
{
|
||||
Task task;
|
||||
context.tdb2.get (dep, task);
|
||||
all.push_back (task);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -142,6 +142,7 @@ public:
|
|||
void removeDependency (const std::string&);
|
||||
void getDependencies (std::vector <int>&) const;
|
||||
void getDependencies (std::vector <std::string>&) const;
|
||||
void getDependencies (std::vector <Task>&) const;
|
||||
|
||||
void getUDAOrphans (std::vector <std::string>&) const;
|
||||
|
||||
|
|
|
@ -44,6 +44,20 @@ extern Context context;
|
|||
|
||||
static void countTasks (const std::vector <Task>&, const std::string&, int&, int&);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Converts a vector of tasks to a human-readable string that represents the tasks.
|
||||
std::string taskIdentifiers (const std::vector <Task>& tasks)
|
||||
{
|
||||
std::vector <std::string> identifiers;
|
||||
for (auto task: tasks)
|
||||
identifiers.push_back (task.identifier (true));
|
||||
|
||||
std::string result;
|
||||
join (result, ", ", identifiers);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string taskDifferences (const Task& before, const Task& after)
|
||||
{
|
||||
|
@ -72,13 +86,11 @@ std::string taskDifferences (const Task& before, const Task& after)
|
|||
{
|
||||
if (name == "depends")
|
||||
{
|
||||
std::vector <int> deps_after;
|
||||
std::vector <Task> deps_after;
|
||||
after.getDependencies (deps_after);
|
||||
std::string to;
|
||||
join (to, ", ", deps_after);
|
||||
|
||||
out << " - "
|
||||
<< format (STRING_FEEDBACK_DEP_SET, to)
|
||||
<< format (STRING_FEEDBACK_DEP_SET, taskIdentifiers (deps_after))
|
||||
<< "\n";
|
||||
}
|
||||
else
|
||||
|
@ -100,15 +112,13 @@ std::string taskDifferences (const Task& before, const Task& after)
|
|||
{
|
||||
if (name == "depends")
|
||||
{
|
||||
std::vector <int> deps_before;
|
||||
std::vector <Task> deps_before;
|
||||
before.getDependencies (deps_before);
|
||||
std::string from;
|
||||
join (from, ", ", deps_before);
|
||||
std::string from = taskIdentifiers (deps_before);
|
||||
|
||||
std::vector <int> deps_after;
|
||||
std::vector <Task> deps_after;
|
||||
after.getDependencies (deps_after);
|
||||
std::string to;
|
||||
join (to, ", ", deps_after);
|
||||
std::string to = taskIdentifiers (deps_after);
|
||||
|
||||
out << " - "
|
||||
<< format (STRING_FEEDBACK_DEP_MOD, from, to)
|
||||
|
@ -161,10 +171,9 @@ std::string taskInfoDifferences (
|
|||
{
|
||||
if (name == "depends")
|
||||
{
|
||||
std::vector <int> deps_before;
|
||||
std::vector <Task> deps_before;
|
||||
before.getDependencies (deps_before);
|
||||
std::string from;
|
||||
join (from, ", ", deps_before);
|
||||
std::string from = taskIdentifiers (deps_before);
|
||||
|
||||
out << format (STRING_FEEDBACK_DEP_DEL, from)
|
||||
<< "\n";
|
||||
|
@ -191,10 +200,9 @@ std::string taskInfoDifferences (
|
|||
{
|
||||
if (name == "depends")
|
||||
{
|
||||
std::vector <int> deps_after;
|
||||
std::vector <Task> deps_after;
|
||||
after.getDependencies (deps_after);
|
||||
std::string to;
|
||||
join (to, ", ", deps_after);
|
||||
std::string to = taskIdentifiers (deps_after);
|
||||
|
||||
out << format (STRING_FEEDBACK_DEP_WAS_SET, to)
|
||||
<< "\n";
|
||||
|
@ -225,15 +233,13 @@ std::string taskInfoDifferences (
|
|||
{
|
||||
if (name == "depends")
|
||||
{
|
||||
std::vector <int> deps_before;
|
||||
std::vector <Task> deps_before;
|
||||
before.getDependencies (deps_before);
|
||||
std::string from;
|
||||
join (from, ", ", deps_before);
|
||||
std::string from = taskIdentifiers (deps_before);
|
||||
|
||||
std::vector <int> deps_after;
|
||||
std::vector <Task> deps_after;
|
||||
after.getDependencies (deps_after);
|
||||
std::string to;
|
||||
join (to, ", ", deps_after);
|
||||
std::string to = taskIdentifiers (deps_after);
|
||||
|
||||
out << format (STRING_FEEDBACK_DEP_WAS_MOD, from, to)
|
||||
<< "\n";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue