2020-10-27 21:39:54 -07:00
# Contributing
2020-10-27 21:35:35 -07:00
2020-10-29 19:46:36 +01:00
Thank you for considering to contribute to `bat` !
2020-10-27 21:35:35 -07:00
2020-10-29 19:46:36 +01:00
## Add an entry to the changelog
2024-02-24 23:58:20 +01:00
Keeping the [`CHANGELOG.md` ](CHANGELOG.md ) file up-to-date makes the release
process much easier and therefore helps to get your changes into a new `bat`
release faster. However, not every change to the repository requires a
changelog entry. Below are a few examples of that.
Please update the changelog if your contribution contains changes regarding
any of the following:
- the behavior of `bat`
- syntax mappings
- syntax definitions
- themes
- the build system, linting, or CI workflows
A changelog entry is not necessary when:
- updating documentation
- fixing typos
>[!NOTE]
> For PRs, a CI workflow verifies that a suitable changelog entry is
> added. If such an entry is missing, the workflow will fail. If your
> changes do not need an entry to the changelog (see above), that
> workflow failure can be disregarded.
### Changelog entry format
2020-10-29 19:46:36 +01:00
The top of the `CHANGELOG` contains a *"unreleased"* section with a few
subsections (Features, Bugfixes, …). Please add your entry to the subsection
2020-12-01 19:38:14 +01:00
that best describes your change.
2020-10-29 19:46:36 +01:00
2024-02-24 23:58:20 +01:00
Entries must follow this format:
2020-10-27 21:39:54 -07:00
```
2020-10-27 21:35:35 -07:00
- Short description of what has been changed, see #123 (@user)
2020-10-27 21:39:54 -07:00
```
2024-02-24 23:58:20 +01:00
Please replace `#123` with the number of your pull request (not issue) and
`@user` by your GitHub username.
2020-10-29 19:51:16 +01:00
## Development
Please check out the [Development ](https://github.com/sharkdp/bat#development )
section in the README.
2020-10-29 19:52:55 +01:00
## Adding a new feature
Please consider opening a
[feature request ticket ](https://github.com/sharkdp/bat/issues/new?assignees=&labels=feature-request&template=feature_request.md )
2022-10-09 01:18:35 -07:00
first in order to give us a chance to discuss the details and specifics of the potential new feature before you go and build it.
2020-10-29 19:52:55 +01:00
2020-10-29 19:51:16 +01:00
## Adding new syntaxes/languages or themes
Before you make a pull request that adds a new syntax or theme, please read
the [Customization ](https://github.com/sharkdp/bat#customization ) section
in the README first.
2025-10-07 19:00:07 +02:00
If you really think that a particular syntax should be added for all
2020-10-29 19:51:16 +01:00
users, please read the corresponding
[documentation ](https://github.com/sharkdp/bat/blob/master/doc/assets.md )
first.
2022-02-26 17:03:54 +01:00
2026-03-18 14:20:35 +01:00
To map a file name pattern to an existing syntax, read [the documentation here ](https://github.com/sharkdp/bat/blob/master/src/syntax_mapping/builtins/README.md ).
2025-10-07 19:00:07 +02:00
Note: We are currently not accepting new default themes.
2022-02-26 17:03:54 +01:00
## Regression tests
2022-10-09 01:18:35 -07:00
You are **strongly encouraged** to add regression tests. Regression tests are great,
2022-02-26 17:03:54 +01:00
not least because they:
2022-10-09 15:44:45 -07:00
* ensure that your contribution will never completely stop working.
2022-02-26 17:03:54 +01:00
2022-10-09 15:44:45 -07:00
* makes code reviews easier, because it becomes very clear what the code is
2022-02-26 17:03:54 +01:00
supposed to do.
For functional changes, you most likely want to add a test to
[`tests/integration_tests.rs` ](https://github.com/sharkdp/bat/blob/master/tests/integration_tests.rs ).
Look at existing tests to know how to write a new test. In short, you will
invoke the `bat` binary with a certain set of arguments, and then assert on
stdout/stderr.
To learn how to write regression tests for theme and syntax changes, read the
[Syntax
tests ](https://github.com/sharkdp/bat/blob/master/doc/assets.md#syntax-tests )
section in `assets.md` .
2026-03-05 13:55:05 +08:00
### Ensuring bat is available for Syntax tests
The syntax test script (`tests/syntax-tests/update.sh` ) calls `bat` from your PATH and regenerates the highlighted output files under
`tests/syntax-tests/highlighted/` . These files are used to verify that syntax highlighting works as expected.
- If you only built the binaries with:
```bash
cargo build --bins
` ``
you need to add the debug build to your PATH from the bat project root before running the tests.
See also step 5 in [Syntax
tests](https://github.com/sharkdp/bat/blob/master/doc/assets.md#syntax-tests) for related instructions.
` ``bash
export PATH="$PATH:$(pwd)/target/debug"
` ``
Otherwise, you will see:
` ``bash
Error: Could not execute 'bat'. Please make sure that the executable is available on the PATH.
` ``
- If you installed bat with:
` ``bash
cargo install --path . --locked
` ``
then bat will be available in ~/.cargo/bin (usually already in PATH), and the tests will run without issues.