Hans-Christoph Steiner | 0761ec3 | 2019-01-09 13:00:45 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # An hook script to verify what is about to be pushed. Called by "git |
| 4 | # push" after it has checked the remote status, but before anything has been |
| 5 | # pushed. If this script exits with a non-zero status nothing will be pushed. |
| 6 | # |
| 7 | # This hook is called with the following parameters: |
| 8 | # |
| 9 | # $1 -- Name of the remote to which the push is being done |
| 10 | # $2 -- URL to which the push is being done |
| 11 | # |
| 12 | # If pushing without using a named remote those arguments will be equal. |
| 13 | # |
| 14 | # Information about the commits which are being pushed is supplied as lines to |
| 15 | # the standard input in the form: |
| 16 | # |
| 17 | # <local ref> <local sha1> <remote ref> <remote sha1> |
| 18 | |
| 19 | remote="$1" |
| 20 | url="$2" |
| 21 | |
| 22 | z40=0000000000000000000000000000000000000000 |
| 23 | |
| 24 | IFS=' ' |
| 25 | while read local_ref local_sha remote_ref remote_sha |
| 26 | do |
| 27 | if [ ! "$local_sha" = $z40 ] # not deleting from remote |
| 28 | then |
| 29 | if [ "$remote_sha" = $z40 ] |
| 30 | then |
| 31 | # New branch, examine all commits |
| 32 | range="$local_sha" |
| 33 | else |
| 34 | # Update to existing branch, examine new commits |
| 35 | range="$remote_sha..$local_sha" |
| 36 | fi |
| 37 | |
| 38 | if echo $url | grep 'gitlab.com[/:]fdroid/fdroidclient'; then |
| 39 | # Check for DO NOT MERGE commit |
| 40 | commit=`git rev-list -n 1 --grep 'DO NOT MERGE' "$range"` |
| 41 | if [ -n "$commit" ] |
| 42 | then |
| 43 | echo "Found DO NOT MERGE commit in $local_ref, not pushing" |
| 44 | exit 1 |
| 45 | fi |
| 46 | |
| 47 | # Check for WIP commit |
| 48 | commit=`git rev-list -n 1 --grep '^WIP' "$range"` |
| 49 | if [ -n "$commit" ] |
| 50 | then |
| 51 | echo "Found WIP commit in $local_ref, not pushing" |
| 52 | exit 1 |
| 53 | fi |
| 54 | fi |
| 55 | |
| 56 | ./gradlew checkstyle lint || exit 1 |
| 57 | fi |
| 58 | done |
| 59 | |
| 60 | exit 0 |