add status
This commit is contained in:
parent
bfe5d7f8e4
commit
6e983f08e8
43
commitly
43
commitly
@ -57,6 +57,35 @@
|
||||
(catch Exception e
|
||||
{:success false :repo repo-path :error (.getMessage e)})))
|
||||
|
||||
(defn show-status [repo-path]
|
||||
"Show git status for a repository"
|
||||
(let [result (process/shell {:dir (str repo-path)
|
||||
:out :string
|
||||
:err :string
|
||||
:continue true}
|
||||
"git status")]
|
||||
{:repo repo-path
|
||||
:status (:out result)}))
|
||||
|
||||
(defn status-all []
|
||||
"Show git status for all modified subrepos"
|
||||
(let [current-dir (fs/cwd)
|
||||
subrepos (find-subrepos current-dir)
|
||||
modified-repos (filter has-changes? subrepos)]
|
||||
|
||||
(when (empty? modified-repos)
|
||||
(println "No repositories with changes found.")
|
||||
(System/exit 0))
|
||||
|
||||
(println (format "Found %d repositories with changes:\n" (count modified-repos)))
|
||||
|
||||
(doseq [repo modified-repos]
|
||||
(let [repo-name (fs/file-name repo)
|
||||
status-result (show-status repo)]
|
||||
(println (str "=== " repo-name " ==="))
|
||||
(println (:status status-result))
|
||||
(println)))))
|
||||
|
||||
(defn commitly [commit-message & {:keys [push?]}]
|
||||
"Main function: commit changes across all modified subrepos"
|
||||
(let [current-dir (fs/cwd)
|
||||
@ -102,8 +131,20 @@
|
||||
(if (empty? args)
|
||||
(do
|
||||
(println "Usage: commitly [-p] <commit-message>")
|
||||
(println " commitly status")
|
||||
(println "")
|
||||
(println "Options:")
|
||||
(println " -p Push changes after committing (or just push if no message)")
|
||||
(println " status Show git status for all subrepos with changes")
|
||||
(System/exit 1))
|
||||
(let [first-arg (first args)]
|
||||
(cond
|
||||
;; Status command
|
||||
(= "status" first-arg)
|
||||
(status-all)
|
||||
|
||||
;; Commit/push command
|
||||
:else
|
||||
(let [push? (some #(= "-p" %) args)
|
||||
message-args (remove #(= "-p" %) args)
|
||||
commit-message (str/join " " message-args)]
|
||||
@ -128,7 +169,7 @@
|
||||
(when (str/blank? commit-message)
|
||||
(println "Error: commit message cannot be empty")
|
||||
(System/exit 1))
|
||||
(commitly commit-message :push? push?))))))
|
||||
(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