forked from rabbitmq/rabbitmq-public-umbrella
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-copyright.sh
executable file
·61 lines (52 loc) · 3.17 KB
/
update-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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/sh
set -e
owner='VMware, Inc. or its affiliates.'
all_owners="(GoPivotal[^.]+\\.|Pivotal[^.]+\\.|VMware[^.]+\\. or its affiliates\\.)"
owner_and_link='<a href="https://tanzu.vmware.com/">VMware</a>, Inc. or its affiliates.'
all_owners_and_links="(<a[^>]*>GoPivotal</a>[^.]+\\.|<a[^>]*>Pivotal[^<]*</a>[^.]+\\.|<a[^>]*>VMware[^<]*</a>[^.]+\\. or its affiliates\\.)"
year=$(date +'%Y')
copyright_sign="(\\([Cc]\\)|©|©)"
git grep -Ilz -i "copyright" "$@" > files-with-copyright.txt
sed=sed
if type gsed >/dev/null 2>&1; then
sed=gsed
fi
xargs -0 \
$sed -E -i \
-e "s@([Cc]opyright) +$copyright_sign +(20[0-9][0-9]) *[—-] *(20[0-9][0-9]|Present) +$all_owners@\\1 \\2 \\3-$year $owner@" \
-e "s@([Cc]opyright) +$copyright_sign +(20[0-9][0-9]), *20[0-9][0-9] +$all_owners@\\1 \\2 \\3-$year $owner@" \
-e "s@([Cc]opyright) +$copyright_sign +(20[0-9][0-9]) +$all_owners@\\1 \\2 \\3-$year $owner@" \
-e "s@([Cc]opyright) +$copyright_sign +$year-$year +$all_owners@\\1 \\2 $year $owner@" \
-e "s@([Cc]opyright) +$copyright_sign +$all_owners@\\1 \\2 2007-$year $owner@" \
\
-e "s@([Cc]opyright) +$copyright_sign +(20[0-9][0-9]) *[—-] *(20[0-9][0-9]|Present) +$all_owners_and_links@\\1 \\2 \\3-$year $owner_and_link@" \
-e "s@([Cc]opyright) +$copyright_sign +(20[0-9][0-9]), *20[0-9][0-9] +$all_owners_and_links@\\1 \\2 \\3-$year $owner_and_link@" \
-e "s@([Cc]opyright) +$copyright_sign +(20[0-9][0-9]) +$all_owners_and_links@\\1 \\2 \\3-$year $owner_and_link@" \
-e "s@([Cc]opyright) +$copyright_sign +$year-$year +$all_owners_and_links@\\1 \\2 $year $owner_and_link@" \
-e "s@([Cc]opyright) +$copyright_sign +$all_owners_and_links@\\1 \\2 2007-$year $owner_and_link@" \
\
-e "s@([Cc]opyright)(:?) +(20[0-9][0-9]) *[—-] *(20[0-9][0-9]|Present) +$all_owners@\\1\\2 \\3-$year $owner@" \
-e "s@([Cc]opyright)(:?) +(20[0-9][0-9]), *20[0-9][0-9] +$all_owners@\\1\\2 \\3-$year $owner@" \
-e "s@([Cc]opyright)(:?) +(20[0-9][0-9]) +$all_owners@\\1\\2 \\3-$year $owner@" \
-e "s@([Cc]opyright)(:?) +$year-$year +$all_owners@\\1\\2 $year $owner@" \
-e "s@([Cc]opyright)(:?) +$all_owners@\\1\\2 2007-$year $owner@" \
\
-e "s@$copyright_sign +$all_owners[^,]*, +(20[0-9][0-9]) *[—-] *(20[0-9][0-9]|Present)(\\.|\$)@\\1 \\3-$year $owner@" \
-e "s@$copyright_sign +$all_owners[^,]*, +(20[0-9][0-9]), *20[0-9][0-9](\\.|\$)@\\1 \\3-$year $owner@" \
-e "s@$copyright_sign +$all_owners[^,]*, +(20[0-9][0-9])([^-]+|\$)(\\.|\$)@\\1 \\3-$year\\4 $owner@" \
-e "s@$copyright_sign +$all_owners[^,]*, +$year-$year(\\.|\$)@\\1 $year $owner@" \
-e "s@$copyright_sign +$all_owners[^,]*(\\.|\$)@\\1 $owner@" \
\
-e "s@$copyright_sign +(20[0-9][0-9]) *[—-] *(20[0-9][0-9]|Present) +$all_owners@\\1 \\2-$year $owner@" \
-e "s@$copyright_sign +(20[0-9][0-9]), *20[0-9][0-9] +$all_owners@\\1 \\2-$year $owner@" \
-e "s@$copyright_sign +(20[0-9][0-9]) +$all_owners@\\1 \\2-$year $owner@" \
-e "s@$copyright_sign +$year-$year +$all_owners@\\1 $year $owner@" \
-e "s@$copyright_sign +$all_owners@\\1 2007-$year $owner@" \
< files-with-copyright.txt
if test "$DO_COMMIT" = 'yes'; then
git diff --quiet || \
xargs -0 \
git commit -m "Update copyright (year $year)" \
< files-with-copyright.txt
fi
rm files-with-copyright.txt