upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/sub_commands/send.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-02-23 10:12:54 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2024-02-23 10:12:54 +0000
commit991da4d8dc2bbdd9832dd9252ebebc27d612154c (patch)
tree5d7bc1fd4975c7f50c6088bd7f2f74bcee37ec11 /src/sub_commands/send.rs
parentb931b37e26486e4e6d15f302e87141dcf2f596ba (diff)
refactor: remove confusing options, improve help
from_branch and to_branch have been replaced by specifying revision ranges
Diffstat (limited to 'src/sub_commands/send.rs')
-rw-r--r--src/sub_commands/send.rs25
1 files changed, 9 insertions, 16 deletions
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::{
24 24
25#[derive(Debug, clap::Args)] 25#[derive(Debug, clap::Args)]
26pub struct SubCommandArgs { 26pub struct SubCommandArgs {
27 #[arg(default_value = "")] 27 #[arg(default_value = "master..HEAD")]
28 /// starting commit (commits since in current branch) or commit range, like 28 /// commits to send as proposal; like in `git format-patch`
29 /// in `git format-patch` 29 pub(crate) since_or_revision_range: String,
30 pub(crate) starting_commit: String,
31 #[clap(long)] 30 #[clap(long)]
32 /// nevent or event id of an existing proposal for which this is a new 31 /// nevent or event id of an existing proposal for which this is a new
33 /// version 32 /// version
34 pub(crate) in_reply_to: Option<String>, 33 pub(crate) in_reply_to: Option<String>,
34 /// don't prompt for a cover letter
35 #[arg(long, action)]
36 pub(crate) no_cover_letter: bool,
35 /// optional cover letter title 37 /// optional cover letter title
36 #[clap(short, long)] 38 #[clap(short, long)]
37 pub(crate) title: Option<String>, 39 pub(crate) title: Option<String>,
38 #[clap(short, long)] 40 #[clap(short, long)]
39 /// optional cover letter description 41 /// optional cover letter description
40 pub(crate) description: Option<String>, 42 pub(crate) description: Option<String>,
41 #[clap(long)]
42 /// branch to get changes from (defaults to head)
43 pub(crate) from_branch: Option<String>,
44 #[clap(long)]
45 /// destination branch (defaults to main or master)
46 pub(crate) to_branch: Option<String>,
47 /// don't ask about a cover letter
48 #[arg(long, action)]
49 pub(crate) no_cover_letter: bool,
50} 43}
51 44
52#[allow(clippy::too_many_lines)] 45#[allow(clippy::too_many_lines)]
@@ -54,9 +47,9 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
54 let git_repo = Repo::discover().context("cannot find a git repository")?; 47 let git_repo = Repo::discover().context("cannot find a git repository")?;
55 48
56 let mut commits: Vec<Sha1Hash> = { 49 let mut commits: Vec<Sha1Hash> = {
57 if args.starting_commit.is_empty() { 50 if args.since_or_revision_range.eq("master..HEAD") {
58 let (from_branch, to_branch, ahead, behind) = 51 let (from_branch, to_branch, ahead, behind) =
59 identify_ahead_behind(&git_repo, &args.from_branch, &args.to_branch)?; 52 identify_ahead_behind(&git_repo, &None, &None)?;
60 53
61 if ahead.is_empty() { 54 if ahead.is_empty() {
62 bail!(format!( 55 bail!(format!(
@@ -94,7 +87,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
94 ahead 87 ahead
95 } else { 88 } else {
96 let ahead = git_repo 89 let ahead = git_repo
97 .parse_starting_commits(&args.starting_commit) 90 .parse_starting_commits(&args.since_or_revision_range)
98 .context("cannot parse specified starting commit or range")?; 91 .context("cannot parse specified starting commit or range")?;
99 println!("creating patch for {} commits", ahead.len(),); 92 println!("creating patch for {} commits", ahead.len(),);
100 ahead 93 ahead