ocf/.github/verify_header.sh
Kamil Łepek 0ce8ced578 Added header verification script
Signed-off-by: Kamil Lepek <kamil.lepek@intel.com>
2022-05-04 16:52:11 +02:00

25 lines
577 B
Bash

#!/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