pre-push 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/sh
  2. # This hook script prevents the user from pushing to Savannah if any of the new
  3. # commits' OpenPGP signatures cannot be verified, or if a commit is signed
  4. # with an unauthorized key.
  5. # Called by "git push" after it has checked the remote status, but before
  6. # anything has been pushed. If this script exits with a non-zero status nothing
  7. # will be pushed.
  8. #
  9. # This hook is called with the following parameters:
  10. #
  11. # $1 -- Name of the remote to which the push is being done
  12. # $2 -- URL to which the push is being done
  13. #
  14. # If pushing without using a named remote those arguments will be equal.
  15. #
  16. # Information about the commits which are being pushed is supplied as lines to
  17. # the standard input in the form:
  18. #
  19. # <local ref> <local sha1> <remote ref> <remote sha1>
  20. # This is the "empty hash" used by Git when pushing a branch deletion.
  21. z40=0000000000000000000000000000000000000000
  22. while read local_ref local_hash remote_ref remote_hash
  23. do
  24. # When deleting a remote branch, no commits are pushed to the remote, and
  25. # thus there are no signatures to be verified.
  26. if [ "$local_hash" != $z40 ]
  27. then
  28. # Only use the hook when pushing to Savannah.
  29. case "$2" in
  30. *.gnu.org*)
  31. exec make authenticate check-channel-news
  32. exit 127
  33. ;;
  34. *)
  35. exit 0
  36. ;;
  37. esac
  38. fi
  39. done
  40. exit 0