Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

on-modify hook ignores task start time #13

Open
xeruf opened this issue May 5, 2020 · 7 comments
Open

on-modify hook ignores task start time #13

xeruf opened this issue May 5, 2020 · 7 comments
Labels
bug Something isn't working

Comments

@xeruf
Copy link

xeruf commented May 5, 2020

When starting a task with something such as task start 1 21:00, taskwarrior correctly marks the task as started at that time in the past, but timewarrior assumes it to have been started just now.

@lauft lauft added the bug Something isn't working label May 6, 2020
@lauft
Copy link
Member

lauft commented May 6, 2020

Interaction between Taskwarrior and Timewarrior is managed by the on-modify.timewarrior hook. Currently the hook script does not extract the start time from the supplied JSON.

To better analyse your issue you could provide a minimal reproducing example JSON, like

# create test environment
export TASKRC=/tmp/taskwarrior/taskrc
export TASKDATA=/tmp/taskwarrior/task
mkdir -p ${TASKDATA}
rm -rf ${TASKDATA:?}/*
:> ${TASKRC}

mkdir -p ${TASKDATA}/hooks
cp path/to/on-modify.dump ${TASKDATA}/hooks # set path to dumper script here!

rm -rf ${TASKDATA:?}/*.data # clean previous runs
# enter the necessary commands to reproduce the issue here, e.g.
task start 1 21:00

# The dumped JSON data is now available at /tmp/on-modify.dump...

The dumper-script:

#!/bin/bash

# The on-modify event is triggered separately for each task modified.

# Input:
# - line of JSON for the original task
# - line of JSON for the modified task, the diff being the modification
read original_task
read modified_task

echo "${original_task}" > /tmp/on-modify.dump
echo "${modified_task}" >> /tmp/on-modify.dump

# Output:
# - JSON, modified or unmodified.
# - Optional feedback/error.
echo "${modified_task}"
echo 'on-modify'

# Status:
# - 0:     JSON accepted, non-JSON is feedback.
# - non-0: JSON ignored, non-JSON is error.
exit 0

@lauft lauft changed the title Ignores task start time on-modify hook ignores task start time May 6, 2020
@xeruf
Copy link
Author

xeruf commented May 6, 2020

oh, I just realised that the syntax above actually creates an annotation instead of marking the start time.
task 1 modify start:2020-05-06T09:00 seems to be the only working way, but that isn't recognized by the hook either.
I couldn't really find any docs on task-start, what it exactly does, which options it supports, whether you can specify a time. I guess I'm gonna ask in taskwarrior as well.

@xeruf
Copy link
Author

xeruf commented May 6, 2020

It also obviously ignores changes of the start time - the hook doesn't care at all if I change the start time of an active task.

@lauft
Copy link
Member

lauft commented May 6, 2020

As mentioned above: 😉

Currently the hook script does not extract the start time from the supplied JSON.

@xeruf
Copy link
Author

xeruf commented May 6, 2020

Yeah I know, just wanted to record that separately in case that changes implementation details :)

@xeruf
Copy link
Author

xeruf commented May 10, 2020

Got it fixed, will open a PR soon :)

@xeruf
Copy link
Author

xeruf commented May 14, 2020

Okay, there is still one issue: In Taskwarrior, multiple tasks can be started at the same time - thus a task that is not actually tracked in timewarrior can have its start time modified, which currently totally messes up things. I think we need to check for an exact match and otherwise create a new timetracking - this is tougher than I thought ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants