codec-utils: Avoid out-of-bounds error
[platform/upstream/gstreamer.git] / scripts / git-hooks / multi-pre-commit.hook
1 #!/bin/sh
2 # Git pre-commit hook that runs multiple hooks specified in $HOOKS.
3 # Make sure this script is executable. Bypass hooks with git commit --no-verify.
4
5 # This file is inspired by a set of unofficial pre-commit hooks available
6 # at github.
7 # Link:    https://github.com/githubbrowser/Pre-commit-hooks
8 # Contact: David Martin, david.martin.mailbox@googlemail.com
9
10
11 ###########################################################
12 # SETTINGS:
13 # pre-commit hooks to be executed. They should be in the same .git/hooks/ folder
14 # as this script. Hooks should return 0 if successful and nonzero to cancel the
15 # commit. They are executed in the order in which they are listed.
16 ###########################################################
17
18 HOOKS="scripts/git-hooks/pre-commit.hook scripts/git-hooks/pre-commit-python.hook"
19
20 # exit on error
21 set -e
22
23 if [ "$GST_DISABLE_PRE_COMMIT_HOOKS" = "1" ]
24 then
25   echo "Pre-commits hooks disabled by env GST_DISABLE_PRE_COMMIT_HOOKS."
26   exit 0
27 fi
28
29 echo $PWD
30
31 for hook in $HOOKS
32 do
33     echo "Running hook: $hook"
34     # run hook if it exists
35     # if it returns with nonzero exit with 1 and thus abort the commit
36     if [ -f "$PWD/$hook" ]; then
37         "$PWD/$hook"
38         if [ $? != 0 ]; then
39             exit 1
40         fi
41     else
42         echo "Error: file $hook not found."
43         echo "Aborting commit. Make sure the hook is at $PWD/$hook and executable."
44         echo "You can disable it by removing it from the list"
45         echo "You can skip all pre-commit hooks with --no-verify (not recommended)."
46         exit 1
47     fi
48 done
49