Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions scripts/ci/check_license.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
#!/bin/bash
#!/usr/bin/env bash

set -e
set -euo pipefail

# Make sure we don't introduce accidental references to PATENTS.
EXPECTED='scripts/ci/check_license.sh'
ACTUAL=$(git grep -l PATENTS)
# File that is allowed to contain the string "PATENTS"
EXPECTED_FILE="scripts/ci/check_license.sh"

if [ "$EXPECTED" != "$ACTUAL" ]; then
echo "PATENTS crept into some new files?"
diff -u <(echo "$EXPECTED") <(echo "$ACTUAL") || true
exit 1
# Get all files that contain "PATENTS" (ignore binary files, handle no matches safely)
mapfile -t ACTUAL_FILES < <(git grep -l --no-color -- "PATENTS" || true)

# If exactly one file and it matches expected → OK
if [[ "${#ACTUAL_FILES[@]}" -eq 1 && "${ACTUAL_FILES[0]}" == "$EXPECTED_FILE" ]]; then
exit 0
fi

echo "Error: Unexpected references to 'PATENTS' found."

echo "Expected:"
echo " $EXPECTED_FILE"

echo "Actual:"
for file in "${ACTUAL_FILES[@]:-<none>}"; do
echo " $file"
done

echo
echo "Diff:"
diff -u <(printf "%s\n" "$EXPECTED_FILE") <(printf "%s\n" "${ACTUAL_FILES[@]}") || true

exit 1