mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-29 10:03:25 +02:00
Fix and test handling of backslashes in hooks (#3909)
* Update hooks to use `read -r` and `printf` This portably avoids any interpretation of backslash escapes by the shell. * Support running make_tc_task elsewhere * Add a test for backslashes in task descriptions
This commit is contained in:
parent
7fdcdebd19
commit
c639cc030d
27 changed files with 115 additions and 75 deletions
|
@ -8,7 +8,13 @@ import tempfile
|
|||
import unittest
|
||||
from .exceptions import CommandError
|
||||
from .hooks import Hooks
|
||||
from .utils import run_cmd_wait, run_cmd_wait_nofail, which, task_binary_location
|
||||
from .utils import (
|
||||
run_cmd_wait,
|
||||
run_cmd_wait_nofail,
|
||||
which,
|
||||
task_binary_location,
|
||||
CMAKE_BINARY_DIR,
|
||||
)
|
||||
from .compat import STRING_TYPE
|
||||
|
||||
|
||||
|
@ -300,5 +306,21 @@ class Task(object):
|
|||
# Use advanced time format
|
||||
self._command = [cmd, "-f", faketime] + self._command
|
||||
|
||||
def make_tc_task(self, **props):
|
||||
"""Create a task directly in TaskChampion, bypassing TaskWarrior
|
||||
entirely, and returning the UUID. The properties are not interpreted by
|
||||
the shell.
|
||||
"""
|
||||
# Generate the path to the `make_tc_task` binary, which is a dependency of the
|
||||
# test runner.
|
||||
make_tc_task = os.path.abspath(
|
||||
os.path.join(CMAKE_BINARY_DIR, "test", "make_tc_task")
|
||||
)
|
||||
cmd = [make_tc_task, self.datadir]
|
||||
for p, v in props.items():
|
||||
cmd.append(f"{p}={v}")
|
||||
_, out, _ = run_cmd_wait(cmd)
|
||||
return out.strip()
|
||||
|
||||
|
||||
# vim: ai sts=4 et sw=4
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue