Advertisement
Guest User

Untitled

a guest
Jul 29th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # A Git pre-push hook to protect a given branch from being
  4. # accidentally pushed to.
  5.  
  6. # This defaults to protecting the master branch. You can choose a
  7. # different branch to protect by setting the GIT_PROTECT
  8. # environment variable.
  9.  
  10. branch="${GIT_PROTECT:-master}"
  11. protected=`git config --get branch.$branch.merge`
  12.  
  13. while read local_ref local_sha remote_ref remote_sha
  14. do
  15. if [[ "$protected" == "$remote_ref" ]] || [[ $remote_ref == *$branch ]]
  16. then
  17. exec < /dev/tty
  18. while true; do
  19. read -p "Do you wish to push to $branch [Yn]: " yn
  20. case $yn in
  21. [Yy]* ) exit 0;;
  22. * ) echo "Aborting push to $branch"; exit 1;;
  23. esac
  24. done
  25. fi
  26. done
  27.  
  28. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement