From 61bf3d45427acaa6f5d8d31ab72c7232104f36fe Mon Sep 17 00:00:00 2001 From: Quentin Boyer Date: Tue, 30 Apr 2024 17:53:53 +0200 Subject: [PATCH] Use the current branch by default for send --- src/main.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8e9898a..b532bff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -66,8 +66,8 @@ struct Send { help = "Version of the patchset to set. Defaults to the latest version" )] version: Option, - #[arg(help = "Patch series to send")] - series: String, + #[arg(help = "Patch series to send. Defaults to the current branch")] + series: Option, } #[derive(Args, Debug)] @@ -522,11 +522,17 @@ fn main() -> Result<()> { Ok(()) } Command::Send(send) => { - let branch_dir = patch_dir.join(&send.series); + let current_branch = git_cd(&["branch", "--show-current"])?; + let branch = send + .series + .as_ref() + .try_m_unwrap_or_else(|| Ok(¤t_branch))?; + + let branch_dir = patch_dir.join(&branch); let version = match send.version { Some(v) => v, None => match latest_version(&branch_dir)? { - None => return Err(miette!("No patch set for the branch {}", send.series)), + None => return Err(miette!("No patch set for the branch {branch}")), Some(v) => v, }, };