Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

chore(tooling): enforce automated cargo fmt via git pre-commit and pre-push hooks

IGECTf6de76869737
diff --git a/.githooks/pre-commit b/.githooks/pre-commit
new file mode 100644
index 00000000..f1da08e7
--- /dev/null
+++ b/.githooks/pre-commit
@@ -0,0 +1,15 @@
+#!/usr/bin/env bash
+set -e
+
+# Detect staged Rust files
+STAGED_RS=$(git diff --cached --name-only --diff-filter=ACM | grep '\.rs$' || true)
+
+if [ -n "$STAGED_RS" ]; then
+ echo "==> Auto-formatting staged Rust files with cargo fmt..."
+ cargo fmt --manifest-path src-tauri/Cargo.toml --all
+ for file in $STAGED_RS; do
+ if [ -f "$file" ]; then
+ git add "$file"
+ fi
+ done
+fi
diff --git a/.githooks/pre-push b/.githooks/pre-push
new file mode 100644
index 00000000..9aad2f73
--- /dev/null
+++ b/.githooks/pre-push
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+set -e
+
+echo "==> Verifying Rust formatting before push..."
+if ! cargo fmt --manifest-path src-tauri/Cargo.toml --all -- --check > /dev/null 2>&1; then
+ echo "ERROR: Unformatted Rust code detected!"
+ echo "Run: cargo fmt --manifest-path src-tauri/Cargo.toml --all"
+ exit 1
+fi
+echo "==> Rust formatting check passed."
diff --git a/AGENTS.md b/AGENTS.md
index 5728515b..47130a0b 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -80,6 +80,7 @@ Welcome to LibreGet. This file serves as the definitive reference and operating
### Local Pre-Commit Verification
Before pushing to `dev`:
+- `pnpm fmt:rs` : Auto-formats Rust workspace (`cargo fmt`) — enforced automatically via `.githooks/pre-commit` and `.githooks/pre-push`.
- `pnpm test` : Runs full Vitest suite (must pass 100%).
- `node scripts/e2e_verify.mjs` : Validates documentation suite routes, links, and accessibility.
- `pnpm lint:ui <target>` : Required whenever modifying Svelte routes, UI components, stylesheets, `index.html`, or `docs/` — see [.agents/skills/ui-lint/SKILL.md](.agents/skills/ui-lint/SKILL.md).
diff --git a/package.json b/package.json
index 2c10065f..6b46a560 100644
--- a/package.json
+++ b/package.json
@@ -23,6 +23,9 @@
"extension:sync": "node browser-extension/sync.mjs",
"clean:cargo": "cargo sweep -t 3 -r src-tauri",
"clean:cargo:all": "cargo sweep -s -r src-tauri",
+ "fmt:rs": "cargo fmt --manifest-path src-tauri/Cargo.toml --all",
+ "check:fmt": "cargo fmt --manifest-path src-tauri/Cargo.toml --all -- --check",
+ "prepare": "git config core.hooksPath .githooks 2>/dev/null || true",
"test": "vitest run",
"test:watch": "vitest"
},