diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-02-22 10:11:39 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-02-22 10:11:39 +0000 |
| commit | fdc15cb017b022a3b932ac5a337c649cb63df93c (patch) | |
| tree | a0883ab2e027042df43c15892f837fffe159cf49 /src/sub_commands/push.rs | |
| parent | ea5aa6993d4c906c1703563ddc304c324c4ae079 (diff) | |
fix(list): support `--in-reply-to` latest revision
update list to support rebases via proposal revisions
as created by `ngit send --in-reply-to`
or upcoming change `ngit push --force`
Diffstat (limited to 'src/sub_commands/push.rs')
| -rw-r--r-- | src/sub_commands/push.rs | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/src/sub_commands/push.rs b/src/sub_commands/push.rs index 73bdb38..dd32b2c 100644 --- a/src/sub_commands/push.rs +++ b/src/sub_commands/push.rs | |||
| @@ -12,10 +12,10 @@ use crate::{ | |||
| 12 | repo_ref::{self, RepoRef}, | 12 | repo_ref::{self, RepoRef}, |
| 13 | sub_commands::{ | 13 | sub_commands::{ |
| 14 | list::{ | 14 | list::{ |
| 15 | find_commits_for_proposal_root_event, find_proposal_events, get_commit_id_from_patch, | 15 | find_commits_for_proposal_root_events, find_proposal_events, get_commit_id_from_patch, |
| 16 | get_most_recent_patch_with_ancestors, tag_value, | 16 | get_most_recent_patch_with_ancestors, tag_value, |
| 17 | }, | 17 | }, |
| 18 | send::{event_to_cover_letter, generate_patch_event, send_events}, | 18 | send::{event_is_revision_root, event_to_cover_letter, generate_patch_event, send_events}, |
| 19 | }, | 19 | }, |
| 20 | Cli, | 20 | Cli, |
| 21 | }; | 21 | }; |
| @@ -149,12 +149,17 @@ pub async fn fetch_proposal_root_and_most_recent_patch_chain( | |||
| 149 | ) -> Result<(nostr::Event, Vec<nostr::Event>)> { | 149 | ) -> Result<(nostr::Event, Vec<nostr::Event>)> { |
| 150 | println!("finding proposal root event..."); | 150 | println!("finding proposal root event..."); |
| 151 | 151 | ||
| 152 | let proposal_events: Vec<nostr::Event> = | 152 | let proposal_events_and_revisions: Vec<nostr::Event> = |
| 153 | find_proposal_events(client, repo_ref, &root_commit.to_string()) | 153 | find_proposal_events(client, repo_ref, &root_commit.to_string()) |
| 154 | .await | 154 | .await |
| 155 | .context("cannot get proposal events for repo")?; | 155 | .context("cannot get proposal events for repo")?; |
| 156 | 156 | ||
| 157 | let proposal_root_event: nostr::Event = proposal_events | 157 | let proposal_events: Vec<&nostr::Event> = proposal_events_and_revisions |
| 158 | .iter() | ||
| 159 | .filter(|e| !event_is_revision_root(e)) | ||
| 160 | .collect::<Vec<&nostr::Event>>(); | ||
| 161 | |||
| 162 | let proposal_root_event: &nostr::Event = proposal_events | ||
| 158 | .iter() | 163 | .iter() |
| 159 | .find(|e| { | 164 | .find(|e| { |
| 160 | event_to_cover_letter(e).is_ok_and(|cl| cl.branch_name.eq(branch_name)) | 165 | event_to_cover_letter(e).is_ok_and(|cl| cl.branch_name.eq(branch_name)) |
| @@ -166,8 +171,24 @@ pub async fn fetch_proposal_root_and_most_recent_patch_chain( | |||
| 166 | 171 | ||
| 167 | println!("found proposal root event. finding commits..."); | 172 | println!("found proposal root event. finding commits..."); |
| 168 | 173 | ||
| 169 | let commits_events: Vec<nostr::Event> = | 174 | let commits_events: Vec<nostr::Event> = find_commits_for_proposal_root_events( |
| 170 | find_commits_for_proposal_root_event(client, &proposal_root_event, repo_ref).await?; | 175 | client, |
| 176 | &[ | ||
| 177 | vec![proposal_root_event], | ||
| 178 | proposal_events_and_revisions | ||
| 179 | .iter() | ||
| 180 | .filter(|e| { | ||
| 181 | e.tags.iter().any(|t| { | ||
| 182 | t.as_vec().len().gt(&1) | ||
| 183 | && t.as_vec()[1].eq(&proposal_root_event.id.to_string()) | ||
| 184 | }) | ||
| 185 | }) | ||
| 186 | .collect::<Vec<&nostr::Event>>(), | ||
| 187 | ] | ||
| 188 | .concat(), | ||
| 189 | repo_ref, | ||
| 190 | ) | ||
| 191 | .await?; | ||
| 171 | 192 | ||
| 172 | Ok((proposal_root_event, commits_events)) | 193 | Ok((proposal_root_event.clone(), commits_events)) |
| 173 | } | 194 | } |