Skip to content

Instantly share code, notes, and snippets.

@tomodachi94
Created September 8, 2024 19:54
Show Gist options
  • Select an option

  • Save tomodachi94/13ff2a29932fca674c6731e5a3b342a4 to your computer and use it in GitHub Desktop.

Select an option

Save tomodachi94/13ff2a29932fca674c6731e5a3b342a4 to your computer and use it in GitHub Desktop.
license_report.sh: show all files and their inline REUSE-specified licenses
#!/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