Skip to content

Commit 667ff93

Browse files
committed
[dev] Make licence header check more friendly
Previously, it could not be used after the guests were built, due to some extra generated files. Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
1 parent aa1091e commit 667ff93

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

Justfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ like-ci config=default-target hypervisor="kvm":
101101
@# Ensure up-to-date Cargo.lock
102102
cargo fetch --locked
103103

104+
@# typos
105+
typos
106+
107+
@# check licence headers
108+
just check-license-headers
109+
104110
@# fmt
105111
just fmt-check
106112

dev/check-license-headers.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
# This script checks for the presence of the required license header in Rust source files.
33

44
# Get the repository root
@@ -32,7 +32,12 @@ MISSING_HEADERS=0
3232
MISSING_FILES=""
3333

3434
# Find all Rust files, excluding target directory
35-
while IFS= read -r file; do
35+
while IFS= read -r -d $'\0' file; do
36+
# Skip some files which appear when the guests are build
37+
if grep -q '^src/tests/rust_guests/[^/]*/target/' <<< "$file"; then
38+
continue
39+
fi
40+
3641
# Skip auto-generated files
3742
if grep -q "@generated" "$file" || grep -q "Automatically generated" "$file"; then
3843
continue
@@ -44,7 +49,7 @@ while IFS= read -r file; do
4449
MISSING_FILES="$MISSING_FILES\n $file"
4550
MISSING_HEADERS=$((MISSING_HEADERS + 1))
4651
fi
47-
done < <(find src -name "*.rs" -type f)
52+
done < <(find src -name "*.rs" -type f -print0)
4853

4954
if [ $MISSING_HEADERS -gt 0 ]; then
5055
echo "Found $MISSING_HEADERS files with missing or invalid license headers:"
@@ -57,4 +62,4 @@ if [ $MISSING_HEADERS -gt 0 ]; then
5762
else
5863
echo "All Rust files have the required license header"
5964
exit 0
60-
fi
65+
fi

0 commit comments

Comments
 (0)