You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pre-push.sample 1.3KB

7 lat temu
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/sh
  2. # An example hook script to verify what is about to be pushed. Called by "git
  3. # push" after it has checked the remote status, but before anything has been
  4. # pushed. If this script exits with a non-zero status nothing will be pushed.
  5. #
  6. # This hook is called with the following parameters:
  7. #
  8. # $1 -- Name of the remote to which the push is being done
  9. # $2 -- URL to which the push is being done
  10. #
  11. # If pushing without using a named remote those arguments will be equal.
  12. #
  13. # Information about the commits which are being pushed is supplied as lines to
  14. # the standard input in the form:
  15. #
  16. # <local ref> <local sha1> <remote ref> <remote sha1>
  17. #
  18. # This sample shows how to prevent push of commits where the log message starts
  19. # with "WIP" (work in progress).
  20. remote="$1"
  21. url="$2"
  22. z40=0000000000000000000000000000000000000000
  23. IFS=' '
  24. while read local_ref local_sha remote_ref remote_sha
  25. do
  26. if [ "$local_sha" = $z40 ]
  27. then
  28. # Handle delete
  29. :
  30. else
  31. if [ "$remote_sha" = $z40 ]
  32. then
  33. # New branch, examine all commits
  34. range="$local_sha"
  35. else
  36. # Update to existing branch, examine new commits
  37. range="$remote_sha..$local_sha"
  38. fi
  39. # Check for WIP commit
  40. commit=`git rev-list -n 1 --grep '^WIP' "$range"`
  41. if [ -n "$commit" ]
  42. then
  43. echo "Found WIP commit in $local_ref, not pushing"
  44. exit 1
  45. fi
  46. fi
  47. done
  48. exit 0