Merge: doc: fixed some typos and other misc. corrections
[nit.git] / misc / jenkins / checkbinaryfiles.sh
1 #!/bin/bash
2 # This file is part of NIT ( http://www.nitlanguage.org ).
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 # Check binary files that might be wrongly committed.
17 #
18 # Usage: checkbinaryfiles.sh from to
19
20 from=${1:-origin/master}
21 to=${2:-HEAD}
22
23 err=0
24
25 cd `git rev-parse --show-toplevel`
26
27 err=0
28
29 echo "checkbinaryfiles $from (`git rev-parse "$from"`) .. $to (`git rev-parse "$to"`)"
30 git diff --name-only --diff-filter=d --no-renames $from..$to -z > checkbinaryfiles_files.out
31 if test \! -s checkbinaryfiles_files.out; then
32 echo "No committed files"
33 exit 0
34 fi
35 # Identify binary files with the presence of a null byte or a control char (except \n \r \t)
36 xargs -0 grep -Pal '[\x00-\x08\x0B-\x0C\x0E-\x1F]' < checkbinaryfiles_files.out > checkbinaryfiles_application.out 2> /dev/null
37 if test -s checkbinaryfiles_application.out; then
38 echo "These files type need a manual check:"
39 echo ""
40 cat checkbinaryfiles_application.out
41 echo ""
42 echo "Please double check that they are not wrongly committed files or that unexpected strange control characters are not included in them."
43 exit 1
44 else
45 echo "All committed files seem good"
46 exit 0
47 fi