upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/bin/ngit/sub_commands/apply.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/ngit/sub_commands/apply.rs')
-rw-r--r--src/bin/ngit/sub_commands/apply.rs32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/bin/ngit/sub_commands/apply.rs b/src/bin/ngit/sub_commands/apply.rs
index fd9eae3..4ed6caa 100644
--- a/src/bin/ngit/sub_commands/apply.rs
+++ b/src/bin/ngit/sub_commands/apply.rs
@@ -4,14 +4,18 @@ use std::{
4}; 4};
5 5
6use anyhow::{Context, Result, bail}; 6use anyhow::{Context, Result, bail};
7use ngit::client::get_all_proposal_patch_pr_pr_update_events_from_cache; 7use ngit::{
8use ngit::git_events::get_pr_tip_event_or_most_recent_patch_with_ancestors; 8 client::get_all_proposal_patch_pr_pr_update_events_from_cache,
9 git_events::get_pr_tip_event_or_most_recent_patch_with_ancestors,
10};
9use nostr::nips::nip19::Nip19; 11use nostr::nips::nip19::Nip19;
10use nostr_sdk::{EventId, FromBech32}; 12use nostr_sdk::{EventId, FromBech32};
11 13
12use crate::client::{Client, Connect, fetching_with_report, get_repo_ref_from_cache}; 14use crate::{
13use crate::git::{Repo, RepoActions}; 15 client::{Client, Connect, fetching_with_report, get_repo_ref_from_cache},
14use crate::repo_ref::get_repo_coordinates_when_remote_unknown; 16 git::{Repo, RepoActions},
17 repo_ref::get_repo_coordinates_when_remote_unknown,
18};
15 19
16fn run_git_fetch(remote_name: &str) -> Result<()> { 20fn run_git_fetch(remote_name: &str) -> Result<()> {
17 println!("fetching from {remote_name}..."); 21 println!("fetching from {remote_name}...");
@@ -55,11 +59,8 @@ pub async fn launch(id: &str, stdout: bool) -> Result<()> {
55 let repo_ref = get_repo_ref_from_cache(Some(git_repo_path), &repo_coordinates).await?; 59 let repo_ref = get_repo_ref_from_cache(Some(git_repo_path), &repo_coordinates).await?;
56 60
57 let proposals_and_revisions: Vec<nostr::Event> = 61 let proposals_and_revisions: Vec<nostr::Event> =
58 ngit::client::get_proposals_and_revisions_from_cache( 62 ngit::client::get_proposals_and_revisions_from_cache(git_repo_path, repo_ref.coordinates())
59 git_repo_path, 63 .await?;
60 repo_ref.coordinates(),
61 )
62 .await?;
63 64
64 let proposal = proposals_and_revisions 65 let proposal = proposals_and_revisions
65 .iter() 66 .iter()
@@ -79,10 +80,13 @@ pub async fn launch(id: &str, stdout: bool) -> Result<()> {
79 let patches = get_pr_tip_event_or_most_recent_patch_with_ancestors(commits_events.clone()) 80 let patches = get_pr_tip_event_or_most_recent_patch_with_ancestors(commits_events.clone())
80 .context("failed to find any PR or patch events on this proposal")?; 81 .context("failed to find any PR or patch events on this proposal")?;
81 82
82 if patches 83 if patches.iter().any(|e| {
83 .iter() 84 [
84 .any(|e| [ngit::git_events::KIND_PULL_REQUEST, ngit::git_events::KIND_PULL_REQUEST_UPDATE].contains(&e.kind)) 85 ngit::git_events::KIND_PULL_REQUEST,
85 { 86 ngit::git_events::KIND_PULL_REQUEST_UPDATE,
87 ]
88 .contains(&e.kind)
89 }) {
86 bail!( 90 bail!(
87 "this proposal uses PR format (not patches). Use `ngit checkout {}` instead.", 91 "this proposal uses PR format (not patches). Use `ngit checkout {}` instead.",
88 event_id.to_hex() 92 event_id.to_hex()