diff options
Diffstat (limited to 'src/sub_commands')
| -rw-r--r-- | src/sub_commands/push.rs | 4 | ||||
| -rw-r--r-- | src/sub_commands/send.rs | 25 |
2 files changed, 10 insertions, 19 deletions
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<()> { | |||
| 106 | sub_commands::send::launch( | 106 | sub_commands::send::launch( |
| 107 | cli_args, | 107 | cli_args, |
| 108 | &sub_commands::send::SubCommandArgs { | 108 | &sub_commands::send::SubCommandArgs { |
| 109 | starting_commit: String::new(), | 109 | since_or_revision_range: String::new(), |
| 110 | in_reply_to: Some(proposal_root_event.id.to_string()), | 110 | in_reply_to: Some(proposal_root_event.id.to_string()), |
| 111 | title: None, | 111 | title: None, |
| 112 | description: None, | 112 | description: None, |
| 113 | from_branch: None, | ||
| 114 | to_branch: None, | ||
| 115 | no_cover_letter: args.no_cover_letter, | 113 | no_cover_letter: args.no_cover_letter, |
| 116 | }, | 114 | }, |
| 117 | ) | 115 | ) |
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)] |
| 26 | pub struct SubCommandArgs { | 26 | pub 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 |