diff --git a/scripts/contributor.txt b/scripts/contributor.txt new file mode 100644 index 0000000000..9c775139f5 --- /dev/null +++ b/scripts/contributor.txt @@ -0,0 +1,2 @@ +// Copyright 2019 Yunion +// diff --git a/scripts/copyright.txt b/scripts/copyright.txt index fa3183803b..5653e0cb5f 100644 --- a/scripts/copyright.txt +++ b/scripts/copyright.txt @@ -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. diff --git a/scripts/gencopyright.sh b/scripts/gencopyright.sh index af601cf777..a01beab2d0 100755 --- a/scripts/gencopyright.sh +++ b/scripts/gencopyright.sh @@ -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