سؤال

I have a post-commit hook. I would like to count the commit number every time I commit on my repo. I wrote :

#!/bin/sh
commit_number=$(git shortlog | grep -E '^[ ]+\w+' | wc -l)
echo "$commit_number"

Every new commit, terminal is printing 0 ... I don't why. If I launch this command after my commit inside my terminal I have the right count.

هل كانت مفيدة؟

المحلول

Try to do something like :

cd ..
commit_number=$(env -i git shortlog | grep -E '^[ ]+\w+' | wc -l)
echo "$commit_number"
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top