Compare commits

...

3 Commits

Author SHA1 Message Date
a74e14514b add pull 2026-01-05 22:11:42 -05:00
01f552b7ec update docs 2026-01-05 20:22:18 -05:00
b6c05ced0a add bbin install docs 2026-01-05 02:47:23 -05:00
4 changed files with 183 additions and 65 deletions
+23 -11
View File
@@ -23,30 +23,42 @@ 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
- `commitly` - Main orchestration function that coordinates the workflow - `pull-changes` - Executes `git pull` for a repo
- `status-all` - Shows git status for all modified repositories
- `commitly` - Main orchestration function that coordinates commit workflow
- `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
1. Scan current directory for subdirectories with `.git` folders 1. Scan current directory for subdirectories with `.git` folders
2. Filter to only repos with uncommitted changes 2. Filter to only repos with uncommitted changes (for commit operations)
3. For each modified repo: stage all changes and commit with provided message 3. For each modified repo: stage all changes and commit with provided message
4. If `-p` flag is present, push each successfully committed repo 4. If `push` subcommand is used, push each successfully committed repo (or all repos if no commit message)
5. Report success/failure for each repository 5. Report success/failure for each repository
## Common Commands ## Common Commands
### Basic Usage ### Basic Usage
**Note:** These examples assume `commitly` is in your PATH.
```bash ```bash
# Commit changes across all modified subrepos # Show status of all modified subrepos
./commitly "commit message" commitly status
# Commit changes across all modified subrepos (no push)
commitly "commit message"
# Commit and push changes # Commit and push changes
./commitly -p "commit message" commitly push "commit message"
# Push only (no commit) - useful after manual commits # Push only (no commit) - useful after manual commits
./commitly -p commitly push
# Pull changes for all subrepos
commitly pull
``` ```
### Running via Babashka Tasks ### Running via Babashka Tasks
@@ -61,7 +73,7 @@ bb run "commit message"
The script is self-contained with no external dependencies beyond Babashka standard library (`babashka.process`, `babashka.fs`). To modify: The script is self-contained with no external dependencies beyond Babashka standard library (`babashka.process`, `babashka.fs`). To modify:
1. Edit the `commitly` script directly 1. Edit the `commitly` script directly
2. Test changes by running `./commitly` with test arguments 2. Test changes by running `commitly` with test arguments (or `./commitly` if running from the repo directory)
3. The script is executable via shebang `#!/usr/bin/env bb` 3. The script is executable via shebang `#!/usr/bin/env bb`
## Important Implementation Details ## Important Implementation Details
@@ -73,9 +85,9 @@ The script is self-contained with no external dependencies beyond Babashka stand
- Non-zero exit code (1) if any operations fail - Non-zero exit code (1) if any operations fail
- Empty commit message validation prevents accidental empty commits - Empty commit message validation prevents accidental empty commits
### Special `-p` Flag Behavior ### Push Subcommand Behavior
The `-p` flag has dual behavior: The `push` subcommand has dual behavior:
- With commit message: commits then pushes - With commit message: commits then pushes
- Without commit message: pushes only (skips committing) - Without commit message: pushes only (skips committing)
@@ -85,7 +97,7 @@ This allows workflows like:
cd service-manager && git commit -m "specific message" cd service-manager && git commit -m "specific message"
cd ../www && git commit -m "different message" cd ../www && git commit -m "different message"
cd .. cd ..
./commitly -p # Push all repos commitly push # Push all repos
``` ```
### Process Execution ### Process Execution
+43 -8
View File
@@ -11,24 +11,30 @@ 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
## Usage ## Usage
**Note:** These examples assume `commitly` is in your PATH (e.g., installed via bbin or symlinked).
```bash ```bash
# Show status of all modified subrepos # Show status of all modified subrepos
./commitly status commitly status
# Commit changes across all modified subrepos # Commit changes across all modified subrepos
./commitly "Your commit message here" commitly "Your commit message here"
# Commit and push changes # Commit and push changes
./commitly -p "Your commit message here" commitly push "Your commit message here"
# Push only (without committing) # Push only (without committing)
./commitly -p commitly push
# Pull changes for all subrepos
commitly pull
``` ```
## Requirements ## Requirements
@@ -37,12 +43,40 @@ A CLI tool for making commits to many subrepos after a distributed change.
## Installation ## Installation
### Using bbin (Recommended)
Install directly from Gitea using SSH:
```bash ```bash
# Install from your Gitea repository via SSH
bbin install git@git.ajet.fyi:ajet-industries/commitly.git
# Install a specific version using a git tag
bbin install git@git.ajet.fyi:ajet-industries/commitly.git --git/tag v1.0.0
# Install the latest commit
bbin install git@git.ajet.fyi:ajet-industries/commitly.git --latest-sha
```
This will install `commitly` to `~/.local/bin/commitly` (make sure `~/.local/bin` is in your PATH).
**Note:** Requires [bbin](https://github.com/babashka/bbin) to be installed first:
```bash
bash < <(curl -s https://raw.githubusercontent.com/babashka/bbin/main/bbin)
```
### Manual Installation
```bash
# Clone the repository
git clone git@git.ajet.fyi:ajet-industries/commitly.git
cd commitly
# Make the script executable # Make the script executable
chmod +x commitly chmod +x commitly
# Optionally, symlink to a directory in your PATH # Symlink to a directory in your PATH
ln -s $(pwd)/commitly /usr/local/bin/commitly ln -s $(pwd)/commitly ~/.local/bin/commitly
``` ```
## How It Works ## How It Works
@@ -52,8 +86,9 @@ ln -s $(pwd)/commitly /usr/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
+77 -28
View File
@@ -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)
@@ -131,32 +145,8 @@
(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))))))))
;; CLI entry point (defn push-all []
(defn -main [& args] "Push all repositories without committing"
(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)]
(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) (let [current-dir (fs/cwd)
subrepos (find-subrepos current-dir)] subrepos (find-subrepos current-dir)]
(println "\nPushing changes...") (println "\nPushing changes...")
@@ -169,12 +159,71 @@
(when (seq failed) (when (seq failed)
(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))))))
;; Otherwise, require commit message
(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
(defn -main [& args]
(if (empty? args)
(do (do
(println "Usage: commitly <commit-message>")
(println " commitly status")
(println " commitly push [<commit-message>]")
(println " commitly pull")
(println "")
(println "Commands:")
(println " status Show git status for all subrepos with changes")
(println " push Push all repositories without committing")
(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)")
(System/exit 1))
(let [first-arg (first args)
rest-args (rest args)]
(cond
;; Status command
(= "status" first-arg)
(status-all)
;; Pull command
(= "pull" first-arg)
(pull-all)
;; Push command
(= "push" first-arg)
(if (empty? rest-args)
;; Push only (no commit)
(push-all)
;; Commit and push
(let [commit-message (str/join " " rest-args)]
(commitly commit-message :push? true)))
;; Commit command (no push)
:else
(let [commit-message (str/join " " args)]
(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? false))))))
(when (= *file* (System/getProperty "babashka.file")) (when (= *file* (System/getProperty "babashka.file"))
(apply -main *command-line-args*)) (apply -main *command-line-args*))
+37 -15
View File
@@ -4,40 +4,61 @@ Use this skill when you need to commit and/or push changes across multiple git r
## What is Commitly? ## What is Commitly?
Commitly is a Babashka script located at `commitly/commitly` that commits and pushes changes across all modified git subrepositories in the ajet-industries monorepo. Commitly is a Babashka CLI tool that commits and pushes changes across all modified git subrepositories in the ajet-industries monorepo.
## Installation
```bash
# Install via bbin (recommended)
bbin install git@git.ajet.fyi:ajet-industries/commitly.git
```
This installs `commitly` to `~/.local/bin/commitly` (ensure `~/.local/bin` is in your PATH).
## Usage ## Usage
**Note:** These examples assume `commitly` is in your PATH.
```bash ```bash
./commitly/commitly status # Show status of modified repos commitly status # Show status of modified repos
./commitly/commitly [-p] <commit-message> # Commit (and push) changes commitly <commit-message> # Commit changes (no push)
commitly push [<commit-message>] # Push (and optionally commit) changes
commitly pull # Pull changes for all repos
``` ```
### Options ### Commands
- `status` - Show git status for all modified repositories - `status` - Show git status for all modified repositories
- `-p` - Push changes after committing. If no commit message is provided with `-p`, it will skip committing and just push all subrepos. - `<commit-message>` - Commit changes across all modified repositories (no push)
- `push` - Push all repositories without committing
- `push <commit-message>` - Commit and push changes across all modified repositories
- `pull` - Pull changes from remote for all repositories
### Examples ### Examples
**Show status of all modified repos:** **Show status of all modified repos:**
```bash ```bash
./commitly/commitly status commitly status
``` ```
**Commit all modified repos with a message:** **Commit all modified repos with a message (no push):**
```bash ```bash
./commitly/commitly "fix: update configuration" commitly "fix: update configuration"
``` ```
**Commit and push all modified repos:** **Commit and push all modified repos:**
```bash ```bash
./commitly/commitly -p "feat: add new feature" commitly push "feat: add new feature"
``` ```
**Just push all repos (no commit):** **Just push all repos (no commit):**
```bash ```bash
./commitly/commitly -p commitly push
```
**Pull changes for all repos:**
```bash
commitly pull
``` ```
## How It Works ## How It Works
@@ -46,9 +67,10 @@ Commitly is a Babashka script located at `commitly/commitly` that commits and pu
2. **Detection**: Checks each repository for uncommitted changes using `git status --porcelain` 2. **Detection**: Checks each repository for uncommitted changes using `git status --porcelain`
3. **Action**: Depending on the command: 3. **Action**: Depending on the command:
- `status`: Shows full `git status` output for each modified repo - `status`: Shows full `git status` output for each modified repo
- `<message>`: Runs `git add -A` and `git commit -m "<message>"` for each modified repo - `<message>`: Runs `git add -A` and `git commit -m "<message>"` for each modified repo (no push)
- `-p <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
- `-p` (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
@@ -68,11 +90,11 @@ Each has its own `.git` directory and is deployed independently via Gitea Action
## Error Handling ## Error Handling
- If any repository fails to commit, commitly exits with code 1 and reports which repos failed - If any repository fails to commit, commitly exits with code 1 and reports which repos failed
- If any repository fails to push (when `-p` is used), commitly exits with code 1 and reports which repos failed - If any repository fails to push (when `push` subcommand is used), commitly exits with code 1 and reports which repos failed
- Repos are processed independently - one failure doesn't stop others from being processed - Repos are processed independently - one failure doesn't stop others from being processed
## Requirements ## Requirements
- Babashka must be installed (`bb` command available) - Babashka must be installed (`bb` command available)
- The script must be executable: `chmod +x commitly/commitly` - `commitly` must be in your PATH (install via bbin or manual symlink)
- Each subrepo must have a git remote configured for pushing - Each subrepo must have a git remote configured for pushing