Skip to content

Commit

Permalink
ci(fix): resolve diff exit, add options for debugging (#5)
Browse files Browse the repository at this point in the history
* ci(fix): resolve diff exit, add options for debugging
  • Loading branch information
leet4tari authored Sep 9, 2024
1 parent ee06ee3 commit ccd4090
Showing 1 changed file with 9 additions and 6 deletions.
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

0 comments on commit ccd4090

Please sign in to comment.