Skip to content

Commit 20a1d24

Browse files
committed
Fix bug and document pre-commit usage
1 parent d57bb98 commit 20a1d24

File tree

7 files changed

+40
-6
lines changed

7 files changed

+40
-6
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ jobs:
1818
- name: Setup Rust
1919
uses: hecrj/setup-rust-action@v2
2020
with:
21-
rust-version: nightly
21+
rust-version: stable
22+
profile: minimal
2223
- name: Set up Python
2324
uses: actions/setup-python@v5
2425
with:
@@ -54,7 +55,8 @@ jobs:
5455
- name: Setup Rust
5556
uses: hecrj/setup-rust-action@v2
5657
with:
57-
rust-version: nightly
58+
rust-version: stable
59+
profile: minimal
5860
- name: Build
5961
run: cargo build --release
6062

@@ -73,7 +75,8 @@ jobs:
7375
- name: Setup Rust
7476
uses: hecrj/setup-rust-action@v2
7577
with:
76-
rust-version: nightly
78+
rust-version: stable
79+
profile: minimal
7780
- name: Cache dependencies
7881
uses: actions/cache@v4
7982
with:
@@ -100,6 +103,9 @@ jobs:
100103
- uses: actions/checkout@v4
101104
- name: Setup Rust
102105
uses: hecrj/setup-rust-action@v2
106+
with:
107+
rust-version: stable
108+
profile: minimal
103109
- name: Publish
104110
run: |
105111
cargo login ${{ secrets.CRATES_TOKEN }}
@@ -115,6 +121,9 @@ jobs:
115121
- uses: actions/checkout@v4
116122
- name: Setup Rust
117123
uses: hecrj/setup-rust-action@v2
124+
with:
125+
rust-version: stable
126+
profile: minimal
118127
- name: Publish
119128
run: |
120129
cargo login ${{ secrets.CRATES_TOKEN }}

.markdownlint-cli2.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
config:
2+
no-duplicate-heading: false
3+
first-line-heading: false

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# CHANGELOG
22

3+
## 2024-09-27 - [0.1.2]
4+
5+
### Bug fixes
6+
7+
- Exit code 1 when files formatted.
8+
39
## 2024-09-27 - [0.1.1]
410

511
### Bug fixes
@@ -10,4 +16,5 @@
1016

1117
First beta release
1218

19+
[0.1.2]: https://github.com/mondeja/hledger-fmt/compare/v0.1.1...v0.1.2
1320
[0.1.1]: https://github.com/mondeja/hledger-fmt/compare/v0.1.0...v0.1.1

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "hledger-fmt"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
edition = "2021"
55
description = "An opinionated hledger's journal files formatter."
66
repository = "https://github.com/mondeja/hledger-fmt"

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ cargo binstall hledger-fmt
3030

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

33+
### pre-commit
34+
35+
Use it with [pre-commit] by adding the hook to your _.pre-commit-config.yaml_:
36+
37+
```yaml
38+
repos:
39+
- repo: https://github.com/mondeja/hledger-fmt
40+
rev: vX.Y.Z
41+
hooks:
42+
# id: hledger-fmt # Use this id to format files in place
43+
- id: hledger-fmt-check # Use this id to check files without formatting
44+
```
45+
3346
## Usage
3447
3548
When you don't pass files to format, it reads all the files with
@@ -61,3 +74,4 @@ accepted to make it more flexible. Send a PR if you want to help.
6174
[cargo-binstall]: https://github.com/cargo-bins/cargo-binstall
6275
[hledger]: https://hledger.org
6376
[cargo]: https://doc.rust-lang.org/cargo/
77+
[pre-commit]: https://pre-commit.com

src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ fn main() {
125125
continue;
126126
}
127127

128+
exitcode = 1;
129+
128130
if args.fix {
129131
match std::fs::write(&file, &formatted) {
130132
Ok(_) => {}
@@ -135,7 +137,6 @@ fn main() {
135137
eprintln!();
136138
}
137139
eprintln!("Error writing file {file}: {e}");
138-
exitcode = 1;
139140
}
140141
}
141142
} else {

0 commit comments

Comments
 (0)