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 - TW-1703 When on-modify hook is installed, some messages print UUIDs
instead of IDs (thanks to Robin Green). instead of IDs (thanks to Robin Green).
- TW-1704 Use Task::identifier to reference the Task in the output - 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 - TW-1720 CmdContext uses a mix of both throw and std::cout to convey
errors (thanks to Paul Beckingham). errors (thanks to Paul Beckingham).
- TW-1723 task info causes segfault (thanks to Roman Golovin). - TW-1723 task info causes segfault (thanks to Roman Golovin).

View File

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

View File

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