-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds the `install-git-hooks` to `cross-dev`, which installs pre-commit hooks to ensure clippy and fmt are run on all commits.
- Loading branch information
1 parent
cf582ce
commit a18f979
Showing
4 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use clap::Args; | ||
|
||
use std::path::Path; | ||
|
||
#[derive(Args, Debug)] | ||
pub struct InstallGitHooks { | ||
/// Provide verbose diagnostic output. | ||
#[clap(short, long)] | ||
verbose: bool, | ||
} | ||
|
||
pub fn install_git_hooks(InstallGitHooks { verbose }: InstallGitHooks) -> cross::Result<()> { | ||
let metadata = cross::cargo_metadata_with_args( | ||
Some(Path::new(env!("CARGO_MANIFEST_DIR"))), | ||
None, | ||
verbose, | ||
)? | ||
.ok_or_else(|| eyre::eyre!("could not find cross workspace and its current version"))?; | ||
let git_hooks = metadata.workspace_root.join(".git").join("hooks"); | ||
let cross_dev = metadata.workspace_root.join("xtask").join("src"); | ||
std::fs::copy(cross_dev.join("pre-commit"), git_hooks.join("pre-commit"))?; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/env bash | ||
|
||
echo "Running rustfmt and clippy checks." | ||
|
||
set -ex | ||
|
||
cargo fmt -- --check | ||
cargo clippy --all-features -- --deny warnings | ||
if cargo +nightly >/dev/null 2>&1; then | ||
cargo +nightly clippy --all-features -- --deny warnings | ||
fi |