[license] keep hacky way under UPDATE
All checks were successful
eden-license / license-header (pull_request) Successful in 33s
All checks were successful
eden-license / license-header (pull_request) Successful in 33s
Signed-off-by: Caio Oliveira <caiooliveirafarias0@gmail.com>
This commit is contained in:
parent
9458928d30
commit
51f58c695f
1 changed files with 25 additions and 12 deletions
|
@ -14,8 +14,9 @@ if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
|
||||||
echo "This script checks and optionally fixes license headers in source, CMake and shell script files."
|
echo "This script checks and optionally fixes license headers in source, CMake and shell script files."
|
||||||
echo
|
echo
|
||||||
echo "Environment Variables:"
|
echo "Environment Variables:"
|
||||||
echo " FIX=true Automatically add the correct license headers to offending files."
|
echo " FIX=true | Automatically add the correct license headers to offending files."
|
||||||
echo " COMMIT=true If FIX=true, commit the changes automatically."
|
echo " UPDATE=true | Automatically update current license headers of offending files."
|
||||||
|
echo " COMMIT=true | If FIX=true, commit the changes automatically."
|
||||||
echo
|
echo
|
||||||
echo "Usage Examples:"
|
echo "Usage Examples:"
|
||||||
echo " # Just check headers (will fail if headers are missing)"
|
echo " # Just check headers (will fail if headers are missing)"
|
||||||
|
@ -24,8 +25,18 @@ if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
|
||||||
echo " # Fix headers only"
|
echo " # Fix headers only"
|
||||||
echo " FIX=true .ci/license-header.sh"
|
echo " FIX=true .ci/license-header.sh"
|
||||||
echo
|
echo
|
||||||
|
echo " # Update headers only"
|
||||||
|
echo " # if COPYRIGHT_OWNER is '$COPYRIGHT_OWNER'"
|
||||||
|
echo " # or else will have 'FIX=true' behavior)"
|
||||||
|
echo " UPDATE=true .ci/license-header.sh"
|
||||||
|
echo
|
||||||
echo " # Fix headers and commit changes"
|
echo " # Fix headers and commit changes"
|
||||||
echo " FIX=true COMMIT=true .ci/license-header.sh"
|
echo " FIX=true COMMIT=true .ci/license-header.sh"
|
||||||
|
echo
|
||||||
|
echo " # Update headers and commit changes"
|
||||||
|
echo " # if COPYRIGHT_OWNER is '$COPYRIGHT_OWNER'"
|
||||||
|
echo " # or else will have 'FIX=true' behavior)"
|
||||||
|
echo " UPDATE=true COMMIT=true .ci/license-header.sh"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -126,7 +137,7 @@ cat << EOF
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
TMP_DIR=$(mktemp -d /tmp/license-header.XXXXXX) || exit 1
|
TMP_DIR=$(mktemp -d /tmp/license-header.XXXXXX) || exit 1
|
||||||
if [ "$FIX" = "true" ]; then
|
if [ "$FIX" = "true" ] || [ "$UPDATE" = "true" ]; then
|
||||||
echo
|
echo
|
||||||
echo "license-header.sh: FIX set to true, fixing headers..."
|
echo "license-header.sh: FIX set to true, fixing headers..."
|
||||||
|
|
||||||
|
@ -152,15 +163,17 @@ if [ "$FIX" = "true" ]; then
|
||||||
|
|
||||||
# this logic is bit hacky but sed don't work well with $VARIABLES
|
# this logic is bit hacky but sed don't work well with $VARIABLES
|
||||||
# it's this or complete remove this logic and keep only the old way
|
# it's this or complete remove this logic and keep only the old way
|
||||||
while IFS= read -r line || [ -n "$line" ]; do
|
if [ "$UPDATE" = "true" ]; then
|
||||||
if [ "$UPDATED" -eq 0 ] && echo "$line" | grep "$COPYRIGHT_OWNER" >/dev/null 2>&1; then
|
while IFS= read -r line || [ -n "$line" ]; do
|
||||||
echo_header "$COMMENT_TYPE" >> "$TMP"
|
if [ "$UPDATED" -eq 0 ] && echo "$line" | grep "$COPYRIGHT_OWNER" >/dev/null 2>&1; then
|
||||||
IFS= read -r _ || true
|
echo_header "$COMMENT_TYPE" >> "$TMP"
|
||||||
UPDATED=1
|
IFS= read -r _ || true
|
||||||
else
|
UPDATED=1
|
||||||
echo "$line" >> "$TMP"
|
else
|
||||||
fi
|
echo "$line" >> "$TMP"
|
||||||
done < "$file"
|
fi
|
||||||
|
done < "$file"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$UPDATED" -eq 0 ]; then
|
if [ "$UPDATED" -eq 0 ]; then
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue