Created
November 30, 2013 14:30
-
-
Save flyser/7719769 to your computer and use it in GitHub Desktop.
An example save hook script for a Cournal server. Warning: If you use Cournal a lot, the directory will grow quickly. Additional measures are needed to prevent that.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
cd "$1" | |
shift | |
# Try to determine a hostname | |
[[ -z "${HOSTNAME}" ]] && HOSTNAME="$(hostname)" | |
[[ -z "${HOSTNAME}" ]] && HOSTNAME="localhost" | |
# Create a predictable git environment | |
export GIT_CONFIG_NOSYSTEM="yes" | |
export HOME="/dev/null" | |
export XDG_CONFIG_HOME="/dev/null" | |
export GIT_AUTHOR_NAME="Cournal Autocommit" | |
export GIT_AUTHOR_EMAIL="cournal@${HOSTNAME}" | |
export GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME" | |
export GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL" | |
# Initialize git repository | |
if [[ ! -e .git ]]; then | |
git init | |
[[ ! -e .gitignore ]] && echo "lock" > .gitignore | |
git add .gitignore | |
git add cnl-*.json || true | |
git commit -m "Initial commit" | |
fi | |
git add "$@" | |
git commit -m "autocommit" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment