Skip to content

Commit

Permalink
Fix bug and document pre-commit usage
Browse files Browse the repository at this point in the history
  • Loading branch information
mondeja committed Sep 27, 2024
1 parent d57bb98 commit 20a1d24
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 6 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ jobs:
- name: Setup Rust
uses: hecrj/setup-rust-action@v2
with:
rust-version: nightly
rust-version: stable
profile: minimal
- name: Set up Python
uses: actions/setup-python@v5
with:
Expand Down Expand Up @@ -54,7 +55,8 @@ jobs:
- name: Setup Rust
uses: hecrj/setup-rust-action@v2
with:
rust-version: nightly
rust-version: stable
profile: minimal
- name: Build
run: cargo build --release

Expand All @@ -73,7 +75,8 @@ jobs:
- name: Setup Rust
uses: hecrj/setup-rust-action@v2
with:
rust-version: nightly
rust-version: stable
profile: minimal
- name: Cache dependencies
uses: actions/cache@v4
with:
Expand All @@ -100,6 +103,9 @@ jobs:
- uses: actions/checkout@v4
- name: Setup Rust
uses: hecrj/setup-rust-action@v2
with:
rust-version: stable
profile: minimal
- name: Publish
run: |
cargo login ${{ secrets.CRATES_TOKEN }}
Expand All @@ -115,6 +121,9 @@ jobs:
- uses: actions/checkout@v4
- name: Setup Rust
uses: hecrj/setup-rust-action@v2
with:
rust-version: stable
profile: minimal
- name: Publish
run: |
cargo login ${{ secrets.CRATES_TOKEN }}
Expand Down
3 changes: 3 additions & 0 deletions .markdownlint-cli2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
config:
no-duplicate-heading: false
first-line-heading: false
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## 2024-09-27 - [0.1.2]

### Bug fixes

- Exit code 1 when files formatted.

## 2024-09-27 - [0.1.1]

### Bug fixes
Expand All @@ -10,4 +16,5 @@

First beta release

[0.1.2]: https://github.com/mondeja/hledger-fmt/compare/v0.1.1...v0.1.2
[0.1.1]: https://github.com/mondeja/hledger-fmt/compare/v0.1.0...v0.1.1
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hledger-fmt"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
description = "An opinionated hledger's journal files formatter."
repository = "https://github.com/mondeja/hledger-fmt"
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ cargo binstall hledger-fmt

We don't currently provide standalone pre-built binaries.

### pre-commit

Use it with [pre-commit] by adding the hook to your _.pre-commit-config.yaml_:

```yaml
repos:
- repo: https://github.com/mondeja/hledger-fmt
rev: vX.Y.Z
hooks:
# id: hledger-fmt # Use this id to format files in place
- id: hledger-fmt-check # Use this id to check files without formatting
```
## Usage
When you don't pass files to format, it reads all the files with
Expand Down Expand Up @@ -61,3 +74,4 @@ accepted to make it more flexible. Send a PR if you want to help.
[cargo-binstall]: https://github.com/cargo-bins/cargo-binstall
[hledger]: https://hledger.org
[cargo]: https://doc.rust-lang.org/cargo/
[pre-commit]: https://pre-commit.com
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ fn main() {
continue;
}

exitcode = 1;

if args.fix {
match std::fs::write(&file, &formatted) {
Ok(_) => {}
Expand All @@ -135,7 +137,6 @@ fn main() {
eprintln!();
}
eprintln!("Error writing file {file}: {e}");
exitcode = 1;
}
}
} else {
Expand Down

0 comments on commit 20a1d24

Please sign in to comment.