From f8609fa53fa1d03971306cf671dd61b60d3500bb Mon Sep 17 00:00:00 2001 From: Tamas Petz Date: Mon, 15 Jan 2024 16:55:03 +0100 Subject: [PATCH] [NFC] Improve annotate-license.sh --- scripts/annotate-license.sh | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/scripts/annotate-license.sh b/scripts/annotate-license.sh index 36c660769..bdbee6276 100755 --- a/scripts/annotate-license.sh +++ b/scripts/annotate-license.sh @@ -30,19 +30,19 @@ LICENSE="Apache-2.0" # unrecognised formats annotate() { local file=$1 - out=$(reuse annotate -c "$COPYRIGHT" --license "$LICENSE" --merge-copyrights $file 2> >(cat)) + out=$(reuse annotate -c "${COPYRIGHT}" --license "${LICENSE}" --merge-copyrights "${file}" 2> >(cat)) if [ $? -eq 2 ]; then - echo -e "${RED}Failed to annotate $file, enforcing c-style comment${NC}" - reuse annotate -c "$COPYRIGHT" --license "$LICENSE" --merge-copyrights --style c $file + echo -e "${RED}Failed to annotate ${file}, enforcing c-style comment${NC}" + reuse annotate -c "${COPYRIGHT}" --license "${LICENSE}" --merge-copyrights --style c "${file}" else - echo $out + echo "${out}" fi } UNSTAGED=$(git diff --name-only) STAGED=$(git diff --cached --name-only) for file in $STAGED; do - annotate $file + annotate "${file}" done # Run license check on the entire codebase @@ -50,8 +50,7 @@ reuse lint # Notify user if there were changes made to staging files for file in $(git diff --name-only); do - if ! echo "$UNSTAGED" | grep -q "\b$file\b"; then - echo -e "${GREEN}Please stage $file for the commit${NC}" + if ! echo "${UNSTAGED}" | grep -q "\b${file}\b"; then + echo -e "${GREEN}Please stage ${file} for the commit${NC}" fi done - -- GitLab