Debian Codegraph @

third_party/rust/cubeb-coreaudio/.githooks/pre-push

raw
1 #!/bin/bash -e
2
3 # An example 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 PUSH_COMMAND=$(ps -ocommand= -p $PPID)
23
24 IS_DESTRUCTIVE="\-\-delete|\-f"
25
26 PROTECTED_BRANCH="trailblazer"
27 CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
28
29 WILL_DELETE_PROTECTED_BRANCH=":$PROTECTED_BRANCH"
30
31 if [[ $PUSH_COMMAND =~ $IS_DESTRUCTIVE ]]; then
32 if [ $CURRENT_BRANCH = $PROTECTED_BRANCH ] || [[ $PUSH_COMMAND =~ $PROTECTED_BRANCH ]]; then
33 echo "'$PROTECTED_BRANCH' cannot be deleted!"
34 exit 1
35 fi
36 exit 0
37 fi
38
39 if [[ $PUSH_COMMAND =~ $WILL_DELETE_PROTECTED_BRANCH ]]; then
40 echo "'$PROTECTED_BRANCH' cannot be deleted!"
41 exit 1
42 fi
43
44 cargo fmt -- --check || (echo "Please run 'cargo fmt'"; false);
45
46 cargo clippy -- -D warnings || (echo "Please run 'cargo clippy'"; false);
47