-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor/ci: ci and pre-commit use same script to check for license tag
- Loading branch information
goerlibe
committed
Sep 11, 2023
1 parent
34f05da
commit 60f5ad1
Showing
4 changed files
with
61 additions
and
125 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
|
||
# This file is part of the DiscoPoP software (http://www.discopop.tu-darmstadt.de) | ||
# | ||
# Copyright (c) 2020, Technische Universitaet Darmstadt, Germany | ||
# | ||
# This software may be modified and distributed under the terms of | ||
# the 3-Clause BSD License. See the LICENSE file in the package base | ||
# directory for details. | ||
|
||
|
||
# this script is given a list of filenames as arguments | ||
# it checks if the files contain the license tag | ||
# if not, it prints an error message and exits with exit code 1 | ||
# if all files contain the license tag, it exits with exit code 0 | ||
# some files are ignored, see below | ||
|
||
ERROR="" | ||
for file in "$@"; do | ||
# no license tag is required in the following locations: | ||
|
||
# binary files | ||
[[ "$file" = *".png" ]] && continue | ||
[[ "$file" = *".svg" ]] && continue | ||
[[ "$file" = *".ico" ]] && continue | ||
|
||
# python: | ||
[[ "$file" = *"/_version.py" ]] && continue | ||
[[ "$file" = *"/__init__.py" ]] && continue # we might want to improve this: only ignore __init__.py files if they are empty | ||
[[ "$file" = *"/py.typed" ]] && continue | ||
# not needed, as they are ignored using .gitignore | ||
#[[ "$file" = *"/__pycache__/"* ]] && continue | ||
#[[ "$file" = *"/.mypy_cache/"* ]] && continue | ||
#[[ "$file" = *"/venv/"* ]] && continue | ||
#[[ "$file" = *"/env/"* ]] && continue | ||
#[[ "$file" = *".egg-info/"* ]] && continue | ||
|
||
# other | ||
[[ "$file" = *".git/"* ]] && continue | ||
[[ "$file" = *"test/"* ]] && continue | ||
[[ "$file" = *"docs/"* ]] && continue | ||
[[ "$file" = *"build/"* ]] && continue | ||
[[ "$file" = *"LICENSE" ]] && continue | ||
[[ "$file" = *"VERSION" ]] && continue | ||
|
||
# check for the license tag in the first 20 lines of the file | ||
FILE_ERROR="" | ||
head -n 20 ${file} | grep -q "DiscoPoP software" || FILE_ERROR="yes" | ||
head -n 20 ${file} | grep -q "Technische Universitaet Darmstadt, Germany" || FILE_ERROR="yes" | ||
head -n 20 ${file} | grep -q "3-Clause BSD License" || FILE_ERROR="yes" | ||
[ -z "$FILE_ERROR" ] || ERROR="yes" | ||
[ -z "$FILE_ERROR" ] || echo "Missing License tag at: ${file}" | ||
done | ||
|
||
# Report error (1), if license tags are missing | ||
[ -z "$ERROR" ] || exit 1 | ||
|
||
# Report success (0), if license tags are present | ||
exit 0 |
This file was deleted.
Oops, something went wrong.