Reset draft commits instead of amending

This commit is contained in:
TEC 2024-01-11 15:57:36 +08:00
parent 8b3bd7e62a
commit 9dcf7cee5d
Signed by: tec
SSH Key Fingerprint: SHA256:eobz41Mnm0/iYWBvWThftS0ElEs1ftBr6jamutnXc/A
1 changed files with 9 additions and 7 deletions

View File

@ -487,13 +487,15 @@ PROJECT is the current project."
(if (= html-changed-files 0)
(warn! "No changes to push")
(let ((default-directory html-dir))
(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))))
(and (git-try-command "add" "-A")
(git-try-command "commit" (and html-draft-p "--amend") "--message" commit-message)
(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)))))
(git-try-command "add" "-A")
(git-try-command "commit" "--message" commit-message)
(git-try-command "push" (and html-draft-p "--force-with-lease"))))))
(section! "Finished")