aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/pre_commit.rs
diff options
context:
space:
mode:
Diffstat (limited to 'xtask/src/pre_commit.rs')
-rw-r--r--xtask/src/pre_commit.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/xtask/src/pre_commit.rs b/xtask/src/pre_commit.rs
index 056f34acf..8f2dbea19 100644
--- a/xtask/src/pre_commit.rs
+++ b/xtask/src/pre_commit.rs
@@ -3,19 +3,21 @@
3use std::{fs, path::PathBuf}; 3use std::{fs, path::PathBuf};
4 4
5use anyhow::{bail, Result}; 5use anyhow::{bail, Result};
6use xshell::cmd;
6 7
7use crate::{not_bash::run, project_root, run_rustfmt, Mode}; 8use crate::{project_root, run_rustfmt, Mode};
8 9
9// FIXME: if there are changed `.ts` files, also reformat TypeScript (by 10// FIXME: if there are changed `.ts` files, also reformat TypeScript (by
10// shelling out to `npm fmt`). 11// shelling out to `npm fmt`).
11pub fn run_hook() -> Result<()> { 12pub fn run_hook() -> Result<()> {
12 run_rustfmt(Mode::Overwrite)?; 13 run_rustfmt(Mode::Overwrite)?;
13 14
14 let diff = run!("git diff --diff-filter=MAR --name-only --cached")?; 15 let diff = cmd!("git diff --diff-filter=MAR --name-only --cached").read()?;
15 16
16 let root = project_root(); 17 let root = project_root();
17 for line in diff.lines() { 18 for line in diff.lines() {
18 run!("git update-index --add {}", root.join(line).display())?; 19 let file = root.join(line);
20 cmd!("git update-index --add {file}").run()?;
19 } 21 }
20 22
21 Ok(()) 23 Ok(())