mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-27 11:31:05 +00:00
header_check: Check header for changed text files
We are running `header_check` for non-text files like binary files, symbolic link files, image files (pictures) and etc., which does not make sense. Filter out non-text files and run `header_check` only for text files changed. Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
This commit is contained in:
parent
7e49e83779
commit
d23284a0dc
@ -413,10 +413,21 @@ static_check_license_headers()
|
||||
|
||||
files=$(get_pr_changed_file_details || true)
|
||||
|
||||
# Strip off status
|
||||
files=$(echo "$files"|awk '{print $NF}')
|
||||
# Strip off status and convert to array
|
||||
files=($(echo "$files"|awk '{print $NF}'))
|
||||
|
||||
# no files were changed
|
||||
text_files=()
|
||||
# Filter out non-text files
|
||||
for file in "${files[@]}"; do
|
||||
if [[ -f "$file" ]] && file --mime-type "$file" | grep -q "text/"; then
|
||||
text_files+=("$file")
|
||||
else
|
||||
info "Ignoring non-text file: $file"
|
||||
fi
|
||||
done
|
||||
files="${text_files[*]}"
|
||||
|
||||
# no text files were changed
|
||||
[ -z "$files" ] && info "No files found" && popd && return
|
||||
|
||||
local header_check
|
||||
|
Loading…
Reference in New Issue
Block a user