enable push without commit
This commit is contained in:
parent
08e503f968
commit
ac39addb72
28
commitly
28
commitly
@ -102,15 +102,33 @@
|
||||
(if (empty? args)
|
||||
(do
|
||||
(println "Usage: commitly [-p] <commit-message>")
|
||||
(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*))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user