diff options
author | Lars Wirzenius <liw@liw.fi> | 2023-01-07 10:19:17 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2023-01-07 10:19:17 +0200 |
commit | 9edd0af9798215e4459e63862e777218cda72681 (patch) | |
tree | a4d5c7191bb21347e7df838c06f6eb8382087069 | |
parent | be9a2e89e4ed353f666816cd798e3bc06af613f7 (diff) | |
download | riki-9edd0af9798215e4459e63862e777218cda72681.tar.gz |
refactor: move GitInvoke, GitError into src/git.rs
Sponsored-by: author
-rw-r--r-- | src/error.rs | 6 | ||||
-rw-r--r-- | src/git.rs | 12 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/error.rs b/src/error.rs index 50c1ba3..2f3bc91 100644 --- a/src/error.rs +++ b/src/error.rs @@ -45,12 +45,6 @@ pub enum SiteError { #[error("link to missing page {1} on {0}")] PageMissing(PathBuf, PathBuf), - #[error("faileed to invoked git with subcommand {0} in {1}")] - GitInvoke(String, PathBuf, #[source] std::io::Error), - - #[error("git {0} in in {1}:\n{2}")] - GitError(String, PathBuf, String), - #[error("failed to parse date: {0:?}")] UnknownTimestamp(String), @@ -9,20 +9,26 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH}; pub enum GitError { #[error("failed to parse Unix timetamp: {0}")] ParseUnixTimestamp(String, #[source] std::num::ParseIntError), + + #[error("faileed to invoked git with subcommand {0} in {1}")] + GitInvoke(String, PathBuf, #[source] std::io::Error), + + #[error("git {0} in in {1}:\n{2}")] + GitError(String, PathBuf, String), } -pub fn git(args: &[&str], cwd: &Path) -> Result<String, SiteError> { +pub fn git(args: &[&str], cwd: &Path) -> Result<String, GitError> { assert!(!args.is_empty()); let output = Command::new("git") .args(args) .current_dir(cwd) .output() - .map_err(|e| SiteError::GitInvoke(args[0].into(), cwd.into(), e))?; + .map_err(|e| GitError::GitInvoke(args[0].into(), cwd.into(), e))?; if output.status.success() { Ok(String::from_utf8_lossy(&output.stdout).into()) } else { let stderr = String::from_utf8_lossy(&output.stderr).into(); - Err(SiteError::GitError(args[0].into(), cwd.into(), stderr)) + Err(GitError::GitError(args[0].into(), cwd.into(), stderr)) } } |