git-stats/scripts/init-git-post-commit
2015-02-11 19:25:44 +02:00

19 lines
527 B
Bash
Executable File

#!/bin/sh
git config --global init.templatedir '~/.git-templates'
mkdir -p ~/.git-templates/hooks
post_commit_path="~/.git-templates/hooks/post-commit"
cat << EOF > $post_commit_path
#!/bin/sh
# Copy last commit hash to clipboard on commit
commit_hash=`git rev-parse HEAD`
repo_url=`git config --get remote.origin.url`
commit_date=`git log -1 --format=%cd`
commit_data="\"{ \"date\": \"$commit_date\", \"url\": \"$repo_url\", \"hash\": \"$commit_hash\" }\""
git-stats --record "$commit_data"
EOF
chmod +x $post_commit_path