feat(ci): generalize 'doom ci deploy-hooks'
By default, 'doom ci deploy-hooks' would deploy Doom's git hooks in
$EMACSDIR (~/.emacs.d/.git/hooks). Now it deploys in the local repo its
run in. This is part of an effort to generalize Doom's CI for use
outside this repo.
Ref: 4bae9ffa47
This commit is contained in:
parent
4bae9ffa47
commit
f281971206
2 changed files with 33 additions and 16 deletions
|
@ -22,20 +22,33 @@
|
||||||
;;;
|
;;;
|
||||||
|
|
||||||
|
|
||||||
(defun doom-cli--ci-deploy-hooks (&optional noforce)
|
(defun doom-cli--ci-deploy-hooks (&optional force)
|
||||||
(let* ((default-directory doom-emacs-dir)
|
(let* ((repo-path (cdr (doom-call-process "git" "rev-parse" "--show-toplevel")))
|
||||||
(dir (cdr (doom-call-process "git" "rev-parse" "--git-path" "hooks"))))
|
(submodule-p (string-empty-p (cdr (doom-call-process "git" "rev-parse" "show-superproject-working-tree"))))
|
||||||
(make-directory dir 'parents)
|
(config-hooks-path (cdr (doom-call-process "git" "config" "core.hooksPath")))
|
||||||
(dolist (hook '("commit-msg" "pre-push"))
|
(hooks-path (cdr (doom-call-process "git" "rev-parse" "--git-path" "hooks"))))
|
||||||
(let ((file (doom-path dir hook)))
|
(unless (string-empty-p config-hooks-path)
|
||||||
(unless (and (file-exists-p file) noforce)
|
(or force
|
||||||
(with-temp-file file
|
(y-or-n-p
|
||||||
(insert "#!/usr/bin/env sh\n"
|
(format (concat "Detected non-standard core.hookPath: %S\n\n"
|
||||||
(doom-path doom-emacs-dir "bin/doom")
|
"Install Doom's commit-msg and pre-push git hooks anyway?")
|
||||||
" --nocolor ci hook-" hook
|
hooks-path))
|
||||||
" \"$@\""))
|
(user-error "Aborted")))
|
||||||
(set-file-modes file #o700)
|
(make-directory hooks-path 'parents)
|
||||||
(print! (success "Created %s") (relpath file)))))))
|
(print! (start "Deploying git hooks in %S") (path hooks-path))
|
||||||
|
(print-group!
|
||||||
|
(dolist (hook '("commit-msg" "pre-push"))
|
||||||
|
(let* ((hook (doom-path hooks-path hook))
|
||||||
|
(overwrite-p (file-exists-p hook)))
|
||||||
|
(with-temp-file hook
|
||||||
|
(insert "#!/usr/bin/env sh\n"
|
||||||
|
(doom-path doom-emacs-dir "bin/doom")
|
||||||
|
" --nocolor ci hook-" (file-name-base hook)
|
||||||
|
" \"$@\""))
|
||||||
|
(set-file-modes hook #o700)
|
||||||
|
(print! (success "%s %s")
|
||||||
|
(if overwrite-p "Overwrote" "Created")
|
||||||
|
(path hook)))))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -24,7 +24,7 @@ name. e.g.
|
||||||
|
|
||||||
DOOMDIR=~/.config/doom doom install"
|
DOOMDIR=~/.config/doom doom install"
|
||||||
(print! (green "Installing Doom Emacs!\n"))
|
(print! (green "Installing Doom Emacs!\n"))
|
||||||
(let ((default-directory (doom-path "~")))
|
(let ((default-directory doom-emacs-dir))
|
||||||
;; Create `doom-private-dir'
|
;; Create `doom-private-dir'
|
||||||
(if noconfig-p
|
(if noconfig-p
|
||||||
(print! (warn "Not copying private config template, as requested"))
|
(print! (warn "Not copying private config template, as requested"))
|
||||||
|
@ -77,7 +77,11 @@ name. e.g.
|
||||||
(if nohooks-p
|
(if nohooks-p
|
||||||
(print! (warn "Not deploying commit-msg and pre-push git hooks, as requested"))
|
(print! (warn "Not deploying commit-msg and pre-push git hooks, as requested"))
|
||||||
(print! "Deploying commit-msg and pre-push git hooks")
|
(print! "Deploying commit-msg and pre-push git hooks")
|
||||||
(doom-cli--ci-deploy-hooks))
|
(print-group!
|
||||||
|
(condition-case e
|
||||||
|
(doom-cli--ci-deploy-hooks doom-auto-accept)
|
||||||
|
('user-error
|
||||||
|
(print! (warn "%s") (error-message-string e))))))
|
||||||
|
|
||||||
(cond (nofonts-p)
|
(cond (nofonts-p)
|
||||||
(IS-WINDOWS
|
(IS-WINDOWS
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue