Skip to content

Commit

Permalink
ci(fix): resolve diff exit, add options for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
leet4tari committed Sep 6, 2024
1 parent d20a660 commit 05cec2c
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions scripts/file_license_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 05cec2c

Please sign in to comment.