Skip to content

Commit dc35d69

Browse files
committed
fix fmt drift and add cargo-husky pre-push hook
`cargo fmt --all` clears the diff that turned CI red on the 0.0.2 release push. The pre-push hook auto-installs on the next `cargo test` and runs `cargo fmt --all --check`, blocking the same drift from reaching CI again.
1 parent 0d05698 commit dc35d69

5 files changed

Lines changed: 28 additions & 12 deletions

File tree

.cargo-husky/hooks/pre-push

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
if ! cargo fmt --all --check; then
5+
echo
6+
echo "pre-push: cargo fmt --all --check failed — run 'cargo fmt --all' and commit." >&2
7+
exit 1
8+
fi

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/catc/src/cli.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -208,17 +208,11 @@ pub enum AliasCmd {
208208
/// List stored aliases.
209209
List,
210210
/// Run a stored alias by name.
211-
Run {
212-
name: String,
213-
},
211+
Run { name: String },
214212
/// Bulk-load aliases from a YAML file.
215-
Import {
216-
file: String,
217-
},
213+
Import { file: String },
218214
/// Bulk-save aliases to a YAML file.
219-
Export {
220-
file: String,
221-
},
215+
Export { file: String },
222216
}
223217

224218
pub async fn run(cli: Cli) -> Result<()> {
@@ -263,8 +257,7 @@ pub async fn run(cli: Cli) -> Result<()> {
263257
},
264258
Cmd::Logic { sub } => match sub {
265259
LogicCmd::Import { file, targets } => {
266-
const DEFAULT_LOGIC: &str =
267-
include_str!("../../../default-logic/default.rhai");
260+
const DEFAULT_LOGIC: &str = include_str!("../../../default-logic/default.rhai");
268261
let rhai = match file {
269262
Some(path) => {
270263
fs::read_to_string(&path).with_context(|| format!("read {path}"))?

crates/catcast-core/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,8 @@ thiserror = { workspace = true }
1414
chrono = { workspace = true }
1515
cron = { workspace = true }
1616
humantime = { workspace = true }
17+
18+
# Installs shared git hooks from `.cargo-husky/hooks/` into `.git/hooks/`
19+
# the first time any workspace test build runs. See `.cargo-husky/`.
20+
[dev-dependencies]
21+
cargo-husky = { version = "1", default-features = false, features = ["user-hooks"] }

crates/catstage/src/autostart.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,10 @@ mod tests {
419419
#[test]
420420
#[cfg(target_os = "macos")]
421421
fn macos_xml_escape_handles_special_chars() {
422-
assert_eq!(xml_escape("a&b<c>d\"e'f"), "a&amp;b&lt;c&gt;d&quot;e&apos;f");
422+
assert_eq!(
423+
xml_escape("a&b<c>d\"e'f"),
424+
"a&amp;b&lt;c&gt;d&quot;e&apos;f"
425+
);
423426
assert_eq!(xml_escape("plain"), "plain");
424427
}
425428
}

0 commit comments

Comments
 (0)