Skip to content

Commit 9eb0138

Browse files
fix: avoid removing entire file when license footer is missing (#26343)
1 parent 42f6f00 commit 9eb0138

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

enterprise/scripts/add-license.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ remove_license_headers() {
4747

4848
# Remove all lines from any occurrence of "IMPORTANT LICENSE NOTICE"
4949
# through "Copyright (c) 2026 Cosmos Labs US Inc."
50-
sed '/\/\/ IMPORTANT LICENSE NOTICE/,/\/\/ Copyright (c) 2026 Cosmos Labs US Inc\./d' "$file" > "$tmpfile"
50+
if grep -qF "// Copyright (c) 2026 Cosmos Labs US Inc." "$file"; then
51+
sed '/\/\/ IMPORTANT LICENSE NOTICE/,/\/\/ Copyright (c) 2026 Cosmos Labs US Inc\./d' "$file" > "$tmpfile"
52+
else
53+
cp "$file" "$tmpfile"
54+
fi
5155

5256
# Remove any blank lines at the start of file
5357
sed -i.bak '1{/^$/d;}' "$tmpfile"

0 commit comments

Comments
 (0)