Skip to content

Instantly share code, notes, and snippets.

@chadaustin
Created November 19, 2019 01:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chadaustin/113198fd51ddcd92bad25af5ea1d2c67 to your computer and use it in GitHub Desktop.
Save chadaustin/113198fd51ddcd92bad25af5ea1d2c67 to your computer and use it in GitHub Desktop.
#!/usr/bin/env run-cargo-script
//! ```cargo
//! [dependencies]
//! ```
use std::process::Command;
fn main() -> std::io::Result<()> {
let mut path = std::env::current_dir()?;
loop {
let mut hg = path.clone();
hg.push(".hg");
if hg.is_dir() {
std::process::exit(Command::new("hg").arg("status").spawn()?.wait()?.code().unwrap());
}
let mut git = path.clone();
git.push(".git");
if git.is_dir() {
std::process::exit(Command::new("git").arg("status").spawn()?.wait()?.code().unwrap());
}
if !path.pop() {
eprintln!("not inside a checkout");
std::process::exit(1);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment