dev(ci): deploy git hooks on 'doom install'

This commit is contained in:
Henrik Lissner 2021-10-09 19:41:30 +02:00
parent 3831096cfb
commit 3854c2fd70
2 changed files with 12 additions and 8 deletions

View file

@ -13,19 +13,20 @@
;;; ;;;
(defun doom-cli--ci-deploy-hooks () (defun doom-cli--ci-deploy-hooks (&optional noforce)
(let ((dir (doom-path doom-emacs-dir ".git/hooks")) (let ((dir (doom-path doom-emacs-dir ".git/hooks"))
(default-directory doom-emacs-dir)) (default-directory doom-emacs-dir))
(make-directory dir 'parents) (make-directory dir 'parents)
(dolist (hook '("commit-msg" "pre-push")) (dolist (hook '("commit-msg" "pre-push"))
(let ((file (doom-path dir hook))) (let ((file (doom-path dir hook)))
(with-temp-file file (unless (and (file-exists-p file) noforce)
(insert "#!/usr/bin/env sh\n" (with-temp-file file
(doom-path doom-emacs-dir "bin/doom") (insert "#!/usr/bin/env sh\n"
" --nocolor ci hook-" hook (doom-path doom-emacs-dir "bin/doom")
" \"$@\"")) " --nocolor ci hook-" hook
(set-file-modes file #o700) " \"$@\""))
(print! (success "Created %s") (relpath file)))))) (set-file-modes file #o700)
(print! (success "Created %s") (relpath file)))))))
;; ;;

View file

@ -73,6 +73,9 @@ name. e.g.
(print! "Regenerating autoloads files") (print! "Regenerating autoloads files")
(doom-autoloads-reload) (doom-autoloads-reload)
(print! "Deploying commit-msg and pre-push git hooks")
(doom-cli--ci-deploy-hooks)
(cond (nofonts-p) (cond (nofonts-p)
(IS-WINDOWS (IS-WINDOWS
(print! (warn "Doom cannot install all-the-icons' fonts on Windows!\n")) (print! (warn "Doom cannot install all-the-icons' fonts on Windows!\n"))