Debian Codegraph @

dev/lint-commits.sh

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
•1 #!/usr/bin/bashscip-shell filesystem . . `/usr/bin/bash`.
2
3 # A script to check prettyness for a range of commits
4 set -e
5
6 CALLNAME="$0"
7
8 function usagescip-shell shell shell-project 0.0.0 usage().
9 {
10 >&2 echoscip-shell system . . echo. "usage: $CALLNAME <commit> <commit>"
11 >&2 echoscip-shell system . . echo. "The order of commits is as given to 'git diff'"
12 }
13
14 if [scip-shell system . . `[`. "$#" != 2 ];
15 then
16 usagescip-shell shell shell-project 0.0.0 usage().
17 exit 1
18 fi
19
20 REDBOLD="\033[31;1m"
21 RESET="\033[0m"
22
23 function redprintscip-shell shell shell-project 0.0.0 redprint().
24 {
25 if truescip-shell system . . true. || [scip-shell system . . `[`. "$COQ_CI_COLOR" ]; then
26 printfscip-shell system . . printf. "$REDBOLD%s$RESET\n" "$1"
27 else
28 printfscip-shell system . . printf. '%s\n' "$1"
29 fi
30 }
31
32 BASE_COMMIT="$1"
33 HEAD_COMMIT="$2"
34
35 tmp=$(mktempscip-shell system . . mktemp. -d)
36 gitscip-shell system . . git. worktree add "$tmp" "$HEAD_COMMIT"
37 pushd "$tmp"
38
39 bad_ws=()
40 bad_compile=()
41 while IFS= read -r commit; do
42 echoscip-shell system . . echo. Checking "$commit"
43 gitscip-shell system . . git. checkout "$commit"
44
45 # git diff --check
46 # uses .gitattributes to know what to check
47 if ! gitscip-shell system . . git. diff --check "${commit}^" "$commit";
48 then bad_ws+=("$commit")
49 fi
50
51 if ! makescip-shell system . . make. check
52 then bad_compile+=("$commit")
53 fi
54 done < <(gitscip-shell system . . git. rev-list "$HEAD_COMMIT" --not "$BASE_COMMIT" --)
55
56 popd
57 gitscip-shell system . . git. worktree remove "$tmp"
58
59 # report errors
60
61 CODE=0
62
63 if [scip-shell system . . `[`. "${#bad_ws[@]}" != 0 ]
64 then
65 >&2 redprintscip-shell shell shell-project 0.0.0 redprint(). "Whitespace errors!"
66 >&2 echoscip-shell system . . echo. "In commits ${bad_ws[*]}"
67 >&2 echoscip-shell system . . echo. "If you use emacs, you can prevent this kind of error from reoccurring by installing ws-butler and enabling ws-butler-convert-leading-tabs-or-spaces."
68 >&2 echoscip-shell system . . echo.
69 CODE=1
70 fi
71
72 if [scip-shell system . . `[`. "${#bad_compile[@]}" != 0 ]
73 then
74 >&2 redprintscip-shell shell shell-project 0.0.0 redprint(). "Compilation errors!"
75 >&2 echoscip-shell system . . echo. "In commits ${bad_compile[*]}"
76 >&2 echoscip-shell system . . echo.
77 CODE=1
78 fi
79
80 exit $CODE