summaryrefslogtreecommitdiffstats
path: root/scripts/license-check.sh
blob: c9c60e081ed9c66fb5d4783ba23540378ecb3335 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env bash
set -e
IFS=$'\n'
count=0
for fileType in GoFiles; do
    for file in `go list -f $'{{range .GoFiles}}{{$.Dir}}/{{.}}\n{{end}}' "$@"`; do
        case $file in
            */utils/lru.go|*/store/storetest/mocks/*|*/services/*/mocks/*|*/app/plugin/jira/plugin_*|*/plugin/plugintest/*|*/app/plugin/zoom/plugin_*)
            # Third-party, doesn't require a header.
            ;;
        *)
            if ! grep 'Mattermost, Inc. All Rights Reserved.' $file -q; then
                >&2 echo "FAIL: $file is missing a license header."
                ((count++))
            fi
        esac
    done
done
if [ $count -eq 0 ]; then
    exit 0
fi

if [ $count -gt 1 ]; then
    >&2 echo "$count files are missing license headers."
else
    >&2 echo "$count file is missing a license header."
fi
exit 1