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