Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(fix): resolve diff exit, add options for debugging #5

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions scripts/file_license_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@

set -e

diffparms=${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 +23,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
Loading