Skip to content

Commit 2017c9c

Browse files
committed
Add script for removing Apache header.
* Can be used to remove the license header added with add_apache_header.sh
1 parent c89685a commit 2017c9c

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

scripts/apache_python.txt

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright (c) 2016-present, Facebook, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
##############################################################################
15+

scripts/remove_apache_header.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
if [[ "$1" == *.py ]]; then
2+
apache_header="apache_python.txt"
3+
else
4+
apache_header="apache_header.txt"
5+
fi
6+
apache_lines=$(wc -l < "${apache_header}")
7+
apache_md5=$(cat "${apache_header}" | md5)
8+
header_md5=$(head -n ${apache_lines} $1 | md5)
9+
if [ "${header_md5}" == "${apache_md5}" ]; then
10+
keep_lines=$(($(wc -l < $1) - ${apache_lines}))
11+
tail -n ${keep_lines} $1 > _remove_apache_header.txt
12+
mv _remove_apache_header.txt $1
13+
fi

scripts/temp.sh

100644100755
+7-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
find ../caffe2 -name "*.h" -exec ./add_apache_header.sh {} \;
2-
find ../caffe2 -name "*.cc" -exec ./add_apache_header.sh {} \;
3-
find ../caffe2 -name "*.cpp" -exec ./add_apache_header.sh {} \;
4-
find ../caffe2 -name "*.cu" -exec ./add_apache_header.sh {} \;
5-
find ../caffe2 -name "*.mm" -exec ./add_apache_header.sh {} \;
6-
find ../caffe2 -name "*.m" -exec ./add_apache_header.sh {} \;
1+
find ../caffe2 -name "*.py" -exec ./remove_apache_header.sh {} \;
2+
find ../caffe2 -name "*.h" -exec ./remove_apache_header.sh {} \;
3+
find ../caffe2 -name "*.cc" -exec ./remove_apache_header.sh {} \;
4+
find ../caffe2 -name "*.cpp" -exec ./remove_apache_header.sh {} \;
5+
find ../caffe2 -name "*.cu" -exec ./remove_apache_header.sh {} \;
6+
find ../caffe2 -name "*.mm" -exec ./remove_apache_header.sh {} \;
7+
find ../caffe2 -name "*.m" -exec ./remove_apache_header.sh {} \;

0 commit comments

Comments
 (0)