From e416d218fed3277c416a7a252ef01ab6c077c61e Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Tue, 5 Mar 2024 10:11:56 -0800 Subject: [PATCH] simplifying lint headers script (#4802) --- ci/lintHeaders.sh | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/ci/lintHeaders.sh b/ci/lintHeaders.sh index 0e3459a369..43261c3057 100755 --- a/ci/lintHeaders.sh +++ b/ci/lintHeaders.sh @@ -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 \ No newline at end of file