diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/git.rs | 6 | ||||
| -rw-r--r-- | src/main.rs | 9 | ||||
| -rw-r--r-- | src/sub_commands/claim.rs | 2 | ||||
| -rw-r--r-- | src/sub_commands/list.rs (renamed from src/sub_commands/prs/list.rs) | 10 | ||||
| -rw-r--r-- | src/sub_commands/mod.rs | 3 | ||||
| -rw-r--r-- | src/sub_commands/prs/mod.rs | 25 | ||||
| -rw-r--r-- | src/sub_commands/pull.rs | 2 | ||||
| -rw-r--r-- | src/sub_commands/push.rs | 4 | ||||
| -rw-r--r-- | src/sub_commands/send.rs (renamed from src/sub_commands/prs/create.rs) | 7 |
9 files changed, 20 insertions, 48 deletions
| @@ -6,7 +6,7 @@ use anyhow::{bail, Context, Result}; | |||
| 6 | use git2::{DiffOptions, Oid, Revwalk}; | 6 | use git2::{DiffOptions, Oid, Revwalk}; |
| 7 | use nostr::prelude::{sha1::Hash as Sha1Hash, Hash}; | 7 | use nostr::prelude::{sha1::Hash as Sha1Hash, Hash}; |
| 8 | 8 | ||
| 9 | use crate::sub_commands::prs::list::tag_value; | 9 | use crate::sub_commands::list::tag_value; |
| 10 | 10 | ||
| 11 | pub struct Repo { | 11 | pub struct Repo { |
| 12 | git_repo: git2::Repository, | 12 | git_repo: git2::Repository, |
| @@ -1251,7 +1251,7 @@ mod tests { | |||
| 1251 | mod apply_patch { | 1251 | mod apply_patch { |
| 1252 | 1252 | ||
| 1253 | use super::*; | 1253 | use super::*; |
| 1254 | use crate::{repo_ref::RepoRef, sub_commands::prs::create::generate_patch_event}; | 1254 | use crate::{repo_ref::RepoRef, sub_commands::send::generate_patch_event}; |
| 1255 | 1255 | ||
| 1256 | fn generate_patch_from_head_commit(test_repo: &GitTestRepo) -> Result<nostr::Event> { | 1256 | fn generate_patch_from_head_commit(test_repo: &GitTestRepo) -> Result<nostr::Event> { |
| 1257 | let original_oid = test_repo.git_repo.head()?.peel_to_commit()?.id(); | 1257 | let original_oid = test_repo.git_repo.head()?.peel_to_commit()?.id(); |
| @@ -1405,7 +1405,7 @@ mod tests { | |||
| 1405 | use test_utils::TEST_KEY_1_KEYS; | 1405 | use test_utils::TEST_KEY_1_KEYS; |
| 1406 | 1406 | ||
| 1407 | use super::*; | 1407 | use super::*; |
| 1408 | use crate::{repo_ref::RepoRef, sub_commands::prs::create::generate_pr_and_patch_events}; | 1408 | use crate::{repo_ref::RepoRef, sub_commands::send::generate_pr_and_patch_events}; |
| 1409 | 1409 | ||
| 1410 | static BRANCH_NAME: &str = "add-example-feature"; | 1410 | static BRANCH_NAME: &str = "add-example-feature"; |
| 1411 | // returns original_repo, pr_event, patch_events | 1411 | // returns original_repo, pr_event, patch_events |
diff --git a/src/main.rs b/src/main.rs index 85b2812..539d9ff 100644 --- a/src/main.rs +++ b/src/main.rs | |||
| @@ -36,8 +36,10 @@ enum Commands { | |||
| 36 | Login(sub_commands::login::SubCommandArgs), | 36 | Login(sub_commands::login::SubCommandArgs), |
| 37 | /// issue repository reference event as a maintainers | 37 | /// issue repository reference event as a maintainers |
| 38 | Claim(sub_commands::claim::SubCommandArgs), | 38 | Claim(sub_commands::claim::SubCommandArgs), |
| 39 | /// create and issue prs | 39 | /// send a PR / patch / patch set via nostr events |
| 40 | Prs(sub_commands::prs::SubCommandArgs), | 40 | Send(sub_commands::send::SubCommandArgs), |
| 41 | /// list open PRs / patches / patch sets and pull / apply them a branch | ||
| 42 | List(sub_commands::list::SubCommandArgs), | ||
| 41 | /// pull latest commits in pr linked to checked out branch | 43 | /// pull latest commits in pr linked to checked out branch |
| 42 | Pull, | 44 | Pull, |
| 43 | /// push commits to current checked out pr branch | 45 | /// push commits to current checked out pr branch |
| @@ -50,7 +52,8 @@ async fn main() -> Result<()> { | |||
| 50 | match &cli.command { | 52 | match &cli.command { |
| 51 | Commands::Login(args) => sub_commands::login::launch(&cli, args).await, | 53 | Commands::Login(args) => sub_commands::login::launch(&cli, args).await, |
| 52 | Commands::Claim(args) => sub_commands::claim::launch(&cli, args).await, | 54 | Commands::Claim(args) => sub_commands::claim::launch(&cli, args).await, |
| 53 | Commands::Prs(args) => sub_commands::prs::launch(&cli, args).await, | 55 | Commands::Send(args) => sub_commands::send::launch(&cli, args).await, |
| 56 | Commands::List(args) => sub_commands::list::launch(&cli, args).await, | ||
| 54 | Commands::Pull => sub_commands::pull::launch().await, | 57 | Commands::Pull => sub_commands::pull::launch().await, |
| 55 | Commands::Push => sub_commands::push::launch(&cli).await, | 58 | Commands::Push => sub_commands::push::launch(&cli).await, |
| 56 | } | 59 | } |
diff --git a/src/sub_commands/claim.rs b/src/sub_commands/claim.rs index d3a80c8..a95021d 100644 --- a/src/sub_commands/claim.rs +++ b/src/sub_commands/claim.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | use anyhow::{Context, Result}; | 1 | use anyhow::{Context, Result}; |
| 2 | 2 | ||
| 3 | use super::prs::create::send_events; | 3 | use super::send::send_events; |
| 4 | #[cfg(not(test))] | 4 | #[cfg(not(test))] |
| 5 | use crate::client::Client; | 5 | use crate::client::Client; |
| 6 | #[cfg(test)] | 6 | #[cfg(test)] |
diff --git a/src/sub_commands/prs/list.rs b/src/sub_commands/list.rs index d4dcfec..49cbf6d 100644 --- a/src/sub_commands/prs/list.rs +++ b/src/sub_commands/list.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | use anyhow::{bail, Context, Result}; | 1 | use anyhow::{bail, Context, Result}; |
| 2 | 2 | ||
| 3 | use super::create::event_is_patch_set_root; | 3 | use super::send::event_is_patch_set_root; |
| 4 | #[cfg(not(test))] | 4 | #[cfg(not(test))] |
| 5 | use crate::client::Client; | 5 | use crate::client::Client; |
| 6 | #[cfg(test)] | 6 | #[cfg(test)] |
| @@ -10,7 +10,7 @@ use crate::{ | |||
| 10 | client::Connect, | 10 | client::Connect, |
| 11 | git::{Repo, RepoActions}, | 11 | git::{Repo, RepoActions}, |
| 12 | repo_ref::{self, RepoRef, REPO_REF_KIND}, | 12 | repo_ref::{self, RepoRef, REPO_REF_KIND}, |
| 13 | sub_commands::prs::create::{event_is_cover_letter, event_to_cover_letter, PATCH_KIND}, | 13 | sub_commands::send::{event_is_cover_letter, event_to_cover_letter, PATCH_KIND}, |
| 14 | Cli, | 14 | Cli, |
| 15 | }; | 15 | }; |
| 16 | 16 | ||
| @@ -22,11 +22,7 @@ pub struct SubCommandArgs { | |||
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | #[allow(clippy::too_many_lines)] | 24 | #[allow(clippy::too_many_lines)] |
| 25 | pub async fn launch( | 25 | pub async fn launch(_cli_args: &Cli, _args: &SubCommandArgs) -> Result<()> { |
| 26 | _cli_args: &Cli, | ||
| 27 | _pr_args: &super::SubCommandArgs, | ||
| 28 | _args: &SubCommandArgs, | ||
| 29 | ) -> Result<()> { | ||
| 30 | let git_repo = Repo::discover().context("cannot find a git repository")?; | 26 | let git_repo = Repo::discover().context("cannot find a git repository")?; |
| 31 | 27 | ||
| 32 | let root_commit = git_repo | 28 | let root_commit = git_repo |
diff --git a/src/sub_commands/mod.rs b/src/sub_commands/mod.rs index 8be9004..b16d50f 100644 --- a/src/sub_commands/mod.rs +++ b/src/sub_commands/mod.rs | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | pub mod claim; | 1 | pub mod claim; |
| 2 | pub mod list; | ||
| 2 | pub mod login; | 3 | pub mod login; |
| 3 | pub mod prs; | ||
| 4 | pub mod pull; | 4 | pub mod pull; |
| 5 | pub mod push; | 5 | pub mod push; |
| 6 | pub mod send; | ||
diff --git a/src/sub_commands/prs/mod.rs b/src/sub_commands/prs/mod.rs deleted file mode 100644 index a41c495..0000000 --- a/src/sub_commands/prs/mod.rs +++ /dev/null | |||
| @@ -1,25 +0,0 @@ | |||
| 1 | use anyhow::Result; | ||
| 2 | use clap::Subcommand; | ||
| 3 | |||
| 4 | use crate::Cli; | ||
| 5 | pub mod create; | ||
| 6 | pub mod list; | ||
| 7 | |||
| 8 | #[derive(clap::Parser)] | ||
| 9 | pub struct SubCommandArgs { | ||
| 10 | #[command(subcommand)] | ||
| 11 | pub prs_command: Commands, | ||
| 12 | } | ||
| 13 | |||
| 14 | #[derive(Debug, Subcommand)] | ||
| 15 | pub enum Commands { | ||
| 16 | Create(create::SubCommandArgs), | ||
| 17 | List(list::SubCommandArgs), | ||
| 18 | } | ||
| 19 | |||
| 20 | pub async fn launch(cli_args: &Cli, pr_args: &SubCommandArgs) -> Result<()> { | ||
| 21 | match &pr_args.prs_command { | ||
| 22 | Commands::Create(args) => create::launch(cli_args, pr_args, args).await, | ||
| 23 | Commands::List(args) => list::launch(cli_args, pr_args, args).await, | ||
| 24 | } | ||
| 25 | } | ||
diff --git a/src/sub_commands/pull.rs b/src/sub_commands/pull.rs index 2b20d3d..fc6db37 100644 --- a/src/sub_commands/pull.rs +++ b/src/sub_commands/pull.rs | |||
| @@ -9,7 +9,7 @@ use crate::{ | |||
| 9 | git::{Repo, RepoActions}, | 9 | git::{Repo, RepoActions}, |
| 10 | repo_ref, | 10 | repo_ref, |
| 11 | sub_commands::{ | 11 | sub_commands::{ |
| 12 | prs::list::get_most_recent_patch_with_ancestors, push::fetch_pr_and_most_recent_patch_chain, | 12 | list::get_most_recent_patch_with_ancestors, push::fetch_pr_and_most_recent_patch_chain, |
| 13 | }, | 13 | }, |
| 14 | }; | 14 | }; |
| 15 | 15 | ||
diff --git a/src/sub_commands/push.rs b/src/sub_commands/push.rs index eb42699..cc1f480 100644 --- a/src/sub_commands/push.rs +++ b/src/sub_commands/push.rs | |||
| @@ -10,12 +10,12 @@ use crate::{ | |||
| 10 | git::{str_to_sha1, Repo, RepoActions}, | 10 | git::{str_to_sha1, Repo, RepoActions}, |
| 11 | login, | 11 | login, |
| 12 | repo_ref::{self, RepoRef}, | 12 | repo_ref::{self, RepoRef}, |
| 13 | sub_commands::prs::{ | 13 | sub_commands::{ |
| 14 | create::{event_to_cover_letter, generate_patch_event, send_events}, | ||
| 15 | list::{ | 14 | list::{ |
| 16 | find_commits_for_pr_event, find_pr_events, get_most_recent_patch_with_ancestors, | 15 | find_commits_for_pr_event, find_pr_events, get_most_recent_patch_with_ancestors, |
| 17 | tag_value, | 16 | tag_value, |
| 18 | }, | 17 | }, |
| 18 | send::{event_to_cover_letter, generate_patch_event, send_events}, | ||
| 19 | }, | 19 | }, |
| 20 | Cli, | 20 | Cli, |
| 21 | }; | 21 | }; |
diff --git a/src/sub_commands/prs/create.rs b/src/sub_commands/send.rs index 35e29d3..2c1dec8 100644 --- a/src/sub_commands/prs/create.rs +++ b/src/sub_commands/send.rs | |||
| @@ -39,11 +39,7 @@ pub struct SubCommandArgs { | |||
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | #[allow(clippy::too_many_lines)] | 41 | #[allow(clippy::too_many_lines)] |
| 42 | pub async fn launch( | 42 | pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { |
| 43 | cli_args: &Cli, | ||
| 44 | _pr_args: &super::SubCommandArgs, | ||
| 45 | args: &SubCommandArgs, | ||
| 46 | ) -> Result<()> { | ||
| 47 | let git_repo = Repo::discover().context("cannot find a git repository")?; | 43 | let git_repo = Repo::discover().context("cannot find a git repository")?; |
| 48 | 44 | ||
| 49 | let (from_branch, to_branch, mut ahead, behind) = | 45 | let (from_branch, to_branch, mut ahead, behind) = |
| @@ -178,6 +174,7 @@ pub async fn launch( | |||
| 178 | Ok(()) | 174 | Ok(()) |
| 179 | } | 175 | } |
| 180 | 176 | ||
| 177 | #[allow(clippy::module_name_repetitions)] | ||
| 181 | pub async fn send_events( | 178 | pub async fn send_events( |
| 182 | #[cfg(test)] client: &crate::client::MockConnect, | 179 | #[cfg(test)] client: &crate::client::MockConnect, |
| 183 | #[cfg(not(test))] client: &Client, | 180 | #[cfg(not(test))] client: &Client, |