mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-01 14:35:29 +00:00
[#2470] fix formatting tools on premium or other repos
This commit is contained in:
@@ -27,6 +27,9 @@ print_usage() {
|
|||||||
Options:
|
Options:
|
||||||
[-d|--debug] enable debug mode, showing every executed command
|
[-d|--debug] enable debug mode, showing every executed command
|
||||||
[-h|--help] print usage (this text)
|
[-h|--help] print usage (this text)
|
||||||
|
[$directory|$file ...] one or multiple files to format; if directories
|
||||||
|
are passed instead, they are searched for all C++
|
||||||
|
files under it which are then formatted
|
||||||
' \
|
' \
|
||||||
"$(basename "${0}")"
|
"$(basename "${0}")"
|
||||||
}
|
}
|
||||||
@@ -38,7 +41,7 @@ while test ${#} -gt 0; do
|
|||||||
'-d'|'--debug') set -vx ;;
|
'-d'|'--debug') set -vx ;;
|
||||||
|
|
||||||
# [-h|--help] print usage (this text).
|
# [-h|--help] print usage (this text).
|
||||||
'-h'|'--help') print_usage ;;
|
'-h'|'--help') print_usage; exit 0 ;;
|
||||||
|
|
||||||
# Allow extra arguments, they should be directories or files to be formatted.
|
# Allow extra arguments, they should be directories or files to be formatted.
|
||||||
*) break ;;
|
*) break ;;
|
||||||
@@ -85,6 +88,13 @@ while test ${#} -gt 0; do
|
|||||||
# We specifically want word splitting for the parameters.
|
# We specifically want word splitting for the parameters.
|
||||||
clang-format --style=file -i $(printf '%s' "${parameters}") "${file}"
|
clang-format --style=file -i $(printf '%s' "${parameters}") "${file}"
|
||||||
elif test -d "${file}"; then
|
elif test -d "${file}"; then
|
||||||
|
# Keep CWD for later use.
|
||||||
|
pwd="${PWD}"
|
||||||
|
|
||||||
|
# First checkout target directory so that the following "git ls-files" call
|
||||||
|
# acts on the proper git repository.
|
||||||
|
cd "${file}"
|
||||||
|
|
||||||
# Get list of files to format.
|
# Get list of files to format.
|
||||||
cd "$(git rev-parse --show-toplevel)"
|
cd "$(git rev-parse --show-toplevel)"
|
||||||
files=$(git ls-files | xargs -n1 printf "${PWD}/%s\\n" | grep -F "${file}" \
|
files=$(git ls-files | xargs -n1 printf "${PWD}/%s\\n" | grep -F "${file}" \
|
||||||
@@ -95,8 +105,13 @@ while test ${#} -gt 0; do
|
|||||||
files=$(printf '%s\n' "${files}" | grep -Fv "${file}" | sed '/^$/d')
|
files=$(printf '%s\n' "${files}" | grep -Fv "${file}" | sed '/^$/d')
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Restore directory to what it initially was because ${files} contains
|
||||||
|
# relative paths.
|
||||||
|
cd "${pwd}"
|
||||||
|
|
||||||
# For all files...
|
# For all files...
|
||||||
for i in ${files}; do
|
for i in ${files}; do
|
||||||
|
# Run recursively to format file or iterate further through directories.
|
||||||
"${0}" "${i}"
|
"${0}" "${i}"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
@@ -27,6 +27,9 @@ print_usage() {
|
|||||||
Options:
|
Options:
|
||||||
[-d|--debug] enable debug mode, showing every executed command
|
[-d|--debug] enable debug mode, showing every executed command
|
||||||
[-h|--help] print usage (this text)
|
[-h|--help] print usage (this text)
|
||||||
|
[$directory|$file ...] one or multiple files to format; if directories
|
||||||
|
are passed instead, they are searched for all C++
|
||||||
|
files under it which are then formatted
|
||||||
' \
|
' \
|
||||||
"$(basename "${0}")"
|
"$(basename "${0}")"
|
||||||
}
|
}
|
||||||
@@ -38,7 +41,7 @@ while test ${#} -gt 0; do
|
|||||||
'-d'|'--debug') set -vx ;;
|
'-d'|'--debug') set -vx ;;
|
||||||
|
|
||||||
# [-h|--help] print usage (this text).
|
# [-h|--help] print usage (this text).
|
||||||
'-h'|'--help') print_usage ;;
|
'-h'|'--help') print_usage; exit 0 ;;
|
||||||
|
|
||||||
# Allow extra arguments, they should be directories or files to be formatted.
|
# Allow extra arguments, they should be directories or files to be formatted.
|
||||||
*) break ;;
|
*) break ;;
|
||||||
@@ -85,6 +88,13 @@ while test ${#} -gt 0; do
|
|||||||
# We specifically want word splitting for the parameters.
|
# We specifically want word splitting for the parameters.
|
||||||
uncrustify -c "${script_path}/../.uncrustify.cfg" --replace $(printf '%s' "${parameters}") "${file}"
|
uncrustify -c "${script_path}/../.uncrustify.cfg" --replace $(printf '%s' "${parameters}") "${file}"
|
||||||
elif test -d "${file}"; then
|
elif test -d "${file}"; then
|
||||||
|
# Keep CWD for later use.
|
||||||
|
pwd="${PWD}"
|
||||||
|
|
||||||
|
# First checkout target directory so that the following "git ls-files" call
|
||||||
|
# acts on the proper git repository.
|
||||||
|
cd "${file}"
|
||||||
|
|
||||||
# Get list of files to format.
|
# Get list of files to format.
|
||||||
cd "$(git rev-parse --show-toplevel)"
|
cd "$(git rev-parse --show-toplevel)"
|
||||||
files=$(git ls-files | xargs -n1 printf "${PWD}/%s\\n" | grep -F "${file}" \
|
files=$(git ls-files | xargs -n1 printf "${PWD}/%s\\n" | grep -F "${file}" \
|
||||||
@@ -95,8 +105,13 @@ while test ${#} -gt 0; do
|
|||||||
files=$(printf '%s\n' "${files}" | grep -Fv "${file}" | sed '/^$/d')
|
files=$(printf '%s\n' "${files}" | grep -Fv "${file}" | sed '/^$/d')
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Restore directory to what it initially was because ${files} contains
|
||||||
|
# relative paths.
|
||||||
|
cd "${pwd}"
|
||||||
|
|
||||||
# For all files...
|
# For all files...
|
||||||
for i in ${files}; do
|
for i in ${files}; do
|
||||||
|
# Run recursively to format file or iterate further through directories.
|
||||||
"${0}" "${i}"
|
"${0}" "${i}"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user