Improve example hooks

The post-save and post-sync hooks now automatically detect whether the
data directory contains a .git/ directory and skip the commit creation
process if it does not.

The post-save hook and the new pre-load hook now also run
calcurse-caldav in the background if that script is available and the
data directory contains a caldav/ directory.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Lukas Fleischer
2016-02-08 08:01:06 +01:00
parent 616c3759a5
commit 4ab6e75aa9
3 changed files with 55 additions and 12 deletions

View File

@@ -1,12 +1,17 @@
#!/bin/sh
#
# Copy this file into ~/.calcurse/caldav/hooks/ and mark it executable to
# automatically commit changes after syncing using Git.
# This is an example hook. If the calcurse data directory contains a Git
# repository, it automatically makes a commit whenever synchronizing with a
# CalDAV server.
#
# In order to install this hook, copy this file to ~/.calcurse/caldav/hooks/.
cd "$HOME"/.calcurse/
git add apts conf keys todo
if ! git diff-index --quiet --cached HEAD; then
git commit -m "Automatic commit by the post-sync hook"
# If the data directory is under version control, create a Git commit.
if [ -d .git -a -x "$(which git)" ]; then
git add apts conf keys todo
if ! git diff-index --quiet --cached HEAD; then
git commit -m "Automatic commit by the post-sync hook"
fi
fi