From 3c1ebe571e05566aec5cccb9db2ab92591571c8b Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Mon, 28 Oct 2024 19:26:27 -0700 Subject: [PATCH 1/2] Sort file extensions in check-license-header.sh --- .../workflows/scripts/check-license-header.sh | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/scripts/check-license-header.sh b/.github/workflows/scripts/check-license-header.sh index 86ecb53..b94c831 100755 --- a/.github/workflows/scripts/check-license-header.sh +++ b/.github/workflows/scripts/check-license-header.sh @@ -56,23 +56,23 @@ while IFS= read -r file_path; do # shellcheck disable=SC2001 # We prefer to use sed here instead of bash search/replace case "${file_extension}" in - swift) expected_file_header=$(sed -e 's|@@|//|g' <<<"${expected_file_header_template}") ;; - h) expected_file_header=$(sed -e 's|@@|//|g' <<<"${expected_file_header_template}") ;; c) expected_file_header=$(sed -e 's|@@|//|g' <<<"${expected_file_header_template}") ;; - js) expected_file_header=$(sed -e 's|@@|//|g' <<<"${expected_file_header_template}") ;; - jsx) expected_file_header=$(sed -e 's|@@|//|g' <<<"${expected_file_header_template}") ;; - ts) expected_file_header=$(sed -e 's|@@|//|g' <<<"${expected_file_header_template}") ;; - tsx) expected_file_header=$(sed -e 's|@@|//|g' <<<"${expected_file_header_template}") ;; - sh) expected_file_header=$(cat <(echo '#!/bin/bash') <(sed -e 's|@@|##|g' <<<"${expected_file_header_template}")) ;; - ps1) expected_file_header=$(sed -e 's|@@|##|g' <<<"${expected_file_header_template}") ;; - kts) expected_file_header=$(sed -e 's|@@|//|g' <<<"${expected_file_header_template}") ;; + cmake) expected_file_header=$(sed -e 's|@@|##|g' <<<"${expected_file_header_template}") ;; gradle) expected_file_header=$(sed -e 's|@@|//|g' <<<"${expected_file_header_template}") ;; groovy) expected_file_header=$(sed -e 's|@@|//|g' <<<"${expected_file_header_template}") ;; + h) expected_file_header=$(sed -e 's|@@|//|g' <<<"${expected_file_header_template}") ;; + in) expected_file_header=$(sed -e 's|@@|##|g' <<<"${expected_file_header_template}") ;; java) expected_file_header=$(sed -e 's|@@|//|g' <<<"${expected_file_header_template}") ;; + js) expected_file_header=$(sed -e 's|@@|//|g' <<<"${expected_file_header_template}") ;; + jsx) expected_file_header=$(sed -e 's|@@|//|g' <<<"${expected_file_header_template}") ;; + kts) expected_file_header=$(sed -e 's|@@|//|g' <<<"${expected_file_header_template}") ;; + ps1) expected_file_header=$(sed -e 's|@@|##|g' <<<"${expected_file_header_template}") ;; py) expected_file_header=$(cat <(echo '#!/usr/bin/env python3') <(sed -e 's|@@|##|g' <<<"${expected_file_header_template}")) ;; rb) expected_file_header=$(cat <(echo '#!/usr/bin/env ruby') <(sed -e 's|@@|##|g' <<<"${expected_file_header_template}")) ;; - in) expected_file_header=$(sed -e 's|@@|##|g' <<<"${expected_file_header_template}") ;; - cmake) expected_file_header=$(sed -e 's|@@|##|g' <<<"${expected_file_header_template}") ;; + sh) expected_file_header=$(cat <(echo '#!/bin/bash') <(sed -e 's|@@|##|g' <<<"${expected_file_header_template}")) ;; + swift) expected_file_header=$(sed -e 's|@@|//|g' <<<"${expected_file_header_template}") ;; + ts) expected_file_header=$(sed -e 's|@@|//|g' <<<"${expected_file_header_template}") ;; + tsx) expected_file_header=$(sed -e 's|@@|//|g' <<<"${expected_file_header_template}") ;; *) error "Unsupported file extension ${file_extension} for file (exclude or update this script): ${file_path}" paths_with_missing_license+=("${file_path} ") From 1e9069d2480b9e960478533b4847ad4383d5e3e6 Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Mon, 28 Oct 2024 19:28:44 -0700 Subject: [PATCH 2/2] =?UTF-8?q?Don=E2=80=99t=20require=20license=20headers?= =?UTF-8?q?=20in=20JSON=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JSON files don’t support comments and thus can’t have license headers --- .github/workflows/scripts/check-license-header.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/scripts/check-license-header.sh b/.github/workflows/scripts/check-license-header.sh index b94c831..171fc91 100755 --- a/.github/workflows/scripts/check-license-header.sh +++ b/.github/workflows/scripts/check-license-header.sh @@ -64,6 +64,7 @@ while IFS= read -r file_path; do in) expected_file_header=$(sed -e 's|@@|##|g' <<<"${expected_file_header_template}") ;; java) expected_file_header=$(sed -e 's|@@|//|g' <<<"${expected_file_header_template}") ;; js) expected_file_header=$(sed -e 's|@@|//|g' <<<"${expected_file_header_template}") ;; + json) continue ;; # JSON doesn't support comments jsx) expected_file_header=$(sed -e 's|@@|//|g' <<<"${expected_file_header_template}") ;; kts) expected_file_header=$(sed -e 's|@@|//|g' <<<"${expected_file_header_template}") ;; ps1) expected_file_header=$(sed -e 's|@@|##|g' <<<"${expected_file_header_template}") ;; @@ -71,6 +72,7 @@ while IFS= read -r file_path; do rb) expected_file_header=$(cat <(echo '#!/usr/bin/env ruby') <(sed -e 's|@@|##|g' <<<"${expected_file_header_template}")) ;; sh) expected_file_header=$(cat <(echo '#!/bin/bash') <(sed -e 's|@@|##|g' <<<"${expected_file_header_template}")) ;; swift) expected_file_header=$(sed -e 's|@@|//|g' <<<"${expected_file_header_template}") ;; + swift-format) continue ;; # .swift-format is JSON and doesn't support comments ts) expected_file_header=$(sed -e 's|@@|//|g' <<<"${expected_file_header_template}") ;; tsx) expected_file_header=$(sed -e 's|@@|//|g' <<<"${expected_file_header_template}") ;; *)