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 anyhow::{bail, Context as _, Result};
|
||||||
use fs_err as fs;
|
use fs_err as fs;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|||||||
@@ -250,19 +250,22 @@ if [[ -f tools/.tidy-check-license-headers ]]; then
|
|||||||
info "checking license headers (experimental)"
|
info "checking license headers (experimental)"
|
||||||
failed_files=''
|
failed_files=''
|
||||||
for p in $(eval $(<tools/.tidy-check-license-headers)); do
|
for p in $(eval $(<tools/.tidy-check-license-headers)); do
|
||||||
# TODO: More file types?
|
|
||||||
case "$(basename "${p}")" in
|
case "$(basename "${p}")" in
|
||||||
*.sh) prefix=("# ") ;;
|
*.stderr | *.expanded.rs) continue ;; # generated files
|
||||||
*.rs | *.c | *.h | *.cpp | *.hpp | *.s | *.S) prefix=("// " "/* ") ;;
|
*.sh | *.py | *.rb | *Dockerfile) prefix=("# ") ;;
|
||||||
|
*.rs | *.c | *.h | *.cpp | *.hpp | *.s | *.S | *.js) prefix=("// " "/* ") ;;
|
||||||
*.ld | *.x) prefix=("/* ") ;;
|
*.ld | *.x) prefix=("/* ") ;;
|
||||||
*) error "unrecognized file type: ${p}" ;;
|
# TODO: More file types?
|
||||||
|
*) continue ;;
|
||||||
esac
|
esac
|
||||||
# TODO: The exact line number is not actually important; it is important
|
# TODO: The exact line number is not actually important; it is important
|
||||||
# that it be part of the top-level comments of the file.
|
# that it be part of the top-level comments of the file.
|
||||||
line="1"
|
line="1"
|
||||||
case "${p}" in
|
if IFS= LC_ALL=C read -rn3 -d '' shebang <"${p}" && [[ "${shebang}" == '#!/' ]]; then
|
||||||
*.sh) line="2" ;; # shebang
|
line="2"
|
||||||
esac
|
elif [[ "${p}" == *"Dockerfile" ]] && IFS= LC_ALL=C read -rn9 -d '' syntax <"${p}" && [[ "${syntax}" == '# syntax=' ]]; then
|
||||||
|
line="2"
|
||||||
|
fi
|
||||||
header_found=''
|
header_found=''
|
||||||
for pre in "${prefix[@]}"; do
|
for pre in "${prefix[@]}"; do
|
||||||
if [[ "$(grep -E -n "${pre}SPDX-License-Identifier: " "${p}")" == "${line}:${pre}SPDX-License-Identifier: "* ]]; then
|
if [[ "$(grep -E -n "${pre}SPDX-License-Identifier: " "${p}")" == "${line}:${pre}SPDX-License-Identifier: "* ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user