From 991da4d8dc2bbdd9832dd9252ebebc27d612154c Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 23 Feb 2024 10:12:54 +0000 Subject: refactor: remove confusing options, improve help from_branch and to_branch have been replaced by specifying revision ranges --- src/main.rs | 11 +++++------ src/sub_commands/push.rs | 4 +--- src/sub_commands/send.rs | 25 +++++++++---------------- 3 files changed, 15 insertions(+), 25 deletions(-) diff --git a/src/main.rs b/src/main.rs index 4c49280..d243aa4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,16 +32,15 @@ pub struct Cli { #[derive(Subcommand)] enum Commands { - /// issue a repo event as a maintainers to signal you are accepting - /// proposals via nostr + /// signal you are this repo's maintainer accepting proposals via nostr Init(sub_commands::init::SubCommandArgs), - /// issue commits on current branch as a new proposal + /// issue commits as a proposal Send(sub_commands::send::SubCommandArgs), - /// list proposals; optionally apply them as a new branch + /// list proposals; checkout, apply or donwload selected List(sub_commands::list::SubCommandArgs), - /// send new commits as proposal amendments + /// send proposal revision Push(sub_commands::push::SubCommandArgs), - /// pull latest commits in proposal linked to checked out branch + /// fetch and apply new proposal commits / revisions linked to branch Pull, /// run with --nsec flag to change npub Login(sub_commands::login::SubCommandArgs), diff --git a/src/sub_commands/push.rs b/src/sub_commands/push.rs index 75bff2d..06c3e50 100644 --- a/src/sub_commands/push.rs +++ b/src/sub_commands/push.rs @@ -106,12 +106,10 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { sub_commands::send::launch( cli_args, &sub_commands::send::SubCommandArgs { - starting_commit: String::new(), + since_or_revision_range: String::new(), in_reply_to: Some(proposal_root_event.id.to_string()), title: None, description: None, - from_branch: None, - to_branch: None, no_cover_letter: args.no_cover_letter, }, ) diff --git a/src/sub_commands/send.rs b/src/sub_commands/send.rs index 51169dc..588e7d1 100644 --- a/src/sub_commands/send.rs +++ b/src/sub_commands/send.rs @@ -24,29 +24,22 @@ use crate::{ #[derive(Debug, clap::Args)] pub struct SubCommandArgs { - #[arg(default_value = "")] - /// starting commit (commits since in current branch) or commit range, like - /// in `git format-patch` - pub(crate) starting_commit: String, + #[arg(default_value = "master..HEAD")] + /// commits to send as proposal; like in `git format-patch` + pub(crate) since_or_revision_range: String, #[clap(long)] /// nevent or event id of an existing proposal for which this is a new /// version pub(crate) in_reply_to: Option, + /// don't prompt for a cover letter + #[arg(long, action)] + pub(crate) no_cover_letter: bool, /// optional cover letter title #[clap(short, long)] pub(crate) title: Option, #[clap(short, long)] /// optional cover letter description pub(crate) description: Option, - #[clap(long)] - /// branch to get changes from (defaults to head) - pub(crate) from_branch: Option, - #[clap(long)] - /// destination branch (defaults to main or master) - pub(crate) to_branch: Option, - /// don't ask about a cover letter - #[arg(long, action)] - pub(crate) no_cover_letter: bool, } #[allow(clippy::too_many_lines)] @@ -54,9 +47,9 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { let git_repo = Repo::discover().context("cannot find a git repository")?; let mut commits: Vec = { - if args.starting_commit.is_empty() { + if args.since_or_revision_range.eq("master..HEAD") { let (from_branch, to_branch, ahead, behind) = - identify_ahead_behind(&git_repo, &args.from_branch, &args.to_branch)?; + identify_ahead_behind(&git_repo, &None, &None)?; if ahead.is_empty() { bail!(format!( @@ -94,7 +87,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { ahead } else { let ahead = git_repo - .parse_starting_commits(&args.starting_commit) + .parse_starting_commits(&args.since_or_revision_range) .context("cannot parse specified starting commit or range")?; println!("creating patch for {} commits", ahead.len(),); ahead -- cgit v1.2.3