Skip to content

Commit ed33ae1

Browse files
committed
Add copyright year check pre-commit hook
1 parent 762d108 commit ed33ae1

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,8 @@ repos:
5757
- -tags=nok8s,ptf
5858
stages:
5959
- pre-push
60+
- id: copyright-year
61+
name: Copyright year is up to date in changed files
62+
entry: ./update-copyright-year.sh
63+
language: script
64+
require_serial: true

update-copyright-year.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
#
3+
# SPDX-FileCopyrightText: 2025 SUSE LLC
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
7+
current_year=$(date +%Y)
8+
for changed_file in $@; do
9+
sed -i -E "s/\/\/ SPDX-FileCopyrightText: [0-9]{4}/\/\/ SPDX-FileCopyrightText: $current_year/" $changed_file
10+
done
11+
12+
if test $(git status --porcelain | wc -l) -ne 0 ; then
13+
echo "✨ Copyright year adjusted, please commit"
14+
fi

0 commit comments

Comments
 (0)