aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-04-10 15:09:32 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-04-10 15:09:32 +0300
commitd96962adf6238b8c168df93315b7c8ef784415dd (patch)
tree9ebfbbd8c84d4a42a331dc3e45a393aa8f21b9c4
parentf5282d9ad28af32c11db1e13a485878225fcd9bf (diff)
chore: add pre-commit fmt hook
-rwxr-xr-x.githooks/pre-commit8
-rw-r--r--CONTRIBUTING.md8
-rw-r--r--justfile6
-rw-r--r--tests/cli_wrapper.rs18
4 files changed, 37 insertions, 3 deletions
diff --git a/.githooks/pre-commit b/.githooks/pre-commit
new file mode 100755
index 00000000..249d41f7
--- /dev/null
+++ b/.githooks/pre-commit
@@ -0,0 +1,8 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+repo_root="$(git rev-parse --show-toplevel)"
+cd "$repo_root"
+
+echo "pre-commit: running cargo fmt --check"
+cargo fmt --check
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 5a4784d5..42a08593 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -48,6 +48,14 @@ If you plan to implement the change yourself, say that directly in the issue and
## Before submitting a PR
+Install the repo hook once in your clone.
+
+```bash
+just install-hooks
+```
+
+The pre-commit hook runs `cargo fmt --check` before every commit.
+
Run the PR checks and make sure they pass.
```bash
diff --git a/justfile b/justfile
index 4dd729c4..3232568b 100644
--- a/justfile
+++ b/justfile
@@ -14,6 +14,12 @@ ci:
check: ci
python3 -m unittest scripts.test_changelog scripts.test_vendor_libghostty_vt
+# Install repo-local git hooks
+install-hooks:
+ git config core.hooksPath .githooks
+ chmod +x .githooks/pre-commit
+ @echo "installed git hooks from .githooks"
+
# Build release binary
build:
cargo build --release
diff --git a/tests/cli_wrapper.rs b/tests/cli_wrapper.rs
index 9da11061..8c8574d3 100644
--- a/tests/cli_wrapper.rs
+++ b/tests/cli_wrapper.rs
@@ -396,8 +396,17 @@ fn pane_close_only_removes_the_target_tab_when_other_tabs_exist() {
let workspaces = run_cli(&socket_path, &["workspace", "list"]);
assert!(workspaces.status.success());
let workspaces_json: serde_json::Value = serde_json::from_slice(&workspaces.stdout).unwrap();
- assert_eq!(workspaces_json["result"]["workspaces"].as_array().unwrap().len(), 1);
- assert_eq!(workspaces_json["result"]["workspaces"][0]["workspace_id"], workspace_id);
+ assert_eq!(
+ workspaces_json["result"]["workspaces"]
+ .as_array()
+ .unwrap()
+ .len(),
+ 1
+ );
+ assert_eq!(
+ workspaces_json["result"]["workspaces"][0]["workspace_id"],
+ workspace_id
+ );
let tabs = run_cli(&socket_path, &["tab", "list", "--workspace", &workspace_id]);
assert!(tabs.status.success());
@@ -436,7 +445,10 @@ fn pane_close_removes_the_workspace_when_it_closes_the_last_pane() {
let workspaces = run_cli(&socket_path, &["workspace", "list"]);
assert!(workspaces.status.success());
let workspaces_json: serde_json::Value = serde_json::from_slice(&workspaces.stdout).unwrap();
- assert!(workspaces_json["result"]["workspaces"].as_array().unwrap().is_empty());
+ assert!(workspaces_json["result"]["workspaces"]
+ .as_array()
+ .unwrap()
+ .is_empty());
cleanup_spawned_herdr(herdr, base);
}