summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2018-02-07 03:09:53 +0100
committerMatthias Beyer <mail@beyermatthias.de>2018-02-10 16:40:47 +0100
commit8fe71c5b73e39e96f7b517f521246edf9f080c03 (patch)
treeb078e5ff4c876dd59626075198fd29f2ab3d4a45 /scripts
parentedd5925f8846b9216dcbc2bcab2950dfe6047fcd (diff)
Add check script whether license headers are there and updated
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/license-headers-updated39
1 files changed, 39 insertions, 0 deletions
diff --git a/scripts/license-headers-updated b/scripts/license-headers-updated
new file mode 100755
index 00000000..cbd8cfe4
--- /dev/null
+++ b/scripts/license-headers-updated
@@ -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
+