Merge pull request #1270 from matthiasbeyer/license-header-checker

License header checker
This commit is contained in:
Matthias Beyer 2018-02-10 23:27:57 +01:00 committed by GitHub
commit d5e0c23499
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 0 deletions

View file

@ -30,6 +30,7 @@ addons:
script: script:
- | - |
bash ./scripts/license-headers-updated || exit 1
cargo build --all --all-features -j 1 || exit 1 cargo build --all --all-features -j 1 || exit 1
cargo test --all --all-features -j 1 || exit 1 cargo test --all --all-features -j 1 || exit 1

39
scripts/license-headers-updated Executable file
View file

@ -0,0 +1,39 @@
#!/usr/bin/env bash
curr_year=$(date +%Y || exit 1)
line() {
head -n "$1" | tail -n 1
}
check() {
local file="$1"
local line="$2"
local mtch="$3"
local desc="$4"
cat "$file" | line "$line" | grep "$mtch" 2>/dev/null >/dev/null || {
echo "[LICENSE ERROR]: '$desc' is missing or wrong in '$file'"
return 1
}
}
find -name "*.rs" -type f | while read filename; do
check "$filename" 2 \
"imag - the personal information management suite for the commandline" \
"Description line" \
|| exit 1
check "$filename" 3 \
"Copyright (C) 2015-${curr_year}" \
"Copyright name" \
|| exit 1
check "$filename" 5 \
"This library is free software" \
"License" \
|| exit 1
echo "[LICENSE OK]: $filename"
done