mirror of
https://github.com/taiki-e/install-action.git
synced 2025-12-27 01:54:13 -05:00
tidy: Update tools/tidy.sh and add SPDX-License-Identifier
This commit is contained in:
@@ -1 +1 @@
|
||||
git ls-files '*.sh' # TODO: check more files
|
||||
git ls-files
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
|
||||
use anyhow::{bail, Context as _, Result};
|
||||
use fs_err as fs;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -250,19 +250,22 @@ if [[ -f tools/.tidy-check-license-headers ]]; then
|
||||
info "checking license headers (experimental)"
|
||||
failed_files=''
|
||||
for p in $(eval $(<tools/.tidy-check-license-headers)); do
|
||||
# TODO: More file types?
|
||||
case "$(basename "${p}")" in
|
||||
*.sh) prefix=("# ") ;;
|
||||
*.rs | *.c | *.h | *.cpp | *.hpp | *.s | *.S) prefix=("// " "/* ") ;;
|
||||
*.stderr | *.expanded.rs) continue ;; # generated files
|
||||
*.sh | *.py | *.rb | *Dockerfile) prefix=("# ") ;;
|
||||
*.rs | *.c | *.h | *.cpp | *.hpp | *.s | *.S | *.js) prefix=("// " "/* ") ;;
|
||||
*.ld | *.x) prefix=("/* ") ;;
|
||||
*) error "unrecognized file type: ${p}" ;;
|
||||
# TODO: More file types?
|
||||
*) continue ;;
|
||||
esac
|
||||
# TODO: The exact line number is not actually important; it is important
|
||||
# that it be part of the top-level comments of the file.
|
||||
line="1"
|
||||
case "${p}" in
|
||||
*.sh) line="2" ;; # shebang
|
||||
esac
|
||||
if IFS= LC_ALL=C read -rn3 -d '' shebang <"${p}" && [[ "${shebang}" == '#!/' ]]; then
|
||||
line="2"
|
||||
elif [[ "${p}" == *"Dockerfile" ]] && IFS= LC_ALL=C read -rn9 -d '' syntax <"${p}" && [[ "${syntax}" == '# syntax=' ]]; then
|
||||
line="2"
|
||||
fi
|
||||
header_found=''
|
||||
for pre in "${prefix[@]}"; do
|
||||
if [[ "$(grep -E -n "${pre}SPDX-License-Identifier: " "${p}")" == "${line}:${pre}SPDX-License-Identifier: "* ]]; then
|
||||
|
||||
Reference in New Issue
Block a user