Last active
January 14, 2023 11:05
-
-
Save pesterhazy/4b5b7cd560a2943f4b14fd280202ce9d to your computer and use it in GitHub Desktop.
Run git post-commit hook asynchronously
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bb | |
;; This script is written in babashka | |
;; brew install babashka | |
;; brew install terminal-notifier | |
(require '[babashka.process :refer [shell process]]) | |
;; assuming that the linter is called my-linter | |
(when-not (zero? (:exit (shell {:continue true} "my-linter" "--check"))) | |
(println "Post-hoc check failed") | |
(process "say" "Static checks failed") | |
(shell ["terminal-notifier", | |
"-title", | |
"Git commit", | |
"-message", | |
"Static checks failed", | |
"-open", | |
"file:///tmp/post-hoc.log"]) | |
(System/exit 1)) | |
nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
# Save this as .git/hooks/post-commit | |
.git/hooks/post-commit-async &>/tmp/async-post-commit.log & disown |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment