Replace Cmd with not-bash

This commit is contained in:
Aleksey Kladov 2020-02-14 15:59:19 +01:00
parent bd3a41cc33
commit ce29497e43
5 changed files with 173 additions and 156 deletions

View file

@ -4,18 +4,18 @@ use std::{fs, path::PathBuf};
use anyhow::{bail, Result};
use crate::{cmd::run_with_output, project_root, run, run_rustfmt, Mode};
use crate::{not_bash::run, project_root, run_rustfmt, Mode};
// FIXME: if there are changed `.ts` files, also reformat TypeScript (by
// shelling out to `npm fmt`).
pub fn run_hook() -> Result<()> {
run_rustfmt(Mode::Overwrite)?;
let diff = run_with_output("git diff --diff-filter=MAR --name-only --cached", ".")?;
let diff = run!("git diff --diff-filter=MAR --name-only --cached")?;
let root = project_root();
for line in diff.lines() {
run(&format!("git update-index --add {}", root.join(line).to_string_lossy()), ".")?;
run!("git update-index --add {}", root.join(line).display())?;
}
Ok(())