mirror of
https://gitlab.cern.ch/wotsubo/endcap-sl-software-ri-generator.git
synced 2025-04-25 06:06:00 +09:00
refactor(XmlGitInfo): improve error msg
This commit is contained in:
parent
d6ee19e000
commit
42efcc7cf6
1 changed files with 6 additions and 6 deletions
12
src/io.rs
12
src/io.rs
|
@ -13,7 +13,7 @@ const ENVVAR_XML_GIT_SHA: &str = "XML_GIT_SHA";
|
|||
#[derive(Debug, Error)]
|
||||
pub enum XmlGitInfoError {
|
||||
#[error("io error while getting xml git info: {msg} {source}")]
|
||||
IOError {
|
||||
GitCommandSpawnError {
|
||||
msg: &'static str,
|
||||
#[source]
|
||||
source: io::Error,
|
||||
|
@ -25,8 +25,8 @@ pub enum XmlGitInfoError {
|
|||
}
|
||||
|
||||
impl XmlGitInfoError {
|
||||
fn io_error(e: io::Error, msg: &'static str) -> Self {
|
||||
XmlGitInfoError::IOError { msg, source: e }
|
||||
fn git_command_spawn_error(e: io::Error, msg: &'static str) -> Self {
|
||||
XmlGitInfoError::GitCommandSpawnError { msg, source: e }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ pub(crate) fn get_xml_gitinfo(xml_path: &path::Path) -> Result<XmlGitInfo, XmlGi
|
|||
.args(["describe", "--always", "--dirty"])
|
||||
.current_dir(xml_path.parent().unwrap())
|
||||
.output()
|
||||
.map_err(|e| XmlGitInfoError::io_error(e, "git describe"))?;
|
||||
.map_err(|e| XmlGitInfoError::git_command_spawn_error(e, "git describe"))?;
|
||||
let describe = if out_describe.status.success() {
|
||||
String::from_utf8_lossy(&out_describe.stdout)
|
||||
.trim()
|
||||
|
@ -71,7 +71,7 @@ pub(crate) fn get_xml_gitinfo(xml_path: &path::Path) -> Result<XmlGitInfo, XmlGi
|
|||
.args(["log", "-1", "--pretty=format:'%cI'"])
|
||||
.current_dir(xml_path.parent().unwrap())
|
||||
.output()
|
||||
.map_err(|e| XmlGitInfoError::io_error(e, "git log (timestamp)"))?;
|
||||
.map_err(|e| XmlGitInfoError::git_command_spawn_error(e, "git log (timestamp)"))?;
|
||||
let timestamp = if timestamp_out.status.success() {
|
||||
String::from_utf8_lossy(×tamp_out.stdout)
|
||||
.trim()
|
||||
|
@ -98,7 +98,7 @@ pub(crate) fn get_xml_gitinfo(xml_path: &path::Path) -> Result<XmlGitInfo, XmlGi
|
|||
.args(["rev-parse", "HEAD"])
|
||||
.current_dir(xml_path.parent().unwrap())
|
||||
.output()
|
||||
.map_err(|e| XmlGitInfoError::io_error(e, "git rev-parse (sha)"))?;
|
||||
.map_err(|e| XmlGitInfoError::git_command_spawn_error(e, "git rev-parse (sha)"))?;
|
||||
let git_sha = if sha.status.success() {
|
||||
String::from_utf8_lossy(&sha.stdout).trim().to_owned()
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue