Zack Williams | 32293ee | 2018-05-18 09:15:13 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 2 | |
| 3 | # licensecheck.sh |
| 4 | # checks for copyright/license headers on files |
| 5 | # excludes filename extensions where this check isn't pertinent |
| 6 | |
Zack Williams | 32293ee | 2018-05-18 09:15:13 -0700 | [diff] [blame] | 7 | set +e -u -o pipefail |
| 8 | fail_licensecheck=0 |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 9 | |
Zack Williams | 32293ee | 2018-05-18 09:15:13 -0700 | [diff] [blame] | 10 | while IFS= read -r -d '' f |
| 11 | do |
| 12 | grep -q "Copyright\|Apache License" "${f}" |
| 13 | rc=$? |
| 14 | if [[ $rc != 0 ]]; then |
| 15 | echo "ERROR: $f does not contain License Header" |
| 16 | fail_licensecheck=1 |
| 17 | fi |
| 18 | done < <(find . -name ".git" -prune -o -type f \ |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 19 | -name "*.*" \ |
| 20 | ! -name "*.PNG" \ |
| 21 | ! -name "*.asc" \ |
| 22 | ! -name "*.bat" \ |
| 23 | ! -name "*.cfg" \ |
| 24 | ! -name "*.cnf" \ |
| 25 | ! -name "*.conf" \ |
| 26 | ! -name "*.cql" \ |
| 27 | ! -name "*.crt" \ |
| 28 | ! -name "*.csr" \ |
| 29 | ! -name "*.csv" \ |
| 30 | ! -name "*.ctmpl" \ |
| 31 | ! -name "*.curl" \ |
| 32 | ! -name "*.db" \ |
| 33 | ! -name "*.der" \ |
| 34 | ! -name "*.diff" \ |
| 35 | ! -name "*.dnsmasq" \ |
| 36 | ! -name "*.do" \ |
| 37 | ! -name "*.docx" \ |
| 38 | ! -name "*.eot" \ |
| 39 | ! -name "*.gif" \ |
| 40 | ! -name "*.gpg" \ |
| 41 | ! -name "*.graffle" \ |
| 42 | ! -name "*.iml" \ |
| 43 | ! -name "*.in" \ |
| 44 | ! -name "*.inc" \ |
| 45 | ! -name "*.j2" \ |
| 46 | ! -name "*.jar" \ |
| 47 | ! -name "*.jks" \ |
| 48 | ! -name "*.jpg" \ |
| 49 | ! -name "*.json" \ |
| 50 | ! -name "*.key" \ |
| 51 | ! -name "*.list" \ |
| 52 | ! -name "*.local" \ |
| 53 | ! -name "*.log" \ |
| 54 | ! -name "*.mak" \ |
| 55 | ! -name "*.md" \ |
| 56 | ! -name "*.mk" \ |
| 57 | ! -name "*.oar" \ |
| 58 | ! -name "*.p12" \ |
| 59 | ! -name "*.patch" \ |
| 60 | ! -name "*.pcap" \ |
| 61 | ! -name "*.pem" \ |
| 62 | ! -name "*.png" \ |
| 63 | ! -name "*.properties" \ |
| 64 | ! -name "*.proto" \ |
| 65 | ! -name "*.pyc" \ |
| 66 | ! -name "*.repo" \ |
| 67 | ! -name "*.robot" \ |
| 68 | ! -name "*.rst" \ |
| 69 | ! -name "*.rules" \ |
| 70 | ! -name "*.service" \ |
| 71 | ! -name "*.svg" \ |
| 72 | ! -name "*.swp" \ |
| 73 | ! -name "*.tar" \ |
| 74 | ! -name "*.tar.gz" \ |
| 75 | ! -name "*.toml" \ |
| 76 | ! -name "*.ttf" \ |
| 77 | ! -name "*.txt" \ |
| 78 | ! -name "*.woff" \ |
| 79 | ! -name "*.xproto" \ |
| 80 | ! -name "*.xtarget" \ |
| 81 | ! -name "*ignore" \ |
| 82 | ! -name "*rc" \ |
| 83 | ! -name "Dockerfile" \ |
| 84 | ! -name "Dockerfile.*" \ |
| 85 | ! -name "Makefile" \ |
| 86 | ! -name "Makefile.*" \ |
| 87 | ! -name "README" \ |
| 88 | ! -path "*/vendor/*.go" \ |
| 89 | ! -path "*conf*" \ |
| 90 | ! -path "*git*" \ |
| 91 | ! -path "*swagger*" \ |
Zack Williams | 32293ee | 2018-05-18 09:15:13 -0700 | [diff] [blame] | 92 | -print0 ) |
| 93 | |
| 94 | exit ${fail_licensecheck} |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 95 | |