Merge pull request #707 from Open-CAS/KamilLepek-patch-1
Added header verification script
This commit is contained in:
commit
32dbb2d355
24
.github/verify_header.sh
vendored
Normal file
24
.github/verify_header.sh
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# Copyright(c) 2022 Intel Corporation
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
YEAR=$(date +"%Y")
|
||||
REGEX="Copyright\(c\) [0-9]{4}-([0-9]{4}) |Copyright\(c\) ([0-9]{4}) "
|
||||
|
||||
while read -r line; do
|
||||
if [[ "$line" =~ $REGEX ]]; then
|
||||
echo ${BASH_REMATCH[0]}
|
||||
if [[ $YEAR == ${BASH_REMATCH[1]} || $YEAR == ${BASH_REMATCH[2]} ]]; then
|
||||
echo $1 have appropriate license header
|
||||
exit 0
|
||||
fi
|
||||
echo $1 have wrong license header year
|
||||
exit 1
|
||||
fi
|
||||
done < "$1"
|
||||
|
||||
echo $1 does not contain appropriate license header
|
||||
exit 1
|
34
.github/workflows/pullrequest.yml
vendored
Normal file
34
.github/workflows/pullrequest.yml
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
name: Licence-date-verification
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
env:
|
||||
EXTENSIONS: "c h cpp py go sh"
|
||||
jobs:
|
||||
verify-date:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2.1.0
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Get changed files
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@v18.2
|
||||
with:
|
||||
files_ignore: '.github/**'
|
||||
- name: List all changed files
|
||||
run: |
|
||||
for FILE in ${{ steps.changed-files.outputs.all_changed_files }}; do
|
||||
REGEX=".*\.(.*)"
|
||||
if [[ "$FILE" =~ $REGEX ]]
|
||||
then
|
||||
EXTENSION=${BASH_REMATCH[1]}
|
||||
EXTENSIONS_LIST=($EXTENSIONS)
|
||||
if [[ " ${EXTENSIONS_LIST[*]} " =~ " ${EXTENSION} " ]]
|
||||
then
|
||||
.github/verify_header.sh $FILE
|
||||
fi
|
||||
fi
|
||||
done
|
Loading…
Reference in New Issue
Block a user