-
Notifications
You must be signed in to change notification settings - Fork 18
/
check_copyright.sh
executable file
·47 lines (43 loc) · 1.47 KB
/
check_copyright.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
#!/bin/bash
# Copyright (c) 2020 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the COPYING file.
# egrep that comes with our Linux distro doesn't like \d, so use [0-9]
notice='Copyright \(c\) 20[0-9][0-9] Arista Networks, Inc.'
apacheNotice='Use of this source code is governed by the Apache License 2.0'
apacheNoticeSource='that can be found in the COPYING file.'
confidential='Confidential and Proprietary'
generatedCodePaths='(^arista|^fmp).*'
copyrightCheck='.*(check_copyright.sh)'
files=`git diff-tree --no-commit-id --name-only --diff-filter=ACMR -r HEAD | \
egrep '\.(go|proto|py|sh)$' | \
grep -v '_pb2\.py$' | \
grep -v '_pb2_grpc\.py$' |\
grep -v 'docsrc/'`
status=0
for file in $files; do
if egrep -q "$confidential" $file ; then
# Need to omit the check_copyright script from this check as it will always fail
if [[ "$file" =~ $copyrightCheck ]] ; then
continue
fi
echo "$file: use of confidential material per copyright notice"
status=1
fi
if ! egrep -q "$notice" $file; then
echo "$file: missing or incorrect copyright notice for Arista"
status=1
fi
if [[ "$file" =~ $generatedCodePaths ]]; then
continue
fi
if ! egrep -q "$apacheNotice" $file ; then
echo "$file: missing or incorrect Apache Licence 2.0 notice"
status=1
fi
if ! egrep -q "$apacheNoticeSource" $file ; then
echo "$file: missing or incorrect Apache Licence 2.0 notice COPYING directive"
status=1
fi
done
exit $status