|
| 1 | +# Copilot Instructions for Homebrew/brew |
| 2 | + |
| 3 | +This is a Ruby based repository with Bash scripts for faster execution. |
| 4 | +It is primarily responsible for providing the `brew` command for the Homebrew package manager. |
| 5 | +Please follow these guidelines when contributing: |
| 6 | + |
| 7 | +## Code Standards |
| 8 | + |
| 9 | +### Required Before Each Commit |
| 10 | + |
| 11 | +- Run `brew typecheck` to verify types are declared correctly using Sorbet. |
| 12 | +- Run `brew style --fix` to lint code formatting using RuboCop. |
| 13 | + Individual files can be checked/fixed by passing them as arguments. |
| 14 | +- Run `brew tests --online` to ensure that RSpec unit tests are passing (although some online tests may be flaky so can be ignored if they pass on a rerun). |
| 15 | + Individual test files can be passed with `--only` e.g. to test `Library/Homebrew/cmd/reinstall.rb` with `Library/Homebrew/test/cmd/reinstall_spec.rb` run `brew tests --only=cmd/reinstall`. |
| 16 | + |
| 17 | +### Development Flow |
| 18 | + |
| 19 | +- Write new code (using Sorbet `sig` type signatures and `typed: strict` files whenever possible) |
| 20 | +- Write new tests (avoid more than one `:integration_test` per file for speed) |
| 21 | + |
| 22 | +## Repository Structure |
| 23 | + |
| 24 | +- `bin/brew`: Homebrew's `brew` command main Bash entry point script |
| 25 | +- `completions/`: Generated shell (`bash`/`fish`/`zsh`) completion files. Don't edit directly, regenerate with `brew generate-man-completions` |
| 26 | +- `Library/Homebrew/`: Homebrew's core Ruby (with a little bash) logic. |
| 27 | +- `Library/Homebrew/bundle/`: Homebrew's `brew bundle` command. |
| 28 | +- `Library/Homebrew/cask/`: Homebrew's Cask classes and DSL. |
| 29 | +- `Library/Homebrew/extend/os/`: Homebrew's OS-specific (i.e. macOS or Linux) class extension logic. |
| 30 | +- `Library/Homebrew/formula.rb`: Homebrew's Formula class and DSL. |
| 31 | +- `docs/`: Documentation for Homebrew users, contributors and maintainers. Consult these for best practices and help. |
| 32 | +- `manpages/`: Generated `man` documentation files. Don't edit directly, regenerate with `brew generate-man-completions` |
| 33 | +- `package/`: Files to generate the macOS `.pkg` file. |
| 34 | + |
| 35 | +## Key Guidelines |
| 36 | + |
| 37 | +1. Follow Ruby best practices and idiomatic patterns |
| 38 | +2. Maintain existing code structure and organisation |
| 39 | +3. Write unit tests for new functionality. Use one assertion per test where possible. |
| 40 | +4. Document public APIs and complex logic. Suggest changes to the `docs/` folder when appropriate |
0 commit comments