Created
December 5, 2018 17:54
-
-
Save benjaminion/0cb6aeb8ab0cb855cfaabf69a9ffba0e to your computer and use it in GitHub Desktop.
Search for source files lacking the copyright boilerplate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright 2018 ConsenSys AG. | |
* | |
* 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. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Searches for .java files lacking the copyright boilerplate | |
# With no args, just lists the files | |
# With "-doit", prepends the boilerplate file | |
boilerplate=$(pwd)/bin/boilerplate.txt | |
all_files=$(find . -name '*.java' -print) | |
bad_files="" | |
for file in $all_files | |
do | |
foo=$(grep -L -G 'Copyright 20.. ConsenSys AG.' $file) | |
if [ $? -eq 1 ] | |
then | |
bad_files="$bad_files $foo" | |
fi | |
done | |
for file in $bad_files | |
do | |
echo $file | |
if [ "$1" = "-doit" ] | |
then | |
tmp=$(mktemp) | |
cat $boilerplate $file > $tmp | |
mv -f $tmp $file | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment