mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 03:21:08 +03:00
Automatic setting up git hooks for the project: rustfmt, etc. (#1380)
Also update document for this change on pre-commit hook config
This commit is contained in:
parent
b74e0fbc1f
commit
b4c2a9d1b2
2 changed files with 29 additions and 4 deletions
|
@ -37,11 +37,16 @@ There is a basic git [pre-commit](../.hooks/pre-commit) hook in the repo.
|
||||||
The pre-commit hook will not prevent commits if style issues are present but it will
|
The pre-commit hook will not prevent commits if style issues are present but it will
|
||||||
indicate any files that need formatting.
|
indicate any files that need formatting.
|
||||||
|
|
||||||
To enable this, create a symlink in `.git/hooks` (note the relative path) -
|
This pre-commit hook will be **automatically** configured in this project, once you run `cargo build` for the 1st time.
|
||||||
|
|
||||||
|
Or you can config it manually with the following command without building, and check it:
|
||||||
```
|
```
|
||||||
cd .git/hooks
|
git config core.hooksPath ./.hooks
|
||||||
ln -s -f ../../.hooks/pre-commit
|
git config --list | grep hook
|
||||||
|
```
|
||||||
|
The output will be:
|
||||||
|
```
|
||||||
|
core.hookspath=./.hooks
|
||||||
```
|
```
|
||||||
|
|
||||||
## Running rustfmt
|
## Running rustfmt
|
||||||
|
|
|
@ -25,11 +25,31 @@ use std::fs::{self, File};
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::path::{self, Path, PathBuf};
|
use std::path::{self, Path, PathBuf};
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
use tar::Archive;
|
use tar::Archive;
|
||||||
|
|
||||||
const WEB_WALLET_TAG: &str = "0.3.0.1";
|
const WEB_WALLET_TAG: &str = "0.3.0.1";
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
// Setting up git hooks in the project: rustfmt and so on.
|
||||||
|
let git_hooks = format!(
|
||||||
|
"git config core.hooksPath {}",
|
||||||
|
PathBuf::from("./.hooks").to_str().unwrap()
|
||||||
|
);
|
||||||
|
|
||||||
|
if cfg!(target_os = "windows") {
|
||||||
|
Command::new("cmd")
|
||||||
|
.args(&["/C", &git_hooks])
|
||||||
|
.output()
|
||||||
|
.expect("failed to execute git config for hooks");
|
||||||
|
} else {
|
||||||
|
Command::new("sh")
|
||||||
|
.args(&["-c", &git_hooks])
|
||||||
|
.output()
|
||||||
|
.expect("failed to execute git config for hooks");
|
||||||
|
}
|
||||||
|
|
||||||
// build and versioning information
|
// build and versioning information
|
||||||
let mut opts = built::Options::default();
|
let mut opts = built::Options::default();
|
||||||
opts.set_dependencies(true);
|
opts.set_dependencies(true);
|
||||||
|
|
Loading…
Reference in a new issue