mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
TW-1705: Directories in .task/hooks should not be reported as invalid hooks
- Thanks to Tomas Babej.
This commit is contained in:
parent
19f57ffead
commit
60667dbcaa
3 changed files with 49 additions and 39 deletions
|
@ -71,14 +71,17 @@ void Hooks::initialize ()
|
|||
for (auto& i : _scripts)
|
||||
{
|
||||
Path p (i);
|
||||
std::string name = p.name ();
|
||||
if (name.substr (0, 6) == "on-add" ||
|
||||
name.substr (0, 9) == "on-modify" ||
|
||||
name.substr (0, 9) == "on-launch" ||
|
||||
name.substr (0, 7) == "on-exit")
|
||||
context.debug ("Found hook script " + i);
|
||||
else
|
||||
context.debug ("Found misnamed hook script " + i);
|
||||
if (! p.is_directory ())
|
||||
{
|
||||
std::string name = p.name ();
|
||||
if (name.substr (0, 6) == "on-add" ||
|
||||
name.substr (0, 9) == "on-modify" ||
|
||||
name.substr (0, 9) == "on-launch" ||
|
||||
name.substr (0, 7) == "on-exit")
|
||||
context.debug ("Found hook script " + i);
|
||||
else
|
||||
context.debug ("Found misnamed hook script " + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -331,22 +331,24 @@ int CmdDiagnostics::execute (std::string& output)
|
|||
for (auto& hook : hooks)
|
||||
{
|
||||
Path p (hook);
|
||||
|
||||
std::string name = p.name ();
|
||||
|
||||
if (p.executable () &&
|
||||
(name.substr (0, 6) == "on-add" ||
|
||||
name.substr (0, 9) == "on-modify" ||
|
||||
name.substr (0, 9) == "on-launch" ||
|
||||
name.substr (0, 7) == "on-exit"))
|
||||
if (! p.is_directory ())
|
||||
{
|
||||
out << (count++ ? " " : "");
|
||||
std::string name = p.name ();
|
||||
|
||||
out.width (longest);
|
||||
out << std::left << name
|
||||
<< format (" ({1})", STRING_CMD_DIAG_HOOK_EXEC)
|
||||
<< (p.is_link () ? format (" ({1})", STRING_CMD_DIAG_HOOK_SYMLINK) : "")
|
||||
<< "\n";
|
||||
if (p.executable () &&
|
||||
(name.substr (0, 6) == "on-add" ||
|
||||
name.substr (0, 9) == "on-modify" ||
|
||||
name.substr (0, 9) == "on-launch" ||
|
||||
name.substr (0, 7) == "on-exit"))
|
||||
{
|
||||
out << (count++ ? " " : "");
|
||||
|
||||
out.width (longest);
|
||||
out << std::left << name
|
||||
<< format (" ({1})", STRING_CMD_DIAG_HOOK_EXEC)
|
||||
<< (p.is_link () ? format (" ({1})", STRING_CMD_DIAG_HOOK_SYMLINK) : "")
|
||||
<< "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -355,25 +357,28 @@ int CmdDiagnostics::execute (std::string& output)
|
|||
for (auto& hook : hooks)
|
||||
{
|
||||
Path p (hook);
|
||||
std::string name = p.name ();
|
||||
|
||||
if (! p.executable () ||
|
||||
(name.substr (0, 6) != "on-add" &&
|
||||
name.substr (0, 9) != "on-modify" &&
|
||||
name.substr (0, 9) != "on-launch" &&
|
||||
name.substr (0, 7) != "on-exit"))
|
||||
if (! p.is_directory ())
|
||||
{
|
||||
out << (count++ ? " " : "");
|
||||
std::string name = p.name ();
|
||||
|
||||
out.width (longest);
|
||||
out << std::left << name
|
||||
<< (p.executable () ? format (" ({1})", STRING_CMD_DIAG_HOOK_EXEC) : format (" ({1})", STRING_CMD_DIAG_HOOK_NO_EXEC))
|
||||
<< (p.is_link () ? format (" ({1})", STRING_CMD_DIAG_HOOK_SYMLINK) : "")
|
||||
<< ((name.substr (0, 6) == "on-add" ||
|
||||
name.substr (0, 9) == "on-modify" ||
|
||||
name.substr (0, 9) == "on-launch" ||
|
||||
name.substr (0, 7) == "on-exit") ? "" : format (" ({1})", STRING_CMD_DIAG_HOOK_NAME))
|
||||
<< "\n";
|
||||
if (! p.executable () ||
|
||||
(name.substr (0, 6) != "on-add" &&
|
||||
name.substr (0, 9) != "on-modify" &&
|
||||
name.substr (0, 9) != "on-launch" &&
|
||||
name.substr (0, 7) != "on-exit"))
|
||||
{
|
||||
out << (count++ ? " " : "");
|
||||
|
||||
out.width (longest);
|
||||
out << std::left << name
|
||||
<< (p.executable () ? format (" ({1})", STRING_CMD_DIAG_HOOK_EXEC) : format (" ({1})", STRING_CMD_DIAG_HOOK_NO_EXEC))
|
||||
<< (p.is_link () ? format (" ({1})", STRING_CMD_DIAG_HOOK_SYMLINK) : "")
|
||||
<< ((name.substr (0, 6) == "on-add" ||
|
||||
name.substr (0, 9) == "on-modify" ||
|
||||
name.substr (0, 9) == "on-launch" ||
|
||||
name.substr (0, 7) == "on-exit") ? "" : format (" ({1})", STRING_CMD_DIAG_HOOK_NAME))
|
||||
<< "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue