From ac39addb727bbc54070656c9bc029c05b573292e Mon Sep 17 00:00:00 2001 From: Adam Jeniski Date: Mon, 5 Jan 2026 02:15:37 -0500 Subject: [PATCH] enable push without commit --- commitly | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/commitly b/commitly index 636b722..1d43f6b 100755 --- a/commitly +++ b/commitly @@ -102,15 +102,33 @@ (if (empty? args) (do (println "Usage: commitly [-p] ") - (println " -p Push changes after committing") + (println " -p Push changes after committing (or just push if no message)") (System/exit 1)) (let [push? (some #(= "-p" %) args) message-args (remove #(= "-p" %) args) commit-message (str/join " " message-args)] - (when (str/blank? commit-message) - (println "Error: commit message cannot be empty") - (System/exit 1)) - (commitly commit-message :push? push?)))) + (if (and (str/blank? commit-message) push?) + ;; If -p is enabled and no message, just push without committing + (do + (println "No commit message provided with -p flag. Pushing only...") + (let [current-dir (fs/cwd) + subrepos (find-subrepos current-dir)] + (println "\nPushing changes...") + (let [push-results (map push-changes subrepos)] + (doseq [result push-results] + (if (:success result) + (println (format "✓ %s" (fs/file-name (:repo result)))) + (println (format "✗ %s: %s" (fs/file-name (:repo result)) (:error result))))) + (let [failed (filter #(not (:success %)) push-results)] + (when (seq failed) + (println (format "\n%d repositories failed to push" (count failed))) + (System/exit 1)))))) + ;; Otherwise, require commit message + (do + (when (str/blank? commit-message) + (println "Error: commit message cannot be empty") + (System/exit 1)) + (commitly commit-message :push? push?)))))) (when (= *file* (System/getProperty "babashka.file")) (apply -main *command-line-args*))