One of the scripts in my git repository is distributed to many users. When they run this script I would it to look into my repository and see if any change is made to this script and if so suggest the users to update the script from the repository. The users know nothing about git and wish to understand as little as possible in the system implementation.
I would like to automatically update a this script's md5sum every time I commit it, without the need to bother and do it manually. Here is the pre-commit hook I wrote
#!/bin/sh
echo -n "# " > test.txt.tmp
linesNumber=`wc -l test.txt | awk '{print $1}'`
tail -n $(($linesNumber - 1)) test.txt | md5sum | awk '{print $1}' >> test.txt.tmp
tail -n $(($linesNumber - 1)) test.txt >> test.txt.tmp
mv test.txt.tmp test.txt
#git push
#git commit --no-verify --message "update file md5sum"
The md5sum works fine, the problem is that after the commit my script is again shows as modified. I tried to commit my changes without running the pre-commit hook (--no-verify) but git says I can't commit because my branch is ahead of 'origin/master' by 1 commit, I tried to push my changes before committing the md5sum but it never finished the operation.
What is the right way to achieve this type of functionality?