约 202 字 预计阅读 1 分钟
1 更新copyright 脚本
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
| #!/bin/bash
RED='\E[1;31m'
GREEN='\E[1;32m'
NOCOLOR='\e[0m'
MODIFIED_FILES=$(git diff --name-only)
CURRENT_YEAR=$(date +%Y)
for FILE in $MODIFIED_FILES
do
copyright=$(head -n 9 $FILE | grep "Copyright"|sed "s/\*//g")
# echo $copyright
if [[ $copyright =~ ([[:digit:]]+),[[:space:]]?([[:digit:]]+),[[:space:]]?([[:digit:]]+)[[:space:]]Healer[[:space:]]Corporation.
|| $copyright =~ ([[:digit:]]+),[[:space:]]?([[:digit:]]+)[[:space:]]Healer[[:space:]]Corporation.
|| $copyright =~ ([[:digit:]]+)[[:space:]]Healer[[:space:]]Corporation. ]]; the
# echo ${BASH_REMATCH[-1]}
if [[ ${BASH_REMATCH[-1]} != ${CURRENT_YEAR} ]]; then
sed -i "s/[[:space:]]Healer Corporation./, $CURRENT_YEAR Healer Corporation./" $FILE
fi
else
FILES_NEED_MANUAL_UPDATE="$FILE $FILES_NEED_MANUAL_UPDATE"
fi
done
if [[ $FILES_NEED_MANUAL_UPDATE ]]; then
echo -e "${GREEN}Please manually update the copyright of the following files: ${NOCOLOR}"
for FILE in $FILES_NEED_MANUAL_UPDATE
do
echo -e "${RED}${FILE}${NOCOLOR}"
done
fi
|
2 Android Studio新建文件自动生成copyright方法
- Settings->Editor->Copyright->Copyright Profile 创建copyright文件。
- Settings->Editor->Copyright 设置copyright作用范围。
1
| Copyright "$today.year" Healer Corporation.
|