diff --git a/src/main.rs b/src/main.rs index 9956a32..7962cd7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,6 +6,7 @@ mod sign; mod utils; mod verify; +use std::borrow::Cow; use std::path::PathBuf; use anyhow::Result; @@ -52,12 +53,12 @@ enum Action { /// Push signify data to a remote repository Push { /// The name of the remote repository - remote: String, + remote: Option>, }, /// Pull signify data from a remote repository Pull { /// The name of the remote repository - remote: String, + remote: Option>, }, } @@ -109,7 +110,7 @@ fn main() -> Result<()> { public_key, git_rev: rev, } => verify::command(public_key, rev), - Action::Push { remote } => push::command(remote), - Action::Pull { remote } => pull::command(remote), + Action::Push { remote } => push::command(&remote.unwrap_or(Cow::Borrowed("origin"))), + Action::Pull { remote } => pull::command(&remote.unwrap_or(Cow::Borrowed("origin"))), } } diff --git a/src/pull.rs b/src/pull.rs index 3956c16..77e20f2 100644 --- a/src/pull.rs +++ b/src/pull.rs @@ -7,7 +7,7 @@ use anyhow::{anyhow, Context, Result}; use crate::utils::ALL_SIGNIFY_REFS; /// Execute the `pull` command. -pub fn command(remote: String) -> Result<()> { +pub fn command(remote: &str) -> Result<()> { let exit_code = Command::new("git") .arg("fetch") .arg(remote) diff --git a/src/push.rs b/src/push.rs index d0cb8d7..65855fc 100644 --- a/src/push.rs +++ b/src/push.rs @@ -7,7 +7,7 @@ use anyhow::{anyhow, Context, Result}; use crate::utils::ALL_SIGNIFY_REFS; /// Execute the `push` command. -pub fn command(remote: String) -> Result<()> { +pub fn command(remote: &str) -> Result<()> { let exit_code = Command::new("git") .arg("push") .arg(remote)