enable push without commit
This commit is contained in:
parent
08e503f968
commit
ac39addb72
22
commitly
22
commitly
@ -102,15 +102,33 @@
|
|||||||
(if (empty? args)
|
(if (empty? args)
|
||||||
(do
|
(do
|
||||||
(println "Usage: commitly [-p] <commit-message>")
|
(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))
|
(System/exit 1))
|
||||||
(let [push? (some #(= "-p" %) args)
|
(let [push? (some #(= "-p" %) args)
|
||||||
message-args (remove #(= "-p" %) args)
|
message-args (remove #(= "-p" %) args)
|
||||||
commit-message (str/join " " message-args)]
|
commit-message (str/join " " message-args)]
|
||||||
|
(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)
|
(when (str/blank? commit-message)
|
||||||
(println "Error: commit message cannot be empty")
|
(println "Error: commit message cannot be empty")
|
||||||
(System/exit 1))
|
(System/exit 1))
|
||||||
(commitly commit-message :push? push?))))
|
(commitly commit-message :push? push?))))))
|
||||||
|
|
||||||
(when (= *file* (System/getProperty "babashka.file"))
|
(when (= *file* (System/getProperty "babashka.file"))
|
||||||
(apply -main *command-line-args*))
|
(apply -main *command-line-args*))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user