-
-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The hook installation in the readme clobbers existing hooks #41
Comments
Couldn't reproduce it: ionicabizau@notebook:~$ cat .git-templates/hooks/post-commit
#!/bin/sh
echo ">>>"
### git-stats hook (begin) ###
# 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}"
### git-stats hook (end) ###
echo ">>> 1"
ionicabizau@notebook:~$ curl -s https://raw.githubusercontent.com/IonicaBizau/git-stats/master/scripts/init-git-post-commit | bash
Setting up git-stats hooks.
Successfully set up git-stats hook at /home/ionicabizau/.git-templates/hooks/post-commit.
ionicabizau@notebook:~$ cat .git-templates/hooks/post-commit
#!/bin/sh
echo ">>>"
echo ">>> 1"
### git-stats hook (begin) ###
# 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}"
### git-stats hook (end) ### It's true that |
/cc @ashleyblackmore |
Sorry, I just got around to double-checking - I was wrong - I was looking in the wrong directory ( |
@IonicaBizau on a related note, I like the script, so I've adapted a bit of it for my own hook and credited you in the hook comment header. However, I decided to use sed instead of perl because it is a bit cleaner. I'm on linux (and it is really only a hook for linux users), so maybe sed is a better approach than perl in my case. Anyway, an idea of what I mean: sed '/### git-stats hook (begin) ###/,/### git-stats hook (end) ###/d' $post_commit_path > $post_commit_path My hook is here if you want to look. Thanks for the great hook, by the way! |
@ashleyblackmore Nice! 👍 |
Running the command here clobbers any existing hooks:
curl -s https://raw.githubusercontent.com/IonicaBizau/git-stats/master/scripts/init-git-post-commit | bash
An improvement could be to make a note in the readme, or to modify the bash script to run append-only. Happy to make a PR for either.
The text was updated successfully, but these errors were encountered: