nexmon – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 #!/bin/sh
2 # Copyright 2013, Alexis La Goutte (See AUTHORS file)
3 #
4 # For git user: copy tools/pre-commit to .git/hooks/ folder and make it
5 # executable. To bypass it for a single commit, use the --no-verify argument.
6 #
7 # Alternatively, invoke it directly with the commit ID. Example for checking the
8 # last commit:
9 #
10 # tools/pre-commit HEAD~
11 #
12 # Relative paths are also supported. For instance, if you are in epan/, then you
13 # could invoke `../tools/pre-commit HEAD` to check for changes to staged files.
14 #
15 # From
16 # http://mark-story.com/posts/view/using-git-commit-hooks-to-prevent-stupid-mistakes
17 #
18  
19 # If the commit identifier is not given, use HEAD instead.
20 COMMIT_ID="${1:-HEAD}"
21  
22 UNAME=`uname -a`
23  
24 case "$UNAME" in
25 *\ Msys)
26 pyvar="pythonw.exe"
27 ;;
28 *)
29 pyvar="python"
30 ;;
31 esac
32  
33 PYBIN=${WS_GITHOOK_PYTHON:-$pyvar}
34  
35 # Path to hook script in the .git directory
36 hook_script=${GIT_DIR:-.git}/hooks/pre-commit
37  
38 # Always start in the root directory of the source tree, this allows for
39 # invocations via relative paths (such as ../tools/pre-commit):
40 cd "$(git rev-parse --show-toplevel)"
41  
42 # Check for newer (actually, different) versions of the pre-commit script
43 # (but only if invoked as hook, i.e. the commit ID is not given as argument).
44 if [ -z "$1" ] && [ -f "$hook_script" ]; then
45 if ! cmp -s "$hook_script" tools/pre-commit; then
46 echo "Pre-commit hook script is outdated, please update!"
47 fi
48 fi
49  
50 exit_status=0
51  
52 COMMIT_FILES=`git diff-index --cached --name-status ${COMMIT_ID} | grep -v "^D" | cut -f2 | grep "\.[ch]$"`
53  
54 # Path to filter script in the tools directory
55 filter_script=${PWD}/tools/pre-commit-ignore.py
56 filter_conf=${PWD}/tools/pre-commit-ignore.conf
57  
58 if [ ! -e "$filter_script" ]; then
59 echo "File '$filter_script' does not exist. Aborting."
60 exit 1
61 fi
62  
63 CHECK_FILES=`echo "$COMMIT_FILES" | "$PYBIN" "$filter_script" "$filter_conf"`
64 if [ $? -ne 0 ]; then
65 exit 1
66 fi
67  
68 # On windows python will output \r\n line endings - we don't want that.
69 #
70 # Do not use sed, as not all versions of sed support \r as meaning CR
71 # in a regexp - the only version that does so might be GNU sed; the
72 # GNU sed documentation says that only \n and \\ can be used in a
73 # portable script.
74 #
75 # The Single UNIX Specification says that tr supports \r; most if not
76 # all modern UN*Xes should support it.
77 CHECK_FILES=`echo "$CHECK_FILES" | tr -d '\r'`
78  
79 for FILE in $CHECK_FILES; do
80  
81 #Check if checkhf is good
82 ./tools/checkhf.pl $FILE || exit_status=1
83  
84 #Check if checkAPIs is good
85 ./tools/checkAPIs.pl -p $FILE || exit_status=1
86  
87 #Check if fix-encoding-args is good
88 ./tools/fix-encoding-args.pl $FILE || exit_status=1
89  
90 #Check if checkfiltername is good
91 ./tools/checkfiltername.pl $FILE || exit_status=1
92  
93 done
94  
95 # If there are whitespace errors, print the offending file names and fail. (from git pre-commit.sample)
96 git diff-index --check --cached ${COMMIT_ID} || exit_status=1
97  
98 exit $exit_status
99  
100 #
101 # Editor modelines
102 #
103 # Local Variables:
104 # c-basic-offset: 4
105 # tab-width: 8
106 # indent-tabs-mode: nil
107 # End:
108 #
109 # ex: set shiftwidth=4 tabstop=8 expandtab:
110 # :indentSize=4:tabSize=8:noTabs=true:
111 #