upleb.uk

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

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.rs11
-rw-r--r--src/sub_commands/push.rs4
-rw-r--r--src/sub_commands/send.rs25
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 {
32 32
33#[derive(Subcommand)] 33#[derive(Subcommand)]
34enum Commands { 34enum Commands {
35 /// issue a repo event as a maintainers to signal you are accepting 35 /// signal you are this repo's maintainer accepting proposals via nostr
36 /// proposals via nostr
37 Init(sub_commands::init::SubCommandArgs), 36 Init(sub_commands::init::SubCommandArgs),
38 /// issue commits on current branch as a new proposal 37 /// issue commits as a proposal
39 Send(sub_commands::send::SubCommandArgs), 38 Send(sub_commands::send::SubCommandArgs),
40 /// list proposals; optionally apply them as a new branch 39 /// list proposals; checkout, apply or donwload selected
41 List(sub_commands::list::SubCommandArgs), 40 List(sub_commands::list::SubCommandArgs),
42 /// send new commits as proposal amendments 41 /// send proposal revision
43 Push(sub_commands::push::SubCommandArgs), 42 Push(sub_commands::push::SubCommandArgs),
44 /// pull latest commits in proposal linked to checked out branch 43 /// fetch and apply new proposal commits / revisions linked to branch
45 Pull, 44 Pull,
46 /// run with --nsec flag to change npub 45 /// run with --nsec flag to change npub
47 Login(sub_commands::login::SubCommandArgs), 46 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<()> {
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)]
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