Skip to content

Commit 947b3f3

Browse files
committed
fix: Use regular grep for copyright check
1 parent 1c81cd2 commit 947b3f3

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

.pre-commit-config.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ repos:
1717
name: copyright
1818
language: system
1919
types: [ python ]
20-
pass_filenames: false
21-
# Lists the Python files that do not have an Aiven copyright. Exits with a
22-
# non-zero exit code if any are found.
23-
entry: bash -c "! git grep -ELm1 'Copyright \(c\) 20[0-9]{2} Aiven' -- '*.py' ':!*__init__.py'"
20+
exclude: __init__\.py
21+
entry: ./copyright.sh
2422

2523
- repo: https://github.com/shellcheck-py/shellcheck-py
2624
rev: v0.9.0.2

copyright.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
missing_copyright=$(
4+
grep \
5+
--extended-regexp \
6+
--files-without-match \
7+
--max-count=1 \
8+
'Copyright \(c\) 20[0-9]{2} Aiven' \
9+
-- "$@"
10+
)
11+
12+
if [[ -n $missing_copyright ]]; then
13+
echo "💥 There are files missing required copyright statement."
14+
echo "$missing_copyright"
15+
exit 1
16+
else
17+
echo "✅ All files have required copyright statement."
18+
fi

0 commit comments

Comments
 (0)