Implementation of new_from_stdin() moved inside of main.rs, new_from_stdin() deleted

This commit is contained in:
mulla028 2024-11-25 18:15:41 -05:00
parent 05949aa378
commit 002f77b3d7

View file

@ -1,5 +1,4 @@
use crate::error::LumenError;
use std::io::Read;
use std::process::Command;
use thiserror::Error;
@ -36,18 +35,6 @@ impl Commit {
})
}
pub fn new_from_stdin() -> Result<Self, LumenError> {
let mut buffer = String::new();
std::io::stdin()
.read_to_string(&mut buffer)
.map_err(LumenError::from)?;
eprintln!("Reading commit SHA from stdin: '{}'", buffer.trim());
// Assuming you want to create the commit based on the SHA read from stdin
Commit::new(buffer.trim().to_string())
}
pub fn is_valid_commit(sha: &str) -> Result<(), LumenError> {
let output = Command::new("git").args(["cat-file", "-t", sha]).output()?;
let output_str = String::from_utf8(output.stdout)?;