MCPcopy Create free account
hub / github.com/alt-art/commit / pre_commit_check

Function pre_commit_check

src/commit.rs:61–89  ·  view source on GitHub ↗
(pre_commit_command: Option<String>, message: &str)

Source from the content-addressed store, hash-verified

59}
60
61pub fn pre_commit_check(pre_commit_command: Option<String>, message: &str) -> Result<()> {
62 if let Some(command) = pre_commit_command {
63 println!("Running pre-commit command...");
64 let mut process = Command::new(command)
65 .env("MSG", message)
66 .stdout(Stdio::piped())
67 .stderr(Stdio::piped())
68 .spawn()?;
69 let stdout = process.stdout.take().expect("Unable to get stdout");
70 let stderr = process.stderr.take().expect("Unable to get stderr");
71 thread::spawn(move || {
72 let lines = BufReader::new(stdout).lines();
73 for line in lines {
74 println!("{}", line.expect("Unable to get line"));
75 }
76 });
77 thread::spawn(move || {
78 let lines = BufReader::new(stderr).lines();
79 for line in lines {
80 eprintln!("{}", line.expect("Unable to get line"));
81 }
82 });
83 let status = process.wait()?;
84 if !status.success() {
85 return Err(anyhow!("Pre-commit command failed with {}", status));
86 }
87 }
88 Ok(())
89}
90
91pub fn git_add_all_modified() -> Result<()> {
92 let output = git_exec(&["add", "-u"])?;

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected