[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
|
||||
echo "Environment Variables:"
|
||||
echo " FIX=true Automatically add the correct license headers to offending files."
|
||||
echo " COMMIT=true If FIX=true, commit the changes automatically."
|
||||
echo " FIX=true | Automatically add the correct license headers to offending files."
|
||||
echo " UPDATE=true | Automatically update current license headers of offending files."
|
||||
echo " COMMIT=true | If FIX=true, commit the changes automatically."
|
||||
echo
|
||||
echo "Usage Examples:"
|
||||
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=true .ci/license-header.sh"
|
||||
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=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
|
||||
fi
|
||||
|
||||
|
@ -126,7 +137,7 @@ cat << EOF
|
|||
EOF
|
||||
|
||||
TMP_DIR=$(mktemp -d /tmp/license-header.XXXXXX) || exit 1
|
||||
if [ "$FIX" = "true" ]; then
|
||||
if [ "$FIX" = "true" ] || [ "$UPDATE" = "true" ]; then
|
||||
echo
|
||||
echo "license-header.sh: FIX set to true, fixing headers..."
|
||||
|
||||
|
@ -152,6 +163,7 @@ if [ "$FIX" = "true" ]; then
|
|||
|
||||
# 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
|
||||
if [ "$UPDATE" = "true" ]; then
|
||||
while IFS= read -r line || [ -n "$line" ]; do
|
||||
if [ "$UPDATED" -eq 0 ] && echo "$line" | grep "$COPYRIGHT_OWNER" >/dev/null 2>&1; then
|
||||
echo_header "$COMMENT_TYPE" >> "$TMP"
|
||||
|
@ -161,6 +173,7 @@ if [ "$FIX" = "true" ]; then
|
|||
echo "$line" >> "$TMP"
|
||||
fi
|
||||
done < "$file"
|
||||
fi
|
||||
|
||||
if [ "$UPDATED" -eq 0 ]; then
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue