add pull
This commit is contained in:
parent
01f552b7ec
commit
a74e14514b
@ -23,9 +23,11 @@ The entire implementation is a single Babashka script (`commitly`) with these ke
|
|||||||
- `has-changes?` - Uses `git status --porcelain` to detect uncommitted changes
|
- `has-changes?` - Uses `git status --porcelain` to detect uncommitted changes
|
||||||
- `commit-changes` - Executes `git add -A` and `git commit -m` for a repo
|
- `commit-changes` - Executes `git add -A` and `git commit -m` for a repo
|
||||||
- `push-changes` - Executes `git push` for a repo
|
- `push-changes` - Executes `git push` for a repo
|
||||||
|
- `pull-changes` - Executes `git pull` for a repo
|
||||||
- `status-all` - Shows git status for all modified repositories
|
- `status-all` - Shows git status for all modified repositories
|
||||||
- `commitly` - Main orchestration function that coordinates commit workflow
|
- `commitly` - Main orchestration function that coordinates commit workflow
|
||||||
- `push-all` - Pushes all repositories without committing
|
- `push-all` - Pushes all repositories without committing
|
||||||
|
- `pull-all` - Pulls changes for all repositories
|
||||||
- `-main` - CLI argument parsing and entry point
|
- `-main` - CLI argument parsing and entry point
|
||||||
|
|
||||||
### Workflow
|
### Workflow
|
||||||
@ -54,6 +56,9 @@ commitly push "commit message"
|
|||||||
|
|
||||||
# Push only (no commit) - useful after manual commits
|
# Push only (no commit) - useful after manual commits
|
||||||
commitly push
|
commitly push
|
||||||
|
|
||||||
|
# Pull changes for all subrepos
|
||||||
|
commitly pull
|
||||||
```
|
```
|
||||||
|
|
||||||
### Running via Babashka Tasks
|
### Running via Babashka Tasks
|
||||||
|
|||||||
@ -11,6 +11,7 @@ A CLI tool for making commits to many subrepos after a distributed change.
|
|||||||
- Automatically detects which subrepos have uncommitted changes
|
- Automatically detects which subrepos have uncommitted changes
|
||||||
- Creates commits with a single message across all modified subrepos
|
- Creates commits with a single message across all modified subrepos
|
||||||
- Push changes to remote repositories after committing
|
- Push changes to remote repositories after committing
|
||||||
|
- Pull changes from remote repositories across all subrepos
|
||||||
- View status of all modified repositories
|
- View status of all modified repositories
|
||||||
- Reports commit status for each subrepo
|
- Reports commit status for each subrepo
|
||||||
- Written in Babashka for fast startup and easy distribution
|
- Written in Babashka for fast startup and easy distribution
|
||||||
@ -31,6 +32,9 @@ commitly push "Your commit message here"
|
|||||||
|
|
||||||
# Push only (without committing)
|
# Push only (without committing)
|
||||||
commitly push
|
commitly push
|
||||||
|
|
||||||
|
# Pull changes for all subrepos
|
||||||
|
commitly pull
|
||||||
```
|
```
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
@ -82,8 +86,9 @@ ln -s $(pwd)/commitly ~/.local/bin/commitly
|
|||||||
3. Depending on the command:
|
3. Depending on the command:
|
||||||
- `status`: Shows git status for all modified repositories
|
- `status`: Shows git status for all modified repositories
|
||||||
- `<message>`: Commits changes in each modified repository with the provided message
|
- `<message>`: Commits changes in each modified repository with the provided message
|
||||||
- `-p <message>`: Commits and pushes changes to remote
|
- `push <message>`: Commits and pushes changes to remote
|
||||||
- `-p` (no message): Pushes all repositories without committing
|
- `push` (no message): Pushes all repositories without committing
|
||||||
|
- `pull`: Pulls changes from remote for all repositories
|
||||||
4. Reports success/failure for each repository
|
4. Reports success/failure for each repository
|
||||||
|
|
||||||
## Use Case
|
## Use Case
|
||||||
|
|||||||
41
commitly
41
commitly
@ -62,6 +62,20 @@
|
|||||||
(catch Exception e
|
(catch Exception e
|
||||||
{:success false :repo repo-path :error (.getMessage e)})))
|
{:success false :repo repo-path :error (.getMessage e)})))
|
||||||
|
|
||||||
|
(defn pull-changes [repo-path]
|
||||||
|
"Pull changes from remote repository"
|
||||||
|
(try
|
||||||
|
(let [pull-result (process/shell {:dir repo-path
|
||||||
|
:out :string
|
||||||
|
:err :string
|
||||||
|
:continue true}
|
||||||
|
"git pull")]
|
||||||
|
(if (zero? (:exit pull-result))
|
||||||
|
{:success true :repo repo-path}
|
||||||
|
{:success false :repo repo-path :error (:err pull-result)}))
|
||||||
|
(catch Exception e
|
||||||
|
{:success false :repo repo-path :error (.getMessage e)})))
|
||||||
|
|
||||||
(defn show-status [repo-path]
|
(defn show-status [repo-path]
|
||||||
"Show git status for a repository"
|
"Show git status for a repository"
|
||||||
(let [result (process/shell {:dir (str repo-path)
|
(let [result (process/shell {:dir (str repo-path)
|
||||||
@ -146,6 +160,27 @@
|
|||||||
(println (format "\n%d repositories failed to push" (count failed)))
|
(println (format "\n%d repositories failed to push" (count failed)))
|
||||||
(System/exit 1))))))
|
(System/exit 1))))))
|
||||||
|
|
||||||
|
(defn pull-all []
|
||||||
|
"Pull changes for all repositories"
|
||||||
|
(let [repos (find-subrepos (fs/cwd))
|
||||||
|
pull-results (map pull-changes repos)
|
||||||
|
successful (filter :success pull-results)
|
||||||
|
failed (filter #(not (:success %)) pull-results)]
|
||||||
|
|
||||||
|
;; Report successes
|
||||||
|
(doseq [result successful]
|
||||||
|
(println (format "✓ %s" (fs/file-name (:repo result)))))
|
||||||
|
|
||||||
|
;; Report failures
|
||||||
|
(when (seq failed)
|
||||||
|
(println (format "\n%d repositories failed to pull:" (count failed)))
|
||||||
|
(doseq [result failed]
|
||||||
|
(println (format "✗ %s" (fs/file-name (:repo result))))
|
||||||
|
(println (format " Error: %s" (:error result))))
|
||||||
|
(System/exit 1))
|
||||||
|
|
||||||
|
(println (format "\nSuccessfully pulled %d repositories." (count successful)))))
|
||||||
|
|
||||||
;; CLI entry point
|
;; CLI entry point
|
||||||
(defn -main [& args]
|
(defn -main [& args]
|
||||||
(if (empty? args)
|
(if (empty? args)
|
||||||
@ -153,11 +188,13 @@
|
|||||||
(println "Usage: commitly <commit-message>")
|
(println "Usage: commitly <commit-message>")
|
||||||
(println " commitly status")
|
(println " commitly status")
|
||||||
(println " commitly push [<commit-message>]")
|
(println " commitly push [<commit-message>]")
|
||||||
|
(println " commitly pull")
|
||||||
(println "")
|
(println "")
|
||||||
(println "Commands:")
|
(println "Commands:")
|
||||||
(println " status Show git status for all subrepos with changes")
|
(println " status Show git status for all subrepos with changes")
|
||||||
(println " push Push all repositories without committing")
|
(println " push Push all repositories without committing")
|
||||||
(println " push <commit-message> Commit and push changes across all modified subrepos")
|
(println " push <commit-message> Commit and push changes across all modified subrepos")
|
||||||
|
(println " pull Pull changes for all repositories")
|
||||||
(println " <commit-message> Commit changes across all modified subrepos (no push)")
|
(println " <commit-message> Commit changes across all modified subrepos (no push)")
|
||||||
(System/exit 1))
|
(System/exit 1))
|
||||||
(let [first-arg (first args)
|
(let [first-arg (first args)
|
||||||
@ -167,6 +204,10 @@
|
|||||||
(= "status" first-arg)
|
(= "status" first-arg)
|
||||||
(status-all)
|
(status-all)
|
||||||
|
|
||||||
|
;; Pull command
|
||||||
|
(= "pull" first-arg)
|
||||||
|
(pull-all)
|
||||||
|
|
||||||
;; Push command
|
;; Push command
|
||||||
(= "push" first-arg)
|
(= "push" first-arg)
|
||||||
(if (empty? rest-args)
|
(if (empty? rest-args)
|
||||||
|
|||||||
@ -23,6 +23,7 @@ This installs `commitly` to `~/.local/bin/commitly` (ensure `~/.local/bin` is in
|
|||||||
commitly status # Show status of modified repos
|
commitly status # Show status of modified repos
|
||||||
commitly <commit-message> # Commit changes (no push)
|
commitly <commit-message> # Commit changes (no push)
|
||||||
commitly push [<commit-message>] # Push (and optionally commit) changes
|
commitly push [<commit-message>] # Push (and optionally commit) changes
|
||||||
|
commitly pull # Pull changes for all repos
|
||||||
```
|
```
|
||||||
|
|
||||||
### Commands
|
### Commands
|
||||||
@ -31,6 +32,7 @@ commitly push [<commit-message>] # Push (and optionally commit) changes
|
|||||||
- `<commit-message>` - Commit changes across all modified repositories (no push)
|
- `<commit-message>` - Commit changes across all modified repositories (no push)
|
||||||
- `push` - Push all repositories without committing
|
- `push` - Push all repositories without committing
|
||||||
- `push <commit-message>` - Commit and push changes across all modified repositories
|
- `push <commit-message>` - Commit and push changes across all modified repositories
|
||||||
|
- `pull` - Pull changes from remote for all repositories
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
@ -54,6 +56,11 @@ commitly push "feat: add new feature"
|
|||||||
commitly push
|
commitly push
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Pull changes for all repos:**
|
||||||
|
```bash
|
||||||
|
commitly pull
|
||||||
|
```
|
||||||
|
|
||||||
## How It Works
|
## How It Works
|
||||||
|
|
||||||
1. **Discovery**: Scans the current directory for subdirectories containing `.git` folders
|
1. **Discovery**: Scans the current directory for subdirectories containing `.git` folders
|
||||||
@ -63,6 +70,7 @@ commitly push
|
|||||||
- `<message>`: Runs `git add -A` and `git commit -m "<message>"` for each modified repo (no push)
|
- `<message>`: Runs `git add -A` and `git commit -m "<message>"` for each modified repo (no push)
|
||||||
- `push <message>`: Commits and then runs `git push` for each successfully committed repo
|
- `push <message>`: Commits and then runs `git push` for each successfully committed repo
|
||||||
- `push` (no message): Runs `git push` for all repos without committing
|
- `push` (no message): Runs `git push` for all repos without committing
|
||||||
|
- `pull`: Runs `git pull` for all repos
|
||||||
|
|
||||||
## When to Use
|
## When to Use
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user