Created
September 8, 2024 19:54
-
-
Save tomodachi94/13ff2a29932fca674c6731e5a3b342a4 to your computer and use it in GitHub Desktop.
license_report.sh: show all files and their inline REUSE-specified licenses
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # SPDX-FileCopyrightText: 2024 Tomodachi94 | |
| # | |
| # SPDX-License-Identifier: MIT | |
| # license_report.sh: show all files and their inline REUSE-specified licenses | |
| # Requirements: bash, ripgrep (https://github.com/BurntSushi/ripgrep), the REUSE tool (https://github.com/fsfe/reuse-tool), and some POSIX utilities (sed, echo) | |
| lint_output=$(reuse lint | rg -F "* Used licenses: " | sed 's/\* Used licenses\: //g') | |
| IFS=',' read -ra LICENSES <<< "$lint_output" | |
| echo "${LICENSES[@]}" | |
| for license in "${LICENSES[@]}"; do | |
| echo "## $license" | |
| rg --hidden -lo "SPDX-License-Identifier\:.*$license.*" | sort | uniq | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment