Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<a name="unreleased"></a>
## [Unreleased]
- No notable changes.
### Features
- **clone:** Add native batch cloning from GitHub users or organizations with parallel support.


<a name="v0.1.0"></a>
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ lib/ # Shared libraries (sourced, not executed)
src/ # Executable scripts
├── main.sh # Entry point & dispatcher
└── commands/ # Subcommand scripts
├── clone.sh # Batch-clone from GitHub
├── pull.sh # Bulk-pull reconciliation
└── status.sh # Repository status overview

Expand Down
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
**GRR** is a CLI tool that finds all git repositories under a directory and reconciles them — fetching, pulling, stashing, resetting, and cleaning — in a single command. Built for developers and platform engineers managing many repos locally.

**Features:**
- Batch-clone all repositories from a GitHub User or Organization
- Discover and pull all git repos in a directory tree
- Parallel execution for speed (`-p N`)
- Safe pipeline: fetch → status-check → stash → checkout → reset → clean → pull
Expand Down Expand Up @@ -84,7 +85,20 @@ grr --version

## Commands

### `grr pull` — Reconcile repositories
### \`grr clone\` — Batch clone repositories

\`\`\`bash
# Clone all repositories from an account (User or Org)
grr clone PlatformStackPulse ./my-repos

# Fast parallel clone with 4 jobs
grr clone PlatformStackPulse -p 4

# Preview what would be cloned
grr clone PlatformStackPulse --dry-run
\`\`\`

### \`grr pull\` — Reconcile repositories

```bash
# Recommended: safe pull with full features
Expand Down Expand Up @@ -205,6 +219,19 @@ make dev-setup # Install dev tools + git hooks

---

## Releasing New Versions

Releases are automated via GitHub Actions. To publish a new version:

1. **Bump Version:** Go to the **Actions** tab in GitHub and select the **Update Version** workflow.
2. **Run Workflow:** Click **Run workflow**, choose the version bump type (patch, minor, or major), and run it on the `main` branch.
3. **Automated Release:** This will automatically create a new git tag. The **Release** workflow will then trigger to:
* Build the single portable binary.
* Generate a GitHub Release with the binary attached as an artifact.
* Publish a new Docker image to GitHub Container Registry (GHCR).

---

## Docker

```bash
Expand Down
53 changes: 53 additions & 0 deletions SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# AI Skill: Git Repo Reconciler (GRR) Development

This skill file guides AI agents on how to maintain, extend, and verify the **Git Repo Reconciler (GRR)** codebase.

## 🧠 Core Architecture & Standards

GRR is a high-performance, modular Bash CLI tool (Bash 3.2+ compatible).

- **Library Pattern:** All reusable logic lives in `lib/*.sh`. They MUST be sourced, never executed directly, and include a double-source guard.
- **Command Dispatcher:** Commands live in `src/commands/*.sh`. The entry point `src/main.sh` dispatches to these scripts.
- **Safety First:** Every script MUST start with `set -euo pipefail`.
- **Portability:** Use `_git_timeout` (from `lib/git.sh`) instead of `timeout` to ensure compatibility between Linux and macOS.
- **Bundling:** The production binary is a single self-contained script generated by `scripts/build.sh`, which inlines all libraries and commands.

## 🛠️ Key Workflows

### Adding a New Command
1. Create `src/commands/mycommand.sh`.
2. Implement `mycommand_usage()` and `mycommand_run()`.
3. Update `src/main.sh` to route the command and add it to help/examples.
4. Add unit tests in `test/unit/mycommand_test.bats`.
5. Update documentation (`README.md`, `CONTRIBUTING.md`, `TEMPLATE_GUIDE.md`).

### Parallel Processing Pattern
When implementing batch operations, follow the pattern in `pull.sh` or `clone.sh`:
- Use a `tmpdir` created via `mktemp -d` for IPC.
- Spawn background jobs `(...) &`.
- Limit concurrency using a `while [[ $running -ge $parallel ]]` loop with `wait -n`.
- Tally results from the `tmpdir` after `wait`.

### GitHub API Interaction
- Use `curl` and `jq`.
- Always check if the account is a `User` or `Organization` using `https://api.github.com/users/<handle>`.
- Handle pagination (GitHub defaults to 30, but we prefer `per_page=100`).
- Support `GITHUB_TOKEN` via headers for private repos and rate-limit bypassing.

## 🧪 Testing & Verification

- **BATS:** Use the Bash Automated Testing System.
- **Mocking:** Since pure BATS doesn't have a mocking library, use `mktemp` to create fake git repositories for integration testing.
- **Standard Checks:** Always run `make lint` (ShellCheck) and `make fmt-check` (shfmt) before committing.

## 🚀 Release & Maintenance

- **Versioning:** Follow Semantic Versioning.
- **Releases:** Triggered via GitHub Actions `version-bump.yml`. Do not manually create tags unless necessary.
- **Artifacts:** The `release.yml` workflow generates the single portable binary for distribution.

## 📖 Style Guide Summary
- Indent: 4 spaces.
- Variables: Always quoted `"$VAR"`.
- Conditionals: Prefer `[[ ... ]]` over `[ ... ]`.
- Separation of Concerns: Logic in `lib/`, CLI glue in `src/`.
4 changes: 2 additions & 2 deletions TEMPLATE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ An overview of the design patterns, project structure, and conventions used in G

## Project Stats

- **Shell Files**: 10 (7 lib + 2 src commands + 1 entry point)
- **Test Files**: 9 (7 unit + 1 integration + 1 helper)
- **Shell Files**: 11 (7 lib + 3 src commands + 1 entry point)
- **Test Files**: 10 (8 unit + 1 integration + 1 helper)
- **Test Framework**: BATS (Bash Automated Testing System)
- **Workflows**: 6 GitHub Actions workflows
- **Dependencies**: ShellCheck, shfmt, BATS (dev only)
Expand Down
Loading
Loading