mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-22 11:18:25 +00:00
use merge-base for copyright year check (#4907)
Instead of comparing against current base branch head, use the common ancestor of the PR and the base branch to avoid false positives when a year was bumped in the base branch but not yet merged into the PR.
This commit is contained in:
parent
8f9bb391a3
commit
3a1c468991
16
.github/workflows/ci.yml
vendored
16
.github/workflows/ci.yml
vendored
@ -57,33 +57,29 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
# Fails on nimyaml tests:
|
||||
# with:
|
||||
# submodules: true
|
||||
with:
|
||||
fetch-depth: 2 # In PR, has extra merge commit: ^1 = PR, ^2 = base
|
||||
# submodules: true # Fails on nimyaml tests
|
||||
|
||||
- name: Check copyright year (Linux)
|
||||
if: github.event_name == 'pull_request' && runner.os == 'Linux'
|
||||
run: |
|
||||
excluded_extensions="ans|json|md|png|txt"
|
||||
|
||||
base_branch=$(jq -r '.pull_request.base.ref' "$GITHUB_EVENT_PATH")
|
||||
git fetch origin "$base_branch" 2>/dev/null
|
||||
modified_files=$(git diff --name-only --diff-filter=d --ignore-submodules "origin/$base_branch" HEAD | grep -vE '\.('$excluded_extensions')$' || true)
|
||||
|
||||
current_year=$(date +"%Y")
|
||||
outdated_files=()
|
||||
for file in $modified_files; do
|
||||
while read -r file; do
|
||||
if ! grep -qE 'Copyright \(c\) .*'$current_year' Status Research & Development GmbH' "$file"; then
|
||||
outdated_files+=("$file")
|
||||
fi
|
||||
done
|
||||
done < <(git diff --name-only --diff-filter=AM --ignore-submodules HEAD^ HEAD | grep -vE '\.('$excluded_extensions')$' || true)
|
||||
|
||||
if (( ${#outdated_files[@]} )); then
|
||||
echo "The following files do not have an up-to-date copyright year:"
|
||||
for file in "${outdated_files[@]}"; do
|
||||
echo "- $file"
|
||||
done
|
||||
exit 1
|
||||
exit 2
|
||||
fi
|
||||
|
||||
- name: MSYS2 (Windows amd64)
|
||||
|
Loading…
x
Reference in New Issue
Block a user