mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 16:21:33 +11:00
Use .output() instead
This commit is contained in:
parent
75cd2cd0e1
commit
9af8b19859
|
@ -1,4 +1,4 @@
|
||||||
use std::{io::Read, path::Path, process::Command};
|
use std::{path::Path, process::Command};
|
||||||
|
|
||||||
use crate::utils::find_agb_root_directory;
|
use crate::utils::find_agb_root_directory;
|
||||||
|
|
||||||
|
@ -48,22 +48,16 @@ fn execute_git_command(root_directory: &Path, args: &[&str]) -> Result<String, E
|
||||||
let git_cmd = Command::new("git")
|
let git_cmd = Command::new("git")
|
||||||
.args(args)
|
.args(args)
|
||||||
.current_dir(root_directory)
|
.current_dir(root_directory)
|
||||||
.spawn()
|
.output()
|
||||||
.map_err(|_| Error::GitError)?;
|
.map_err(|_| Error::GitError("Failed to run command"))?;
|
||||||
let mut buf = Vec::new();
|
|
||||||
git_cmd
|
|
||||||
.stdout
|
|
||||||
.ok_or(Error::GitError)?
|
|
||||||
.read_to_end(&mut buf)
|
|
||||||
.map_err(|_| Error::GitError)?;
|
|
||||||
|
|
||||||
String::from_utf8(buf).map_err(|_| Error::GitError)
|
String::from_utf8(git_cmd.stdout).map_err(|_| Error::GitError("Output not utf-8"))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
FindRootDirectory,
|
FindRootDirectory,
|
||||||
GitError,
|
GitError(&'static str),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
|
Loading…
Reference in a new issue