Skip to content

Commit

Permalink
simplifying lint headers script (#4802)
Browse files Browse the repository at this point in the history
  • Loading branch information
patnir authored Mar 5, 2024
1 parent 737e6ae commit e416d21
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions ci/lintHeaders.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,19 @@
# an MPL license header.
# $ lintHeaders ./src *.rs

license1="/* This Source Code Form is subject to the terms of the Mozilla Public"
license2=" * License, v. 2.0. If a copy of the MPL was not distributed with this"
license3=" * file, You can obtain one at https://mozilla.org/MPL/2.0/. */"
license="/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */"

files=$(find $1 -type f -name '*.rs')
result=0

headerLineNumbers() {
grep -Fn -e "$license1" -e "$license2" -e "$license3" "$1" | cut -f1 -d:
}
files=$(find $1 -type f -name $2)

expectedHeaderLineNumbers='1
2
3'
result=0

for file in $files; do
if ! [ "$(headerLineNumbers $file)" = "$expectedHeaderLineNumbers" ]; then
echo "$file"
for file in ${files[@]}; do
if ! [ "$(head $file -n3)" = "$license" ]; then
echo "Incorrect header in $file"
result=1
fi
done

exit $result
exit $result

0 comments on commit e416d21

Please sign in to comment.