Skip to content

Commit

Permalink
Merge pull request Aiven-Open#564 from aiven/fix/copyright-false-nega…
Browse files Browse the repository at this point in the history
…tive

fix: Use regular grep for copyright check
  • Loading branch information
tvainika authored Mar 22, 2023
2 parents 1c81cd2 + 947b3f3 commit 0f3ae1b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
6 changes: 2 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ repos:
name: copyright
language: system
types: [ python ]
pass_filenames: false
# Lists the Python files that do not have an Aiven copyright. Exits with a
# non-zero exit code if any are found.
entry: bash -c "! git grep -ELm1 'Copyright \(c\) 20[0-9]{2} Aiven' -- '*.py' ':!*__init__.py'"
exclude: __init__\.py
entry: ./copyright.sh

- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.9.0.2
Expand Down
18 changes: 18 additions & 0 deletions copyright.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

missing_copyright=$(
grep \
--extended-regexp \
--files-without-match \
--max-count=1 \
'Copyright \(c\) 20[0-9]{2} Aiven' \
-- "$@"
)

if [[ -n $missing_copyright ]]; then
echo "💥 There are files missing required copyright statement."
echo "$missing_copyright"
exit 1
else
echo "✅ All files have required copyright statement."
fi

0 comments on commit 0f3ae1b

Please sign in to comment.