hive-forge: move pr create --remote's origin default onto the clap arg
Puts the default on #[arg(long, default_value = "origin")] instead of
duplicating unwrap_or("origin") at both call sites (REST/--push path
and agit_create). clap now renders the default in --help itself, so
the hand-written doc-comment default is dropped in favor of it.
Regenerated docs/tools/forge-cli.md to match.
This commit is contained in:
parent
18f0199566
commit
15424d3e49
2 changed files with 8 additions and 6 deletions
|
|
@ -56,9 +56,9 @@ pub struct Args {
|
|||
/// Push the local `--head` branch to `--remote` before creating the PR.
|
||||
#[arg(long)]
|
||||
push: bool,
|
||||
/// Remote to push to (default: `origin`).
|
||||
#[arg(long)]
|
||||
remote: Option<String>,
|
||||
/// Remote to push to.
|
||||
#[arg(long, default_value = "origin")]
|
||||
remote: String,
|
||||
/// Open the PR via Forgejo's `AGit` flow instead of pushing a branch —
|
||||
/// works for read-only collaborators. Run from inside a cloned repo.
|
||||
#[arg(long)]
|
||||
|
|
@ -98,7 +98,7 @@ pub fn run(client: &Client, args: Args) -> Result<()> {
|
|||
.head
|
||||
.as_deref()
|
||||
.expect("clap requires --head unless --agit");
|
||||
let remote = args.remote.as_deref().unwrap_or("origin");
|
||||
let remote = args.remote.as_str();
|
||||
if args.push {
|
||||
push_branch(remote, head)?;
|
||||
}
|
||||
|
|
@ -149,7 +149,7 @@ pub fn run(client: &Client, args: Args) -> Result<()> {
|
|||
/// PATCH, mirroring the manual `pr create --title …` + `issue edit
|
||||
/// --body-file` two-step.
|
||||
fn agit_create(client: &Client, args: &Args, body: &str) -> Result<()> {
|
||||
let remote = args.remote.as_deref().unwrap_or("origin");
|
||||
let remote = args.remote.as_str();
|
||||
let topic = match &args.topic {
|
||||
Some(t) => t.clone(),
|
||||
None => current_branch().unwrap_or_else(|| "contribution".to_owned()),
|
||||
|
|
|
|||
Loading…
Reference in a new issue