Skip to content

Commit

Permalink
Add license check
Browse files Browse the repository at this point in the history
  • Loading branch information
parijke committed Mar 14, 2024
1 parent d9012ef commit 154db14
Show file tree
Hide file tree
Showing 9 changed files with 315 additions and 187 deletions.
15 changes: 15 additions & 0 deletions .docheader
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Copyright %regexp:\d{4}% SURFnet %regexp:(B.V.|bv)%
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
20 changes: 20 additions & 0 deletions bin/copyright-correction.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# Get all PHP files in src/ directory
files=$(find src/ -type f -name "*.php")

for file in $files
do
# Get the year of the first commit of the file
year=$(git log --follow --format=%ad --date=format:'%Y' $file | tail -1)

# Check if year is a valid 4-digit number
if [[ ! $year =~ ^[0-9]{4}$ ]]
then
echo "Invalid year $year for file $file. Skipping..."
continue
fi

# Replace the year in the copyright statement
sed -i "s/Copyright [0-9]\{4\} SURFnet bv/Copyright $year SURFnet bv/g" $file
done
5 changes: 5 additions & 0 deletions ci/qa/docheader
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

cd $(dirname $0)/../../

./vendor/bin/docheader --no-ansi check src/ tests/
6 changes: 6 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"twig/twig": "^3.0"
},
"require-dev": {
"malukenho/docheader": "^1.0.0",
"matthiasnoback/symfony-config-test": "^4.0",
"mockery/mockery": "^1.0",
"overtrue/phplint": "^9.0",
Expand Down Expand Up @@ -91,11 +92,13 @@
"@phpmd",
"@phpcs",
"@jscpd",
"@license-headers",
"@phpstan",
"@phpunit",
"@security-tests"
],
"phplint": "./ci/qa/phplint",
"license-headers": "./ci/qa/docheader",
"phpmd": "./ci/qa/phpmd",
"phpcs": "./ci/qa/phpcs",
"phpstan": "./ci/qa/phpstan",
Expand All @@ -122,6 +125,9 @@
]
},
"config": {
"audit": {
"abandoned": "report"
},
"allow-plugins": {
"symfony/flex": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
Expand Down
Loading

0 comments on commit 154db14

Please sign in to comment.