This repository has been archived on 2024-01-28. You can view files and clone it, but cannot push or open issues or pull requests.
ecg-prog-filtered/filter.sh

19 lines
522 B
Bash
Executable file

#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-3.0-or-later
set -euo pipefail
export FILTER_BRANCH_SQUELCH_WARNING=1
filter_files=$(reuse spdx 2>/dev/null \
| grep -E '^(FileName: |LicenseInfoInFile: |$)' \
| rg -U -o --replace '$2 $1' "FileName: (.*)\nLicenseInfoInFile: (.*)\n" \
| sort -u \
| grep 'LicenseRef-CGV' \
| cut -d' ' -f 2 \
| tr '\n' ' ')
git branch -D filtered
git switch -c filtered
git filter-branch -f --tree-filter "rm -f ${filter_files}" HEAD
git push -f -u filtered filtered
git switch -