From 05cec2ce63eda4f5e5c0ec13808b19bb4ca35345 Mon Sep 17 00:00:00 2001 From: "C.Lee Taylor" Date: Fri, 6 Sep 2024 18:19:36 +0200 Subject: [PATCH] ci(fix): resolve diff exit, add options for debugging --- scripts/file_license_check.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/file_license_check.sh b/scripts/file_license_check.sh index 8985052..49169af 100755 --- a/scripts/file_license_check.sh +++ b/scripts/file_license_check.sh @@ -5,13 +5,16 @@ set -e +diffparms="-u --suppress-blank-empty --strip-trailing-cr --color=never" + +rgTemp=${rgTemp:-$(mktemp)} + # rg -i "Copyright.*The Tari Project" --files-without-match \ # -g '!*.{Dockerfile,asc,bat,config,config.js,css,csv,drawio,env,gitkeep,hbs,html,ini,iss,json,lock,md,min.js,ps1,py,rc,scss,sh,sql,svg,toml,txt,yml,vue}' . \ # | sort > /tmp/rgtemp # Exclude files without extensions as well as those with extensions that are not in the list # -rgTemp=$(mktemp) rg -i "Copyright.*The Tari Project" --files-without-match \ -g '!*.{Dockerfile,asc,bat,config,config.js,css,csv,drawio,env,gitkeep,hbs,html,ini,iss,json,lock,md,min.js,ps1,py,rc,scss,sh,sql,svg,toml,txt,yml,vue}' . \ | while IFS= read -r file; do @@ -21,20 +24,21 @@ rg -i "Copyright.*The Tari Project" --files-without-match \ done | sort > ${rgTemp} # Sort the .license.ignore file as sorting seems to behave differently on different platforms -licenseIgnoreTemp=$(mktemp) +licenseIgnoreTemp=${licenseIgnoreTemp:-$(mktemp)} cat .license.ignore | sort > ${licenseIgnoreTemp} -DIFFS=$(diff -u --strip-trailing-cr ${licenseIgnoreTemp} ${rgTemp}) +DIFFS=$( diff ${diffparms} ${licenseIgnoreTemp} ${rgTemp} || true ) # clean up rm -vf ${rgTemp} rm -vf ${licenseIgnoreTemp} -if [ -n "$DIFFS" ]; then - echo "New files detected that either need copyright/license identifiers added, or they need to be added to .license.ignore" +if [ -n "${DIFFS}" ]; then + echo "New files detected that either need copyright/license identifiers added, " + echo "or they need to be added to .license.ignore" echo "NB: The ignore file must be sorted alphabetically!" echo "Diff:" - echo "$DIFFS" + echo "${DIFFS}" exit 1 fi