-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcheck-for-license-headers.sh
executable file
·66 lines (63 loc) · 2.31 KB
/
check-for-license-headers.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh
# Copyright (C) 2012-2017 Jacob R. Lifshay
# This file is part of Voxels.
#
# Voxels is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Voxels is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Voxels; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
#
test_project_file()
{
local project_file="$1"
local header_string="`printf "/*\n * Copyright (C) 2012-2017 Jacob R. Lifshay"`"
local IFS="`printf "\na"`"
IFS="${IFS%a}"
local project_files="`cat $project_file | grep '<Unit filename="' | sed '{s/.*filename="\([^"]*\)".*/\1/}'`"
local files="`find src include ! -type d`"
local filename found_in_project new_project_files
for filename in $files; do
found_in_project=0
new_project_files=""
for project_filename in $project_files; do
if [ "$filename" = "$project_filename" ]; then
found_in_project=1
elif [ -z "$new_project_files" ]; then
new_project_files="$project_filename"
else
new_project_files="$new_project_files`echo; echo "$project_filename"`"
fi
done
project_files="$new_project_files"
if [ "$found_in_project" = 0 ]; then
echo "$filename: not in project"
fi
if [ "$filename" != "src/util/game_version.cpp" ]; then
if [ "`head -n 2 "$filename"`" != "$header_string" ]; then
echo "$filename:"
echo "`head -n 2 "$filename"`"
echo
echo vs.
echo
echo "$header_string"
echo
fi
fi
done
for project_filename in $project_files; do
echo "$project_filename: not found"
done
}
test_project_file voxels-0.7.cbp
test_project_file voxels-0.7-win.cbp