3 # Copy me to .git/hooks/pre-commit
7 if [[ "${GIT_REFLOG_ACTION:-}" == 'rebase (reword)' ]];then
13 if [[ "$tmpdir" && -e "$tmpdir" ]];then
17 trap cleanup_tmpdir EXIT
19 # Check out the git index (what's about to be committed) in a temporary
20 # directory & run the supplied command there.
21 in_git_index_in_tmpdir
() {
23 [[ "$tmpdir" && -d "$tmpdir" ]]
24 start_index
=$(sha256sum "${GIT_INDEX_FILE:-.git/index}")
25 git checkout
-index --prefix="$tmpdir/" -a
29 end_index
=$(sha256sum "${GIT_INDEX_FILE:-.git/index}")
30 if [[ "$start_index" != "$end_index" ]];then
31 echo "Index changed while pre-commit tests were running. Aborting!"
38 cargo clippy
--frozen -- -D warnings \
40 -W clippy
::clone_on_ref_ptr \
41 -W clippy
::if_then_some_else_none \
42 -W clippy
::impl_trait_in_params \
43 -W clippy
::pattern_type_mismatch \
44 -W clippy
::shadow_reuse \
45 -W clippy
::shadow_unrelated \
46 -W clippy
::str_to_string \
48 -A clippy
::missing_errors_doc
49 find .
-name target
-prune -o -name '*.rs' -exec rustfmt
--check -- {} +
52 in_git_index_in_tmpdir verify