171e8329
Default --head to HEAD for patch create and revise
a73x 2026-03-21 09:02
Make the --head flag optional on patch create and patch revise commands. When omitted, resolves to the current HEAD commit automatically. Fixes: 4609d859 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
diff --git a/src/cli.rs b/src/cli.rs index d38fde8..8760148 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -165,9 +165,9 @@ pub enum PatchCmd { /// Base branch ref #[arg(long, default_value = "main")] base: String, /// Head commit to review /// Head commit to review (defaults to HEAD) #[arg(long)] head: String, head: Option<String>, /// Issue ID this patch fixes (auto-closes on merge) #[arg(long)] fixes: Option<String>, @@ -217,9 +217,9 @@ pub enum PatchCmd { Revise { /// Patch ID (prefix match) id: String, /// New head commit /// New head commit (defaults to HEAD) #[arg(long)] head: String, head: Option<String>, /// Updated description #[arg(short, long)] body: Option<String>, diff --git a/src/lib.rs b/src/lib.rs index 5f3d67a..81bdf42 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -133,6 +133,10 @@ pub fn run(cli: cli::Cli, repo: &Repository) -> Result<(), error::Error> { head, fixes, } => { let head = match head { Some(h) => h, None => repo.head()?.peel_to_commit()?.id().to_string(), }; let id = patch::create(repo, &title, &body, &base, &head, fixes.as_deref())?; println!("Created patch {:.8}", id); Ok(()) @@ -236,6 +240,10 @@ pub fn run(cli: cli::Cli, repo: &Repository) -> Result<(), error::Error> { Ok(()) } PatchCmd::Revise { id, head, body } => { let head = match head { Some(h) => h, None => repo.head()?.peel_to_commit()?.id().to_string(), }; patch::revise(repo, &id, &head, body.as_deref())?; println!("Patch revised."); Ok(())