mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Hooks
- It is now an error for a failing hook script to fail to also generate some feedback. - Updated NEWS file to mention stricter hook script controls.
This commit is contained in:
parent
acce2d5a68
commit
5a060802e7
3 changed files with 29 additions and 3 deletions
7
NEWS
7
NEWS
|
@ -2,10 +2,11 @@
|
||||||
New Features in taskwarrior 2.4.1
|
New Features in taskwarrior 2.4.1
|
||||||
|
|
||||||
- New German translation.
|
- New German translation.
|
||||||
|
- Hook scripts are now under much stricter control.
|
||||||
|
|
||||||
New commands in taskwarrior 2.4.1
|
New commands in taskwarrior 2.4.1
|
||||||
|
|
||||||
-
|
- None
|
||||||
|
|
||||||
New configuration options in taskwarrior 2.4.1
|
New configuration options in taskwarrior 2.4.1
|
||||||
|
|
||||||
|
@ -17,11 +18,11 @@ New configuration options in taskwarrior 2.4.1
|
||||||
|
|
||||||
Newly deprecated features in taskwarrior 2.4.1
|
Newly deprecated features in taskwarrior 2.4.1
|
||||||
|
|
||||||
-
|
- None
|
||||||
|
|
||||||
Removed features in 2.4.1
|
Removed features in 2.4.1
|
||||||
|
|
||||||
-
|
- None
|
||||||
|
|
||||||
Known Issues
|
Known Issues
|
||||||
|
|
||||||
|
|
|
@ -144,6 +144,8 @@ void Hooks::onLaunch ()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
assertFeedback (outputFeedback);
|
||||||
|
|
||||||
std::vector <std::string>::iterator message;
|
std::vector <std::string>::iterator message;
|
||||||
for (message = outputFeedback.begin (); message != outputFeedback.end (); ++message)
|
for (message = outputFeedback.begin (); message != outputFeedback.end (); ++message)
|
||||||
context.error (*message);
|
context.error (*message);
|
||||||
|
@ -209,6 +211,8 @@ void Hooks::onExit ()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
assertFeedback (outputFeedback);
|
||||||
|
|
||||||
std::vector <std::string>::iterator message;
|
std::vector <std::string>::iterator message;
|
||||||
for (message = outputFeedback.begin (); message != outputFeedback.end (); ++message)
|
for (message = outputFeedback.begin (); message != outputFeedback.end (); ++message)
|
||||||
context.error (*message);
|
context.error (*message);
|
||||||
|
@ -273,6 +277,8 @@ void Hooks::onAdd (Task& task)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
assertFeedback (outputFeedback);
|
||||||
|
|
||||||
std::vector <std::string>::iterator message;
|
std::vector <std::string>::iterator message;
|
||||||
for (message = outputFeedback.begin (); message != outputFeedback.end (); ++message)
|
for (message = outputFeedback.begin (); message != outputFeedback.end (); ++message)
|
||||||
context.error (*message);
|
context.error (*message);
|
||||||
|
@ -342,6 +348,8 @@ void Hooks::onModify (const Task& before, Task& after)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
assertFeedback (outputFeedback);
|
||||||
|
|
||||||
std::vector <std::string>::iterator message;
|
std::vector <std::string>::iterator message;
|
||||||
for (message = outputFeedback.begin (); message != outputFeedback.end (); ++message)
|
for (message = outputFeedback.begin (); message != outputFeedback.end (); ++message)
|
||||||
context.error (*message);
|
context.error (*message);
|
||||||
|
@ -493,6 +501,22 @@ void Hooks::assertSameTask (const std::vector <std::string>& input, const Task&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void Hooks::assertFeedback (const std::vector <std::string>& input) const
|
||||||
|
{
|
||||||
|
bool foundSomething = false;
|
||||||
|
std::vector <std::string>::const_iterator i;
|
||||||
|
for (i = input.begin (); i != input.end (); ++i)
|
||||||
|
if (nontrivial (*i))
|
||||||
|
foundSomething = true;
|
||||||
|
|
||||||
|
if (! foundSomething)
|
||||||
|
{
|
||||||
|
context.error ("Hook Error: Expected feedback from a failing hook script.");
|
||||||
|
throw 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int Hooks::callHookScript (
|
int Hooks::callHookScript (
|
||||||
const std::string& script,
|
const std::string& script,
|
||||||
|
|
|
@ -56,6 +56,7 @@ private:
|
||||||
void assertValidJSON (const std::vector <std::string>&) const;
|
void assertValidJSON (const std::vector <std::string>&) const;
|
||||||
void assertNTasks (const std::vector <std::string>&, int) const;
|
void assertNTasks (const std::vector <std::string>&, int) const;
|
||||||
void assertSameTask (const std::vector <std::string>&, const Task&) const;
|
void assertSameTask (const std::vector <std::string>&, const Task&) const;
|
||||||
|
void assertFeedback (const std::vector <std::string>&) const;
|
||||||
int callHookScript (const std::string&, const std::vector <std::string>&, std::vector <std::string>&);
|
int callHookScript (const std::string&, const std::vector <std::string>&, std::vector <std::string>&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue