Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,20 @@ Until then, we would kindly ask you to not open pull requests.

We will update this document when we are ready for your submissions.
Thank you and stay tuned!

## License Headers

New source files only carry the SPDX license identifier as their first line,
using the comment syntax of the file type, for example:

```cpp
// SPDX-License-Identifier: MIT
```

```cmake
# SPDX-License-Identifier: MIT
```

Do not add `SPDX-FileCopyrightText` lines or other author / copyright lists to new files.
The original author of a file and all later contributors are recorded in the git history.
The CI license check only requires the `SPDX-License-Identifier`.
34 changes: 31 additions & 3 deletions SilKit/ci/check_licenses.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,43 @@ result="$(licensecheck --check='\.c.*$|\.h.*$|\.py|CMakeLists.txt|\.sh' \
numfiles=$(echo "$result" | wc -l)
echo "Scanned $numfiles files"

violations=$(echo "$result" | grep "UNKNOWN")
# Policy: a file only needs an SPDX license identifier, e.g.
# // SPDX-License-Identifier: MIT
# No SPDX-FileCopyrightText (author/copyright list) is required; authorship is
# recorded by the git history. licensecheck reports files carrying only the
# identifier line as UNKNOWN, so accept those here.
has_spdx_identifier()
{
head -n 30 "$1" | grep -q 'SPDX-License-Identifier: MIT'
}

violations=""
unknown=$(echo "$result" | grep "UNKNOWN")
if [ -n "$unknown" ] ; then
tmp=$(mktemp)
printf "%s\n" "$unknown" > "$tmp"
while IFS= read -r line;
do
file="$(echo "$line" | cut -d ':' -f 1)"
if ! has_spdx_identifier "$file" ; then
violations="${violations}${line}
"
fi
done < "$tmp"
rm -f "$tmp"
violations=$(printf "%s" "$violations")
fi

if [ -n "$violations" ] ; then
numviolations=$(echo "$violations" | wc -l)
echo "FAILURE: Found $numviolations files without proper license info!"
echo "$violations"
mfiles="$(assemble_file_string "$violations")"
reuseMessage=$(cat << EOM
You can add the correct SPDX header to these files by running:
reuse addheader --copyright="Vector Informatik GmbH" --license="MIT" -- $mfiles
Add the SPDX license identifier as the first line of each of these files, e.g.:
// SPDX-License-Identifier: MIT (C/C++)
# SPDX-License-Identifier: MIT (CMake, Python, shell)
Files: $mfiles
EOM
)

Expand Down
Loading