mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-28 13:37:20 +02:00
Dependencies
- Improved error message when entering "task 1 dep:2; task 1 dep:2". - Documented circularity checking. - Stubbed dependencyChainBroken (). - Stubbed dependencyNag (). - Improved existing unit tests, added more.
This commit is contained in:
parent
0e2c090dc5
commit
199114abcd
4 changed files with 53 additions and 15 deletions
|
@ -477,6 +477,7 @@ void Task::addDependency (int id)
|
|||
if (id == this->id)
|
||||
throw std::string ("A task cannot be dependent on itself.");
|
||||
|
||||
// Check for extant dependency.
|
||||
std::string uuid = context.tdb.uuid (id);
|
||||
if (uuid == "")
|
||||
{
|
||||
|
@ -485,15 +486,23 @@ void Task::addDependency (int id)
|
|||
throw s.str ();
|
||||
}
|
||||
|
||||
// Store the dependency.
|
||||
std::string depends = get ("depends");
|
||||
if (depends.length ())
|
||||
{
|
||||
if (depends.find (uuid) == std::string::npos)
|
||||
set ("depends", depends + "," + uuid);
|
||||
else
|
||||
{
|
||||
std::stringstream out;
|
||||
out << "Task " << this->id << " already depends on task " << id << ".";
|
||||
throw out.str ();
|
||||
}
|
||||
}
|
||||
else
|
||||
set ("depends", uuid);
|
||||
|
||||
// Prevent circular dependencies.
|
||||
if (dependencyIsCircular (*this))
|
||||
throw std::string ("Circular dependency detected and disallowed.");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue