Skip to content

Instantly share code, notes, and snippets.

@pesterhazy
Last active January 14, 2023 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pesterhazy/4b5b7cd560a2943f4b14fd280202ce9d to your computer and use it in GitHub Desktop.
Save pesterhazy/4b5b7cd560a2943f4b14fd280202ce9d to your computer and use it in GitHub Desktop.
Run git post-commit hook asynchronously
#!/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
#!/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