12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- #!/bin/bash
- echo "Running pre-push hook"
- z40=0000000000000000000000000000000000000000
- remote="$1"
- ref_is_upstream_branch() {
- if [ "$1" == "refs/heads/master" ] ||
- [[ "$1" == refs/heads/release-* ]] ||
- [[ "$1" == refs/heads/maint-* ]]
- then
- return 1
- fi
- }
- while read -r local_ref local_sha remote_ref remote_sha
- do
- if [ "$local_sha" = $z40 ]
- then
-
- :
- else
- if [ "$remote_sha" = $z40 ]
- then
-
- range="$local_sha"
- else
-
- range="$remote_sha..$local_sha"
- fi
- if (ref_is_upstream_branch "$local_ref" == 0 ||
- ref_is_upstream_branch "$remote_ref" == 0) &&
- [ "$local_ref" != "$remote_ref" ]
- then
- if [ "$remote" == "origin" ]
- then
- echo >&2 "Not pushing: $local_ref to $remote_ref"
- echo >&2 "If you really want to push this, use --no-verify."
- exit 1
- else
- continue
- fi
- fi
-
- commit=$(git rev-list -n 1 --grep '^fixup!' "$range")
- if [ -n "$commit" ]
- then
- echo >&2 "Found fixup! commit in $local_ref, not pushing"
- echo >&2 "If you really want to push this, use --no-verify."
- exit 1
- fi
-
- commit=$(git rev-list -n 1 --grep '^squash!' "$range")
- if [ -n "$commit" ]
- then
- echo >&2 "Found squash! commit in $local_ref, not pushing"
- echo >&2 "If you really want to push this, use --no-verify."
- exit 1
- fi
- fi
- done
- exit 0
|