{"id":19146268,"url":"https://github.com/01walid/sloughi","last_synced_at":"2025-10-25T04:32:41.045Z","repository":{"id":57667699,"uuid":"474715619","full_name":"01walid/sloughi","owner":"01walid","description":"Shareable git hooks for Rust project. Sloughi is a friend of Husky from North Africa! :algeria:","archived":false,"fork":false,"pushed_at":"2022-03-28T04:59:59.000Z","size":15,"stargazers_count":29,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-18T04:56:50.998Z","etag":null,"topics":["cargo","git","hooks","husky","precommit","rust","workflow"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/01walid.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-27T17:52:53.000Z","updated_at":"2024-12-03T11:01:44.000Z","dependencies_parsed_at":"2022-09-26T20:31:59.193Z","dependency_job_id":null,"html_url":"https://github.com/01walid/sloughi","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/01walid/sloughi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/01walid%2Fsloughi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/01walid%2Fsloughi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/01walid%2Fsloughi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/01walid%2Fsloughi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/01walid","download_url":"https://codeload.github.com/01walid/sloughi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/01walid%2Fsloughi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280901444,"owners_count":26410586,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-25T02:00:06.499Z","response_time":81,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cargo","git","hooks","husky","precommit","rust","workflow"],"created_at":"2024-11-09T07:43:43.357Z","updated_at":"2025-10-25T04:32:41.006Z","avatar_url":"https://github.com/01walid.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sloughi\n[![Crates.io](https://img.shields.io/crates/v/sloughi?color=green)](https://crates.io/crates/sloughi)\n![Crates.io](https://img.shields.io/crates/l/sloughi)\n![Crates.io](https://img.shields.io/crates/d/sloughi?color=green)\n\n\u003cimg align=\"right\" width=\"180\" alt=\"Sloughi Dog\" src=\"https://user-images.githubusercontent.com/983020/160320457-6dbdd901-01c4-4cd0-8d3c-c758cb4f615b.jpeg\" /\u003e\n\nA tiny crate to make it easy to share and apply Git hooks for Rust projects. Inspired by [Husky](https://github.com/typicode/husky).\n- Zero dependencies.\n- No magic, uses Git's `config core.hooksPath` to set a custom hooks path. Use native/regular shell scripts for git hooks.\n- Makes use of [Cargo's build script](https://doc.rust-lang.org/cargo/reference/build-scripts.html).\n- IDE/Code editor agnostic.\n- Customizable setup.\n\n[Sloughi](https://en.wikipedia.org/wiki/Sloughi) is an ancient breed of domesticated dog originating from North Africa (i.e. Algeria, where I live 👋).\n\n# Install \n- Add sloughi to your `build-dependencies` (not `dev-dependencies`):\n\n  ```toml\n  [build-dependencies]\n  sloughi = \"0.3.0\"\n  ```\n- Create a `build.rs` file at the root of your project to install Sloughi (besides `Cargo.toml`, not inside `src/`):\n\n  ```rust\n  use sloughi::Sloughi;\n\n  fn main() {\n      let _ = Sloughi::new().install(); // This will fail silently. Won't interrupt the build.\n  }\n  ```\nThat's it!\n\nThe next time `cargo build` is triggered (by VSCode, or by running `cargo run`/`cargo test`), you will notice a `.sloughi` folder is created with a sample `pre-commit` hook inside. \n\n## Customizing the install\nThis crate uses the builder pattern, you can chain options on top `::new()` to adjust the install:\n```rust\nlet _ = Sloughi::new()\n    .custom_path(\".git_hooks\").   // Choose a custom Git hooks relative path (default is \".sloughi\")\n    .ignore_env(\"CI\").            // Ignore setup when `CI` environment variable is set (like in CircleCI ..etc)\n    .ignore_env(\"GITHUB_ACTIONS\") // Do not run in Github Actions as well\n    .install();\n```\n\n### Fail the build\nThe above snippets for `build.rs` will not interrupt the build in case Sloughi install failed (e.g. not a git repo, permission error ..etc). It's explicitly silenced with `let _ =`, you can handle the error however you like, or just yell with:\n\n```rust\nSloughi::new().install().expect(\"Sloughi install failed\");\n```\n\n# F.A.Q\n\n### Why use `build.rs`? \nCargo lacks install hooks (like `postinstall` in npm's `package.json`), this makes it challenging to have a way to share git hooks automatically in a upstream repository.\n\nCargo's build script is a nice \u0026 transparent way to:\n- Act on the project at build/compile time.\n- Customize the setup without extra config files and formats.\n\n### What happens when cargo build is run multiple times?\n\nThe `install()` call is [idempotent](https://en.wikipedia.org/wiki/Idempotence). It won't modify the existing setup and hooks.\n\n### Will this slow down my builds? \nNo:\n- `build.rs` itself is only built when it's changed (by default).\n- The setup will first check if you already have `.sloughi` (or the custom path) created. If so, it skips installs.\n\n### Does it run in release mode? \nNo, release mode is a no-op.\n\n\n# TODO:\n- [ ] Optional feature flags. I.e. conventional commits as pre-commit, rustfmt as pre-commit. \n- [ ] A [optiona] companion binary to manage hooks. \n- [ ] Check Cargo workspaces compatiblity. \n- [ ] Introduce the `uninstall()` call to the exported `Sloughi` struct.\n- [ ] Integration tests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F01walid%2Fsloughi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F01walid%2Fsloughi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F01walid%2Fsloughi/lists"}