| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | |
| 3 | fmtcount=`gitscip-shell system . . git. ls-files | grepscip-shell system . . grep. '.go$' | xargsscip-shell system . . xargs. gofmt -l 2>&1 | wcscip-shell system . . wc. -l` |
| 4 | if [scip-shell system . . `[`. $fmtcount -gt 0 ]; then |
| 5 | echoscip-shell system . . echo. "Some files aren't formatted, please run 'go fmt ./...' to format your source code before committing" |
| 6 | exit 1 |
| 7 | fi |
| 8 | |
| 9 | vetcount=`goscip-shell system . . go. tool vet ./ 2>&1 | wcscip-shell system . . wc. -l` |
| 10 | if [scip-shell system . . `[`. $vetcount -gt 0 ]; then |
| 11 | echoscip-shell system . . echo. "Some files aren't passing vet heuristics, please run 'go vet ./...' to see the errors it flags and correct your source code before committing" |
| 12 | exit 1 |
| 13 | fi |
| 14 | exit 0 |
| 15 | |
| 16 | # Ensure FIXME lines are removed before commit. |
| 17 | fixme_lines=$(gitscip-shell system . . git. diff --cached | grepscip-shell system . . grep. ^+ | grepscip-shell system . . grep. -v pre-commit | grepscip-shell system . . grep. FIXME | sedscip-shell system . . sed. 's_^+\s*__g') |
| 18 | if [scip-shell system . . `[`. "$fixme_lines" != "" ]; then |
| 19 | echoscip-shell system . . echo. "Please remove the following lines:" |
| 20 | echoscip-shell system . . echo. -e "$fixme_lines" |
| 21 | exit 1 |
| 22 | fi |
| 23 |