3 #=======================================================================
5 # File ID: e2469b62-dc83-11e0-9dfc-9f1b7346cb92
7 # Shortcut to task(1) or timew(1) and commit changes to Git
9 # Author: Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later.
11 #=======================================================================
16 if test "$1" = "--version"; then
17 echo $progname $VERSION
22 T_GREEN
=$
(tput setaf
2)
26 lockdir
=$HOME/.t-task.LOCK
27 taskdir
=$HOME/src
/git
/task
29 if test "$1" = "-h" -o "$1" = "--help"; then
32 Frontend to task(1) (Taskwarrior) or timew(1) (Timewarrior), depending
33 on what the script is called. If the file name of the script is "t",
34 call Taskwarrior, if it's "tw", call Timewarrior. Other names result in
37 Commits the result of every command to Git.
39 Usage: $progname [options] TASK_COMMAND
48 Check that the task repository is marked as active, that the t.active Git
49 config value is set to "true". If it's anything else, the script will abort
52 Print version information.
54 "$progname angre" assumes that $taskdir is version controlled by Git and
55 will throw away the newest commit. If the repository is modified in any
56 way, the operation aborts.
63 rmdir $lockdir ||
echo $progname: $lockdir: Cannot remove lockdir
>&2
67 cd $taskdir ||
{ echo $progname: $taskdir: Cannot chdir
>&2; exit 1; }
69 if test "$1" = "--is-active"; then
70 if test "$(git config --get t.active)" != "true"; then
72 echo "The task repository ($taskdir) is not marked as active," >&2
73 echo "set the Git config variable t.active to \"true\"." >&2
80 base
="$(basename "$0")"
81 if test "$base" = "t"; then
83 elif test "$base" = "tw"; then
86 echo $progname: $base: Unknown
script name
, must be
\"t
\" or
\"tw
\" >&2
90 t
--is-active ||
exit 1
93 echo $progname: $lockdir: Cannot create lockdir
>&2
96 trap "myexit 1" INT TERM
98 if [ ! -f $taskdir/.taskrc
-o ! -d $taskdir/.task
]; then
99 echo $progname: Missing files
in $taskdir/ >&2
103 if [ "$1" = "angre" ]; then
104 if [ ! -d .git
]; then
105 echo $progname: $taskdir/.git not found
>&2
108 if ! (git-wait-until-clean
-e); then
109 echo $progname: $taskdir has modifications
, aborting
>&2
112 echo -n "$T_BOLD$T_RED"
113 GIT_PAGER
=cat git log
-1 --format='Deleting rev: %h ("%s", %cd)'
115 git
reset --hard HEAD^
116 echo -n "$T_BOLD$T_GREEN"
117 GIT_PAGER
=cat git log
-1 --format='New rev: %h ("%s", %cd)'
124 oldcommit
=$
(git rev-parse HEAD
)
125 ciall
-d -y -- $cmd "$@" >/tmp
/t-output.txt
2>&1 ||
{
126 echo $progname: git commit error
>&2
131 ciall
-d -y -- Finish previous
command >/tmp
/t-output-2.txt
2>&1 ||
{
132 echo $progname: git commit
2 error
>&2
135 newcommit
=$
(git rev-parse HEAD
)
136 GIT_PAGER
=cat git log
--abbrev-commit --format=oneline
--decorate=short \
137 $oldcommit..
$newcommit