mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
Move validation for tag set up
- The given set of tags must be a subset of the latest interval's tag set (this includes the empty case) - If not a subset, throw an error and show the first non-matching tag - This also prevents the stop command from doing any work on the database - Closes #280 Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
This commit is contained in:
parent
5b1c77b8aa
commit
96aaa71eb4
1 changed files with 12 additions and 0 deletions
|
@ -76,6 +76,18 @@ int CmdStop (
|
|||
throw std::string ("The end of a date range must be after the start.");
|
||||
}
|
||||
|
||||
std::set <std::string> diff = {};
|
||||
|
||||
if(! std::includes(latest.tags ().begin (), latest.tags ().end (),
|
||||
filter.tags ().begin (), filter.tags ().end ()))
|
||||
{
|
||||
std::set_difference(filter.tags ().begin (), filter.tags ().end (),
|
||||
latest.tags ().begin (), latest.tags ().end (),
|
||||
std::inserter(diff, diff.begin ()));
|
||||
|
||||
throw format ("The current interval does not have the '{1}' tag.", *diff.begin ());
|
||||
}
|
||||
|
||||
journal.startTransaction ();
|
||||
|
||||
Interval modified {latest};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue