2019-01-27 02:03:52 +03:00
|
|
|
use std::process::Command;
|
2018-12-09 12:27:13 +00:00
|
|
|
|
2019-06-11 01:47:37 +03:00
|
|
|
use ra_tools::{Result, run_rustfmt, run, project_root, Overwrite};
|
2019-01-27 02:03:52 +03:00
|
|
|
|
2019-06-11 01:47:37 +03:00
|
|
|
fn main() -> Result<()> {
|
|
|
|
|
run_rustfmt(Overwrite)?;
|
2018-12-09 12:27:13 +00:00
|
|
|
update_staged()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn update_staged() -> Result<()> {
|
|
|
|
|
let root = project_root();
|
|
|
|
|
let output = Command::new("git")
|
|
|
|
|
.arg("diff")
|
2018-12-20 16:45:54 +00:00
|
|
|
.arg("--diff-filter=MAR")
|
2018-12-09 12:27:13 +00:00
|
|
|
.arg("--name-only")
|
|
|
|
|
.arg("--cached")
|
|
|
|
|
.current_dir(&root)
|
|
|
|
|
.output()?;
|
|
|
|
|
if !output.status.success() {
|
2019-06-16 00:48:50 +06:00
|
|
|
Err(format!(
|
|
|
|
|
"`git diff --diff-filter=MAR --name-only --cached` exited with {}",
|
|
|
|
|
output.status
|
|
|
|
|
))?;
|
2018-12-09 12:27:13 +00:00
|
|
|
}
|
|
|
|
|
for line in String::from_utf8(output.stdout)?.lines() {
|
2019-02-08 14:49:43 +03:00
|
|
|
run(&format!("git update-index --add {}", root.join(line).to_string_lossy()), ".")?;
|
2018-12-09 12:27:13 +00:00
|
|
|
}
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|