From 5465a3d9a694104da0d07b637cc8bec30bfe6377 Mon Sep 17 00:00:00 2001 From: Chris Leonard <35844395+crleonard@users.noreply.github.com> Date: Tue, 28 Apr 2026 18:17:37 +0100 Subject: [PATCH 1/2] Allow license headers without CONTRIBUTORS.txt --- .github/workflows/scripts/check-license-header.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/scripts/check-license-header.sh b/.github/workflows/scripts/check-license-header.sh index 2677b084..0d9f7466 100755 --- a/.github/workflows/scripts/check-license-header.sh +++ b/.github/workflows/scripts/check-license-header.sh @@ -122,10 +122,20 @@ while IFS= read -r file_path; do | sed -E -e 's/20[12][0123456789] ?[-–] ?20[12][0123456789]/YEARS/' -e 's/20[12][0123456789]/YEARS/' \ ) - if ! diff -u \ + if ! diff_output=$(diff -u \ --label "Expected header" <(echo "${expected_file_header}") \ - --label "${file_path}" <(echo "${normalized_file_header}") + --label "${file_path}" <(echo "${normalized_file_header}")) then + expected_file_header_without_contributors=$(echo "${expected_file_header}" | sed '/CONTRIBUTORS\.txt/d') + normalized_file_header_without_contributors=$(echo "${normalized_file_header}" | sed '/CONTRIBUTORS\.txt/d') + if [ "${expected_file_header}" != "${expected_file_header_without_contributors}" ] \ + && diff -u \ + --label "Expected header" <(echo "${expected_file_header_without_contributors}") \ + --label "${file_path}" <(echo "${normalized_file_header_without_contributors}") > /dev/null + then + continue + fi + echo "${diff_output}" paths_with_missing_license+=("${file_path} ") fi done <<< "$file_paths" From 87d95e9d01e5262ff996c934d6f0d7e25c954d00 Mon Sep 17 00:00:00 2001 From: Chris Leonard <35844395+crleonard@users.noreply.github.com> Date: Tue, 28 Apr 2026 18:17:40 +0100 Subject: [PATCH 2/2] Create check-license-header.sh --- tests/check-license-header.sh | 58 +++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 tests/check-license-header.sh diff --git a/tests/check-license-header.sh b/tests/check-license-header.sh new file mode 100755 index 00000000..3f08e363 --- /dev/null +++ b/tests/check-license-header.sh @@ -0,0 +1,58 @@ +#!/bin/bash +##===----------------------------------------------------------------------===## +## +## This source file is part of the Swift.org open source project +## +## Copyright (c) 2026 Apple Inc. and the Swift project authors +## Licensed under Apache License v2.0 with Runtime Library Exception +## +## See https://swift.org/LICENSE.txt for license information +## +##===----------------------------------------------------------------------===## + +set -euo pipefail + +repo_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) +tmpdir=$(mktemp -d) +trap 'rm -rf "${tmpdir}"' EXIT + +mkdir -p "${tmpdir}/.github/workflows/scripts" +cp "${repo_root}/.github/workflows/scripts/check-license-header.sh" "${tmpdir}/.github/workflows/scripts/check-license-header.sh" + +cd "${tmpdir}" +git init -q + +cat > WithContributors.swift <<'EOF' +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift Logging API open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift Logging API project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift Logging API project authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// +EOF + +cat > WithoutContributors.swift <<'EOF' +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift Logging API open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift Logging API project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// +EOF + +git add WithContributors.swift WithoutContributors.swift + +PROJECT_NAME="Swift Logging API" .github/workflows/scripts/check-license-header.sh