forked from runtimeverification/k
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadd_copyright
More file actions
executable file
·69 lines (68 loc) · 1.75 KB
/
add_copyright
File metadata and controls
executable file
·69 lines (68 loc) · 1.75 KB
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
67
68
69
#!/bin/bash
# Copyright (c) 2014-2018 K Team. All Rights Reserved.
# Usage: ./add_copyright <file>
# TODO(dwightguth): currently this script will add a duplicate xml declaration
# to files containing an xml declaration but no copyright, and will not
# add an xml declaration to files with a copyright but no xml declaration.
# you will have to correct for these two cases manually.
EXTENSION="${1##*.}"
YEAR=
BLAME="`git log --follow --format=%ci "$1" | awk '{print $1}'`"
if [ -n "`echo $BLAME | grep 2018`" ]
then
YEAR=2018-
fi
if [ -n "`echo $BLAME | grep 2017`" ]
then
YEAR=2017-
fi
if [ -n "`echo $BLAME | grep 2016`" ]
then
YEAR=2016-
fi
if [ -n "`echo $BLAME | grep 2015`" ]
then
YEAR=2015-
fi
if [ -n "`echo $BLAME | grep 2014`" ]
then
YEAR=2014-
fi
if [ -n "`echo $BLAME | grep 2013`" ]
then
YEAR=2013-
fi
if [ -n "`echo $BLAME | grep 2012`" ]
then
YEAR=2012-
fi
if [ -n "`echo $BLAME | grep 2011`" ]
then
YEAR=2011-
fi
if [ -n "`echo $BLAME | grep 2010`" ]
then
YEAR=2010-
fi
if [ -n "`cat "$1" | head -2 | grep "Copyright (c)"`" ]
then
# copyright already present, just fix year
sed -i '1,2s/Copyright (c) .* K Team/Copyright (c) '$YEAR'2016 K Team/' "$1"
exit
fi
if [ $EXTENSION = "xml" -o $EXTENSION = "xsd" ]
then
sed -i '1s/^/<?xml version="1.0" encoding="UTF-8"?>\n<!-- Copyright (c) '$YEAR'2019 K Team. All Rights Reserved. -->\n/' "$1"
fi
if [ $EXTENSION = "md" ]
then
sed -i '1s/^/<!-- Copyright (c) '$YEAR'2019 K Team. All Rights Reserved. -->\n/' "$1"
fi
if [ $EXTENSION = "k" -o $EXTENSION = "java" -o $EXTENSION = "jj" ]
then
sed -i '1s/^/\/\/ Copyright (c) '$YEAR'2019 K Team. All Rights Reserved.\n/' "$1"
fi
if [ $EXTENSION = "css" ]
then
sed -i '1s/^/\/\* Copyright (c) '$YEAR'2019 K Team. All Rights Reserved. \*\/\n/' "$1"
fi