File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -22,14 +22,13 @@ post_commit_path="${git_hooks_dir}/post-commit"
2222mkdir -p " $git_hooks_dir "
2323
2424hook=$( cat << EOF
25-
2625### git-stats hook (begin) ###
2726# Copy last commit hash to clipboard on commit
2827commit_hash=\$ (git rev-parse HEAD)
2928repo_url=\$ (git config --get remote.origin.url)
3029commit_date=\$ (git log -1 --format=%cd)
3130commit_data="\"{ \"date\": \"\$ commit_date\", \"url\": \"\$ repo_url\", \"hash\": \"\$ commit_hash\" }\""
32- git-stats --record "\$ commit_data"
31+ git-stats --record "\$ { commit_data} "
3332### git-stats hook (end) ###
3433EOF
3534) ;
@@ -40,6 +39,8 @@ if [ ! -f "$post_commit_path" ]; then
4039 && echo " Successfully set up git-stats hook at ${post_commit_path} ." \
4140 && exit 0
4241else
42+ # Remove any previous git-stats hook code blocks
43+ perl -i -0pe ' s/(([ \t]*# Copy last commit hash to clipboard on commit\s*(\n.*){5}\s*git-stats --record "\$commit_data"\s*)|([ \t]*### git-stats hook \(begin\) ###\s*(\n.*){7}\s*### git-stats hook \(end\) ###\s*))//g' " $post_commit_path "
4344 printf " \n%s\n" " $hook " >> " $post_commit_path " \
4445 && echo " Successfully set up git-stats hook at ${post_commit_path} ." \
4546 && exit 0
You can’t perform that action at this time.
0 commit comments