From 4fd290d43f74e5742ef62709cfe1da66c588c4e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionic=C4=83=20Biz=C4=83u?= Date: Wed, 11 Feb 2015 19:33:45 +0200 Subject: [PATCH] Use variables and escape the eof content. --- scripts/init-git-post-commit | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/scripts/init-git-post-commit b/scripts/init-git-post-commit index e17a630..88a0875 100755 --- a/scripts/init-git-post-commit +++ b/scripts/init-git-post-commit @@ -1,18 +1,21 @@ #!/bin/sh -git config --global init.templatedir '~/.git-templates' -mkdir -p ~/.git-templates/hooks -post_commit_path="~/.git-templates/hooks/post-commit" +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 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" +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