Skip to content

Commit 598d8d3

Browse files
committed
Fix license header check ignoring well known files
The previous PR tried to ignore two well known files `.licenseignore` and `.license_header_template`. However, that PR wasn't fully working and broke this check. This PR fixes it by using a slightly different approach for those well known files.
1 parent 85e54b8 commit 598d8d3

8 files changed

+42
-28
lines changed

.github/workflows/scripts/check-broken-symlinks.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# ===----------------------------------------------------------------------===//
2+
# ===----------------------------------------------------------------------===#
33
#
44
# This source file is part of the Swift.org open source project
55
#
@@ -9,7 +9,7 @@
99
# See https://swift.org/LICENSE.txt for license information
1010
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
1111
#
12-
# ===----------------------------------------------------------------------===//
12+
# ===----------------------------------------------------------------------===#
1313

1414
set -euo pipefail
1515

.github/workflows/scripts/check-docs.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# ===----------------------------------------------------------------------===//
2+
# ===----------------------------------------------------------------------===#
33
#
44
# This source file is part of the Swift.org open source project
55
#
@@ -9,7 +9,7 @@
99
# See https://swift.org/LICENSE.txt for license information
1010
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
1111
#
12-
# ===----------------------------------------------------------------------===//
12+
# ===----------------------------------------------------------------------===#
1313

1414
set -euo pipefail
1515

.github/workflows/scripts/check-license-header.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# ===----------------------------------------------------------------------===//
2+
# ===----------------------------------------------------------------------===#
33
#
44
# This source file is part of the Swift.org open source project
55
#
@@ -9,7 +9,7 @@
99
# See https://swift.org/LICENSE.txt for license information
1010
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
1111
#
12-
# ===----------------------------------------------------------------------===//
12+
# ===----------------------------------------------------------------------===#
1313

1414
set -euo pipefail
1515

@@ -40,12 +40,12 @@ fi
4040

4141
paths_with_missing_license=( )
4242

43-
file_excludes=".license_header_template
44-
.licenseignore"
45-
if [ -f .licenseignore ]; then
46-
file_excludes=$file_excludes$(printf '\n')$(cat .licenseignore)
43+
if [[ -f .licenseignore ]]; then
44+
file_paths=$(tr '\n' '\0' < .licenseignore | xargs -0 -I% printf '":(exclude)%" '| xargs git ls-files ":(exclude).licenseignore" ":(exclude).license_header_template" )
45+
else
46+
file_paths=$(git ls-files ":(exclude).license_header_template" )
4747
fi
48-
file_paths=$(echo "$file_excludes" | tr '\n' '\0' | xargs -0 -I% printf '":(exclude)%" '| xargs git ls-files)
48+
4949

5050
while IFS= read -r file_path; do
5151
file_basename=$(basename -- "${file_path}")

.github/workflows/scripts/check-swift-format.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# ===----------------------------------------------------------------------===//
2+
# ===----------------------------------------------------------------------===#
33
#
44
# This source file is part of the Swift.org open source project
55
#
@@ -9,7 +9,7 @@
99
# See https://swift.org/LICENSE.txt for license information
1010
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
1111
#
12-
# ===----------------------------------------------------------------------===//
12+
# ===----------------------------------------------------------------------===#
1313

1414
set -euo pipefail
1515

.github/workflows/scripts/check-unacceptable-language.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# ===----------------------------------------------------------------------===//
2+
# ===----------------------------------------------------------------------===#
33
#
44
# This source file is part of the Swift.org open source project
55
#
@@ -9,7 +9,7 @@
99
# See https://swift.org/LICENSE.txt for license information
1010
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
1111
#
12-
# ===----------------------------------------------------------------------===//
12+
# ===----------------------------------------------------------------------===#
1313

1414
set -euo pipefail
1515

.license_header_template

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# ===----------------------------------------------------------------------===#
2+
#
3+
# This source file is part of the Swift.org open source project
4+
#
5+
# Copyright (c) YEARS Apple Inc. and the Swift project authors
6+
# Licensed under Apache License v2.0 with Runtime Library Exception
7+
#
8+
# See https://swift.org/LICENSE.txt for license information
9+
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
#
11+
# ===----------------------------------------------------------------------===#

.licenseignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.github/workflows/configs/.flake8
2+
**/*.yml
3+
CODEOWNERS
4+
LICENSE.txt
5+
README.md

tests/test.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
#!/usr/bin/env python3
2-
##===----------------------------------------------------------------------===##
3-
##
4-
## This source file is part of the Swift.org open source project
5-
##
6-
## Copyright (c) 2020 Apple Inc. and the Swift.org project authors
7-
## Licensed under Apache License v2.0
8-
##
9-
## See LICENSE.txt for license information
10-
## See CONTRIBUTORS.txt for the list of Swift.org project authors
11-
##
12-
## SPDX-License-Identifier: Apache-2.0
13-
##
14-
##===----------------------------------------------------------------------===##
2+
# ===----------------------------------------------------------------------===#
3+
#
4+
# This source file is part of the Swift.org open source project
5+
#
6+
# Copyright (c) 2024 Apple Inc. and the Swift project authors
7+
# Licensed under Apache License v2.0 with Runtime Library Exception
8+
#
9+
# See https://swift.org/LICENSE.txt for license information
10+
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
11+
#
12+
# ===----------------------------------------------------------------------===#

0 commit comments

Comments
 (0)