update gencopyright script to use // comments

This commit is contained in:
Qiu Jian
2019-03-29 13:34:25 +08:00
committed by Yousong Zhou
parent 8993b4acf9
commit cfd3ae405b
3 changed files with 26 additions and 19 deletions
+2
View File
@@ -0,0 +1,2 @@
// Copyright 2019 Yunion
//
+11 -16
View File
@@ -1,16 +1,11 @@
/*
Copyright 2019 Yunion
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
+13 -3
View File
@@ -7,14 +7,24 @@ ROOT_DIR=$(cd .. && pwd -P)
popd > /dev/null
COPYRIGHT_TXT=$ROOT_DIR/scripts/copyright.txt
CONTRIBUTOR_TXT=$ROOT_DIR/scripts/contributor.txt
LINECNT=$(wc -l $COPYRIGHT_TXT | awk '{print $1}')
FULLLINECNT=$((LINECNT+2))
function patch() {
if ! (head -n $LINECNT $1 | diff -q $COPYRIGHT_TXT - > /dev/null); then
echo "patch $1"
if ! (head -n $FULLLINECNT $1 | tail -n $LINECNT | diff -b -q $COPYRIGHT_TXT - > /dev/null); then
echo "patch copyright $1"
OUT=$(mktemp) || { echo "Failed to create temp file"; exit 1; }
cat $COPYRIGHT_TXT > $OUT
cat $CONTRIBUTOR_TXT > $OUT
cat $COPYRIGHT_TXT >> $OUT
echo "" >> $OUT
cat $1 >> $OUT
mv $OUT $1
elif ! (head -n 2 $1 | diff -b -q $CONTRIBUTOR_TXT - > /dev/null); then
echo "patch contributor $1"
OUT=$(mktemp) || { echo "Failed to create temp file"; exit 1; }
head -n 1 $CONTRIBUTOR_TXT > $OUT
cat $1 >> $OUT
mv $OUT $1
fi