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
15 changes: 15 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ colored output and comprehensive logging.
- **Preserve existing code style, naming, and patterns**
- **Add code only when absolutely necessary to fix the specific issue**
- **When fixing bugs, change only what's broken, not what could be improved**
- **To understand code coverage, run `cargo tarpaulin --skip-clean`. Be patient while it runs, as it may take some time to complete.**

## Testing Standards

- **Maintain test-inventory.md with test cases for features, update test case status regularly**
- **Maintain high test coverage (aim for 80%)**

### Unit Tests

- **Write unit tests for all new functionality**
- **Use descriptive test names and organize tests logically**

### Integration Tests

- **Write integration tests for critical workflows**

## Documentation Standards

Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ Thumbs.db
# Project specific
cloned_repos*/
coverage/
*.profraw
logs/
config.yaml
tarpaulin-report.html
test-*/
tests/test-recipes.yaml
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ multiple repositories simultaneously with the `--parallel` flag.
repositories with a single command.
- **Comprehensive Logging**: Every command run is logged, with detailed,
per-repository output files for easy debugging.
- **Reusable Command Recipes**: Define multi-step scripts in your config and run
them across repositories with a simple name.
- **Extensible Plugin System**: Add custom commands by creating simple
`repos-<name>` executables in your `PATH`.
- **Built in Rust**: Fast, memory-safe, and reliable.

## Installation
Expand Down Expand Up @@ -98,7 +102,7 @@ overview. Click on a command to see its detailed documentation.
| Command | Description |
|---|---|
| [**`clone`**](./docs/commands/clone.md) | Clones repositories from your config file. |
| [**`run`**](./docs/commands/run.md) | Runs a shell command in each repository. |
| [**`run`**](./docs/commands/run.md) | Runs a shell command or a pre-defined recipe in each repository. |
| [**`pr`**](./docs/commands/pr.md) | Creates pull requests for repositories with changes. |
| [**`rm`**](./docs/commands/rm.md) | Removes cloned repositories from your local disk. |
| [**`init`**](./docs/commands/init.md) | Generates a `config.yaml` file from local Git repositories. |
Expand Down Expand Up @@ -128,8 +132,28 @@ repositories:
url: git@github-enterprise:company/project.git
tags: [enterprise, backend]
# GitHub Enterprise and custom SSH configurations are supported

recipes:
- name: setup
steps:
git checkout main
git pull
./scripts/setup.sh
```

## Plugins

`repos` supports an extensible plugin system that allows you to add new
functionality without modifying the core codebase. Any executable in your `PATH`
named `repos-<plugin>` can be invoked as a subcommand.

- **List available plugins**: `repos --list-plugins`
- **Execute a plugin**: `repos <plugin-name> [args...]`

This allows for powerful, custom workflows written in any language. For a
detailed guide on creating and using plugins, see the
[Plugin System Documentation](./docs/plugins.md).

## Docker Image

You can use `repos` within a Docker container, which is great for CI/CD
Expand Down
69 changes: 57 additions & 12 deletions docs/commands/run.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
# repos run

The `run` command executes a shell command in each of the specified
repositories.
The `run` command executes a shell command or a named recipe in each of the
specified repositories.

## Usage

```bash
repos run [OPTIONS] <COMMAND> [REPOS]...
repos run [OPTIONS] <COMMAND_OR_RECIPE> [REPOS]...
```

## Description

This is one of the most powerful commands in `repos`, allowing you to automate
tasks across hundreds or thousands of repositories at once. You can run any
shell command, from simple `ls` to complex `docker build` or `terraform apply`
scripts.
shell command, from simple `ls` to complex `docker build` scripts.

By default, the output of each command is logged to a file in the `logs/runs/`
Additionally, you can define **recipes**—multi-step scripts—in your
`config.yaml` and execute them by name. This is perfect for standardizing
complex workflows like dependency updates, code generation, or release
preparation.

By default, the output of each command is logged to a file in the `output/runs/`
directory, but this can be disabled.

## Arguments

- `<COMMAND>`: The shell command to execute in each repository. It should be
enclosed in quotes if it contains spaces or special characters.
- `<COMMAND_OR_RECIPE>`: The shell command to execute or the name of the recipe
to run. If it is a command, it should be enclosed in quotes if it contains
spaces or special characters.
- `[REPOS]...`: A space-separated list of specific repository names to run the
command in. If not provided, filtering will be based on tags.

Expand All @@ -34,13 +39,45 @@ command in. If not provided, filtering will be based on tags.
(OR logic).
- `-e, --exclude-tag <EXCLUDE_TAG>`: Exclude repositories with a specific tag.
Can be specified multiple times.
- `-p, --parallel`: Execute the command in parallel across all selected
repositories.
- `-p, --parallel`: Execute the command or recipe in parallel across all
selected repositories.
- `--no-save`: Disables saving the command output to log files.
- `--output-dir <OUTPUT_DIR>`: Specifies a custom directory for log files
instead of the default `logs/runs`.
instead of the default `output/runs`.
- `-h, --help`: Prints help information.

## Recipes

Recipes are named, multi-step scripts defined in your `config.yaml`. They allow
you to codify and reuse common workflows.

### Defining a Recipe

Add a `recipes` section to your `config.yaml`:

```yaml
recipes:
- name: update-deps
steps: >
git checkout main
git pull
cargo update
cargo build --release

- name: test
steps:
- |
cargo test --all-features
run: cargo clippy
```

Each recipe has a `name` and a list of `steps`. Each step is a shell command
executed sequentially.

### Running a Recipe

To run a recipe, use its name as the main argument for the `run` command.

## Examples

### Run a command on all repositories
Expand Down Expand Up @@ -81,10 +118,18 @@ This is highly recommended for long-running commands to save time.
repos run -p "docker build ."
```

### Run a command without saving logs
### Run a command without saving output

Useful for quick, simple commands where you don't need a record of the output.

```bash
repos run --no-save "ls -la"
```

### Run the 'update-deps' recipe on all repositories

repos run --recipe update-deps

### Run the 'test' recipe on backend repositories in parallel

repos run -t backend -p --recipe test
Loading
Loading