38 lines
1.2 KiB
Bash
Executable file
38 lines
1.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
# SPDX-FileCopyrightText: 2026 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
|
#
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
BASE_SHA=""
|
|
|
|
if [[ -n "$CI_MERGE_REQUEST_DIFF_BASE_SHA" ]]; then
|
|
# This is when there is a merge request associated with the current branch.
|
|
BASE_SHA="$CI_MERGE_REQUEST_DIFF_BASE_SHA"
|
|
elif [[ -n "$CI_COMMIT_DEFAULT_BRANCH_BASE_SHA" ]]; then
|
|
# This is when there is no a merge request associated with the current branch.
|
|
# When there is a merge request, CI_COMMIT_DEFAULT_BRANCH_BASE_SHA will not
|
|
# be set anymore.
|
|
BASE_SHA="$CI_COMMIT_DEFAULT_BRANCH_BASE_SHA"
|
|
else
|
|
echo "Not running in GitLab CI, skipping reuse lint"
|
|
exit 0
|
|
fi
|
|
|
|
for sha1 in $(git log --format=%H $BASE_SHA..); do
|
|
git checkout $sha1
|
|
|
|
# Make sure that new files have all the required SPDX identifiers.
|
|
for file in $(git show --name-only --diff-filter=A --pretty="" HEAD); do
|
|
if ! reuse lint-file $file; then
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
# Make sure that no source file ends with no SPDX identifiers.
|
|
for file in $(git show -S "SPDX" --name-only --diff-filter=M --pretty="" HEAD); do
|
|
if ! reuse lint-file $file; then
|
|
exit 1
|
|
fi
|
|
done
|
|
done
|