2015-02-10 09:19:51 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2015-02-11 18:33:45 +01:00
|
|
|
git_templates_dir="$HOME/.git-templates"
|
|
|
|
git_hooks_dir="$git_templates_dir/hooks"
|
|
|
|
post_commit_path="$git_hooks_dir/post-commit"
|
|
|
|
|
|
|
|
git config --global init.templatedir $git_templates_dir
|
|
|
|
mkdir -p $git_hooks_dir
|
2015-02-10 09:19:51 +01:00
|
|
|
|
2015-02-11 18:25:44 +01:00
|
|
|
cat << EOF > $post_commit_path
|
2015-02-10 09:19:51 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Copy last commit hash to clipboard on commit
|
2015-02-11 18:33:45 +01:00
|
|
|
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"
|
2015-02-10 09:19:51 +01:00
|
|
|
EOF
|
2015-02-11 18:25:44 +01:00
|
|
|
|
|
|
|
chmod +x $post_commit_path
|