Advertisement
Guest User

Untitled

a guest
Sep 26th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #
  4. # post-commit hook script to make actual master branch archive in every commit
  5. # save it as a .git/hooks/post-commit
  6. #
  7. # created date: 26.09.2016
  8. # last update date: 26.09.2016
  9. # author: @yugoslavskiy
  10.  
  11. last_hooked_commit=$( cat .git/hooks/last_hooked_commit )
  12. last_manual_commit=$( cat .git/hooks/last_manual_commit )
  13. preprevious_commit=$( git log -2 --format="%H" | tail -1 )
  14.  
  15. # if PREprevious commit is manual — we are on looped post-commit hook, break it.
  16. if [ "${preprevious_commit}" == "${last_manual_commit}" ]; then
  17. git rev-parse HEAD > .git/hooks/last_hooked_commit
  18. exit 0
  19. elif [ "${preprevious_commit}" == "${last_hooked_commit}" ]; then
  20. git rev-parse HEAD > .git/hooks/last_manual_commit
  21. git archive master --format=zip --output=master.zip
  22. git add master.zip
  23. git commit -a -m 'updated/added actual master branch archive'
  24. else
  25. echo "shit. i do not know wtf is going on" > .git/hooks/post_commit_errorlog
  26. exit 1
  27. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement