Giter Site home page Giter Site logo

Comments (5)

IonicaBizau avatar IonicaBizau commented on May 7, 2024

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 echo ">>> 1" went to top, but it was not removed. Can you describe your usecase?

from git-stats.

IonicaBizau avatar IonicaBizau commented on May 7, 2024

/cc @ashleyblackmore

from git-stats.

ashleyblackmore avatar ashleyblackmore commented on May 7, 2024

Sorry, I just got around to double-checking - I was wrong - I was looking in the wrong directory (.git-templates/hooks/, rather than .git/hooks/)

from git-stats.

ashleyblackmore avatar ashleyblackmore commented on May 7, 2024

@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!

from git-stats.

IonicaBizau avatar IonicaBizau commented on May 7, 2024

@ashleyblackmore Nice! 👍

from git-stats.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.