summaryrefslogtreecommitdiff
path: root/src/bin/pre-commit.rs
diff options
context:
space:
mode:
authorJustin Worthe <justin@worthe-it.co.za>2017-08-22 21:38:36 +0200
committerJustin Worthe <justin@worthe-it.co.za>2017-08-22 21:38:36 +0200
commit0c1e6e18373fde9407ccf287757f1d221469e6d1 (patch)
treee7d1c0a2e57c13bdacab30f682a4bea26f5cc0ab /src/bin/pre-commit.rs
parentce7cc08eeb78ebec41a1a29a18ba80c272d2f0eb (diff)
master: Added git hook for running cargo before commits
Diffstat (limited to 'src/bin/pre-commit.rs')
-rw-r--r--src/bin/pre-commit.rs24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/bin/pre-commit.rs b/src/bin/pre-commit.rs
index 7b52443..361dd9c 100644
--- a/src/bin/pre-commit.rs
+++ b/src/bin/pre-commit.rs
@@ -1,14 +1,20 @@
+extern crate rust_git_hooks;
+use rust_git_hooks::*;
+
use std::env;
use std::io::{stdin, BufRead};
+use std::process;
+use std::process::{Command, Stdio};
fn main() {
- let args: Vec<_> = env::args().skip(1).collect();
- println!("pre-commit called with {:?}", args);
-
- println!("BEGIN STDIN for pre-commit");
- let stdin = stdin();
- for line in stdin.lock().lines() {
- println!("{:?}", line);
- }
- println!("END STDIN");
+ log();
+
+ let command = Command::new("cargo")
+ .arg("test")
+ .stdout(Stdio::inherit())
+ .stderr(Stdio::inherit())
+ .output()
+ .expect("failed to execute process");
+
+ process::exit(command.status.code().unwrap_or(0));
}