Merge pull request #714 from rafalste/copyright_header_check_improvements
Copyright header check improvements
This commit is contained in:
commit
9ad308d84f
32
.github/verify_header.sh
vendored
32
.github/verify_header.sh
vendored
@ -5,20 +5,32 @@
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
# COPYRIGHT_REGEX is lowercase, because the whole line is
|
||||
# converted to lowercase before test against this regex.
|
||||
COPYRIGHT_REGEX="(copyright|\(c\))\s*([0-9]{4}(\s*-\s*([0-9]{4}))?)"
|
||||
LICENSE_REGEX="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
|
||||
unset copyright_header license_header
|
||||
|
||||
# Read lines until proper copyright and license headers are found.
|
||||
while read -r line && [[ ! "$copyright_header" || ! "$license_header" ]]; do
|
||||
if [[ "${line,,}" =~ $COPYRIGHT_REGEX ]]; then
|
||||
# If the fourth regex group (from year range) doesn't exist,
|
||||
# use the second regex group instead (from a single year).
|
||||
copyright_year=${BASH_REMATCH[4]:-${BASH_REMATCH[2]}}
|
||||
|
||||
if [[ $copyright_year == $YEAR ]]; then
|
||||
copyright_header="correct_copyright_header_found"
|
||||
fi
|
||||
echo $1 have wrong license header year
|
||||
exit 1
|
||||
elif [[ "$line" =~ $LICENSE_REGEX ]]; then
|
||||
license_header="correct_license_header_found"
|
||||
fi
|
||||
done < "$1"
|
||||
|
||||
echo $1 does not contain appropriate license header
|
||||
# Proper copyright and license info were found - all good.
|
||||
[[ "$copyright_header" && "$license_header" ]] && exit 0
|
||||
|
||||
[[ ! "$copyright_header" ]] && echo >&2 "error: file '$1' does not contain any appropriate copyright info"
|
||||
[[ ! "$license_header" ]] && echo >&2 "error: file '$1' does not contain appropriate license identifier"
|
||||
exit 1
|
||||
|
24
.github/workflows/pullrequest.yml
vendored
24
.github/workflows/pullrequest.yml
vendored
@ -5,7 +5,8 @@ on:
|
||||
- master
|
||||
|
||||
env:
|
||||
EXTENSIONS: "c h cpp py go sh"
|
||||
EXTENSIONS: "c h cpp py go sh mk spec service"
|
||||
FILES: "*Makefile"
|
||||
jobs:
|
||||
verify-date:
|
||||
runs-on: ubuntu-latest
|
||||
@ -23,15 +24,16 @@ jobs:
|
||||
files_to_check=(${{ steps.changed-files.outputs.added_files }})
|
||||
files_to_check+=(${{ steps.changed-files.outputs.modified_files }})
|
||||
|
||||
for FILE in ${files_to_check[@]}; do
|
||||
REGEX=".*\.(.*)"
|
||||
if [[ "$FILE" =~ $REGEX ]]
|
||||
then
|
||||
EXTENSION=${BASH_REMATCH[1]}
|
||||
EXTENSIONS_LIST=($EXTENSIONS)
|
||||
if [[ " ${EXTENSIONS_LIST[*]} " =~ " ${EXTENSION} " ]]
|
||||
then
|
||||
.github/verify_header.sh $FILE
|
||||
fi
|
||||
for file in ${files_to_check[@]}; do
|
||||
for file_in_list in $FILES; do
|
||||
if [[ "$file" == $file_in_list ]]; then
|
||||
.github/verify_header.sh "$file"
|
||||
continue 2
|
||||
fi
|
||||
done
|
||||
|
||||
extension=${file##*.}
|
||||
if [[ "$EXTENSIONS" =~ $extension ]]; then
|
||||
.github/verify_header.sh "$file"
|
||||
fi
|
||||
done
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright(c) 2022 Intel Corporation
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include "utils_generator.h"
|
||||
|
||||
/**
|
||||
|
@ -2,6 +2,7 @@
|
||||
* Copyright(c) 2021-2022 Intel Corporation
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/*
|
||||
* <tested_file_path>src/concurrency/ocf_cache_line_concurrency.c</tested_file_path>
|
||||
* <tested_function>ocf_req_async_lock_rd</tested_function>
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright(c) 2019-2022 Intel Corporation
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/*
|
||||
* <tested_file_path>src/concurrency/ocf_metadata_concurrency.c</tested_file_path>
|
||||
* <tested_function>ocf_hb_req_prot_lock_rd</tested_function>
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright(c) 2020-2022 Intel Corporation
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/*
|
||||
* <tested_file_path>src/engine/engine_common.c</tested_file_path>
|
||||
* <tested_function>ocf_prepare_clines_miss</tested_function>
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright(c) 2019-2022 Intel Corporation
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/*
|
||||
* <tested_file_path>src/metadata/metadata_collision.c</tested_file_path>
|
||||
* <tested_function>ocf_metadata_hash_func</tested_function>
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright(c) 2019-2022 Intel Corporation
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/*
|
||||
*<tested_file_path>src/mngt/ocf_mngt_cache.c</tested_file_path>
|
||||
* <tested_function>ocf_mngt_cache_set_fallback_pt_error_threshold</tested_function>
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright(c) 2021-2022 Intel Corporation
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/*
|
||||
* <tested_file_path>src/ocf_lru.c</tested_file_path>
|
||||
* <tested_function>_lru_init</tested_function>
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright(c) 2021-2022 Intel Corporation
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/*
|
||||
* <tested_file_path>src/ocf_lru.c</tested_file_path>
|
||||
* <tested_function>lru_iter_next</tested_function>
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright(c) 2021-2022 Intel Corporation
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/*
|
||||
* <tested_file_path>src/ocf_space.c</tested_file_path>
|
||||
* <tested_function>ocf_remap_do</tested_function>
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright(c) 2019-2022 Intel Corporation
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/*
|
||||
* <tested_file_path>src/utils/utils_refcnt.c</tested_file_path>
|
||||
* <tested_function>ocf_refcnt_dec</tested_function>
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright(c) 2019-2022 Intel Corporation
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/*
|
||||
* <tested_file_path>src/utils/utils_refcnt.c</tested_file_path>
|
||||
* <tested_function>ocf_refcnt_freeze</tested_function>
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright(c) 2019-2022 Intel Corporation
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/*
|
||||
* <tested_file_path>src/utils/utils_refcnt.c</tested_file_path>
|
||||
* <tested_function>ocf_refcnt_inc</tested_function>
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright(c) 2019-2022 Intel Corporation
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/*
|
||||
* <tested_file_path>src/utils/utils_refcnt.c</tested_file_path>
|
||||
* <tested_function>ocf_refcnt_init</tested_function>
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright(c) 2019-2022 Intel Corporation
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/*
|
||||
* <tested_file_path>src/utils/utils_refcnt.c</tested_file_path>
|
||||
* <tested_function>ocf_refcnt_register_zero_cb</tested_function>
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright(c) 2019-2022 Intel Corporation
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/*
|
||||
* <tested_file_path>src/utils/utils_refcnt.c</tested_file_path>
|
||||
* <tested_function>ocf_refcnt_unfreeze</tested_function>
|
||||
|
Loading…
Reference in New Issue
Block a user