From 589fd4e21a7c99738351e1913b05837edd525ede Mon Sep 17 00:00:00 2001 From: Ayden Brewer Date: Mon, 10 Jul 2023 12:47:05 -0700 Subject: [PATCH] Remove husky hooks for pre-push, pre-commit, post-commit --- .cargo-husky/hooks/post-commit | 46 ---------------------------------- .cargo-husky/hooks/pre-commit | 27 -------------------- .cargo-husky/hooks/pre-push | 37 --------------------------- 3 files changed, 110 deletions(-) delete mode 100755 .cargo-husky/hooks/post-commit delete mode 100755 .cargo-husky/hooks/pre-commit delete mode 100755 .cargo-husky/hooks/pre-push diff --git a/.cargo-husky/hooks/post-commit b/.cargo-husky/hooks/post-commit deleted file mode 100755 index b259a331dc..0000000000 --- a/.cargo-husky/hooks/post-commit +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env bash -# vim: noexpandtab shiftwidth=2 tabstop=2 -# -# Author: S0AndS0 -# Description: Check and possibly format only Rust files that were recently committed -# Note: Utilizes nightly features to mitigate extraneous changes -# -# **Warnings** -# - Unstaged hunks in files formatted with this hook will be tracked -# -# **Example usage** -# -# ```bash -# git commit src/some-file.rs -# -# VERBOSE=1 git commit src/another-file.rs -# ``` -## - -set -EeT - -__hey_listen__() { - if (( VERBOSE )); then - printf '%s\n' "${@}" - fi -} - -while read -r _path; do - if rustup run nightly -- rustfmt --check --quiet -- "${_path}" 1>/dev/null 2>&1; then - __hey_listen__ "Skipping -> ${_path}" - continue 1 - else - __hey_listen__ "Formatting -> ${_path}" - rustup run nightly -- rustfmt -- "${_path}" 1>/dev/null 2>&1 - git add "${_path}" - fi -done < <(git diff --name-only -r HEAD^1 -- '*.rs') - -if ! git diff --name-only --staged --quiet; then - __hey_listen__ 'Committing format changes' - git commit --no-verify -F- <&2 'WARNING: formatting changed please -> git push' -fi diff --git a/.cargo-husky/hooks/pre-commit b/.cargo-husky/hooks/pre-commit deleted file mode 100755 index 2c1b473935..0000000000 --- a/.cargo-husky/hooks/pre-commit +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash -# vim: noexpandtab shiftwidth=2 tabstop=2 -# -# Author: S0AndS0 -# Description: Run checks only if/when Rust source code is about to be committed -# -# **Example usage** -# -# ```bash -# VERBOSE=1 git commit src/some-file.rs -# ``` -## - -set -EeT - -__hey_listen__() { - if (( VERBOSE )); then - printf '%s\n' "${@}" - fi -} - -if git diff --name-only --staged --quiet -- '*.rs'; then - __hey_listen__ 'Skipping -> cargo check' -else - __hey_listen__ 'Running -> cargo check' - cargo check -fi diff --git a/.cargo-husky/hooks/pre-push b/.cargo-husky/hooks/pre-push deleted file mode 100755 index 9ca4284ac7..0000000000 --- a/.cargo-husky/hooks/pre-push +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash -# vim: noexpandtab shiftwidth=2 tabstop=2 -# -# Author: S0AndS0 -# Description: Run tests when Rust source code was committed and not yet tracked by remote -# -# **Warnings** -# - May fail if HEAD is detached -# -# **Example usage** -# -# ```bash -# VERBOSE=1 git commit src/some-file.rs -# -# git push -# ``` -## - -export PATH="$HOME/.cargo/bin:$PATH" - -set -EeT - -__hey_listen__() { - if (( VERBOSE )); then - printf '%s\n' "${@}" - fi -} - -_local_branch="$(git branch --show-current)" -_remote_branch="origin/${_local_branch}" - -if git diff --name-only --quiet "${_remote_branch}".."${_local_branch}" -- '*.rs'; then - __hey_listen__ 'Skipping -> cargo test' -else - __hey_listen__ 'Running -> cargo test' - cargo test -fi