Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # post-commit hook script to make actual master branch archive in every commit
- # save it as a .git/hooks/post-commit
- #
- # created date: 26.09.2016
- # last update date: 26.09.2016
- # author: @yugoslavskiy
- last_hooked_commit=$( cat .git/hooks/last_hooked_commit )
- last_manual_commit=$( cat .git/hooks/last_manual_commit )
- preprevious_commit=$( git log -2 --format="%H" | tail -1 )
- # if PREprevious commit is manual — we are on looped post-commit hook, break it.
- if [ "${preprevious_commit}" == "${last_manual_commit}" ]; then
- git rev-parse HEAD > .git/hooks/last_hooked_commit
- exit 0
- elif [ "${preprevious_commit}" == "${last_hooked_commit}" ]; then
- git rev-parse HEAD > .git/hooks/last_manual_commit
- git archive master --format=zip --output=master.zip
- git add master.zip
- git commit -a -m 'updated/added actual master branch archive'
- else
- echo "shit. i do not know wtf is going on" > .git/hooks/post_commit_errorlog
- exit 1
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement