Rework reset/draft publish logic

This commit is contained in:
Timothy 2024-01-11 16:13:21 +08:00
parent c3df4d429e
commit 7690dc82f2
Signed by: tec
SSH key fingerprint: SHA256:eobz41Mnm0/iYWBvWThftS0ElEs1ftBr6jamutnXc/A

View file

@ -491,13 +491,13 @@ PROJECT is the current project."
(if (= html-changed-files 0)
(warn! "No changes to push")
(let ((default-directory html-dir))
(and (or source-draft-p
(prog1 (or (not html-draft-p)
(git-try-command "reset" "--soft" "HEAD~1"))
(dolist (file (mapcar #'cdr (get-unstaged-changes)))
(when (and (file-exists-p file)
(string-prefix-p "DRAFT-" (file-name-base file)))
(delete-file file)))))
(and (prog1 (or (not html-draft-p)
(git-try-command "reset" "--soft" "HEAD~1"))
(unless source-draft-p
(dolist (file (mapcar #'cdr (get-unstaged-changes)))
(when (and (file-exists-p file)
(string-prefix-p "DRAFT-" (file-name-base file)))
(delete-file file)))))
(git-try-command "add" "-A")
(git-try-command "commit" "--message" commit-message)
(git-try-command "push" (and html-draft-p "--force-with-lease"))))))