TW-1705: Directories in .task/hooks should not be reported as invalid hooks

- Thanks to Tomas Babej.
This commit is contained in:
Paul Beckingham 2016-01-11 22:30:35 -05:00
parent 19f57ffead
commit 60667dbcaa
3 changed files with 49 additions and 39 deletions

View file

@ -22,6 +22,8 @@
- TW-1703 When on-modify hook is installed, some messages print UUIDs
instead of IDs (thanks to Robin Green).
- TW-1704 Use Task::identifier to reference the Task in the output
- TW-1705 Directories in .task/hooks should not be reported as invalid hooks
(thanks to Tomas Babej).
- TW-1720 CmdContext uses a mix of both throw and std::cout to convey
errors (thanks to Paul Beckingham).
- TW-1723 task info causes segfault (thanks to Roman Golovin).

View file

@ -71,6 +71,8 @@ void Hooks::initialize ()
for (auto& i : _scripts)
{
Path p (i);
if (! p.is_directory ())
{
std::string name = p.name ();
if (name.substr (0, 6) == "on-add" ||
name.substr (0, 9) == "on-modify" ||
@ -82,6 +84,7 @@ void Hooks::initialize ()
}
}
}
}
else if (_debug >= 1)
context.debug ("Hook directory not readable: " + d._data);

View file

@ -331,7 +331,8 @@ int CmdDiagnostics::execute (std::string& output)
for (auto& hook : hooks)
{
Path p (hook);
if (! p.is_directory ())
{
std::string name = p.name ();
if (p.executable () &&
@ -349,12 +350,15 @@ int CmdDiagnostics::execute (std::string& output)
<< "\n";
}
}
}
out << " Inactive: ";
count = 0;
for (auto& hook : hooks)
{
Path p (hook);
if (! p.is_directory ())
{
std::string name = p.name ();
if (! p.executable () ||
@ -377,6 +381,7 @@ int CmdDiagnostics::execute (std::string& output)
}
}
}
}
else
out << format (" ({1})\n", STRING_CMD_DIAG_NONE);