upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/bin/git_remote_nostr
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/git_remote_nostr')
-rw-r--r--src/bin/git_remote_nostr/fetch.rs17
-rw-r--r--src/bin/git_remote_nostr/push.rs13
-rw-r--r--src/bin/git_remote_nostr/utils.rs2
3 files changed, 19 insertions, 13 deletions
diff --git a/src/bin/git_remote_nostr/fetch.rs b/src/bin/git_remote_nostr/fetch.rs
index 90387f3..458c6d8 100644
--- a/src/bin/git_remote_nostr/fetch.rs
+++ b/src/bin/git_remote_nostr/fetch.rs
@@ -141,9 +141,11 @@ async fn fetch_proposals(
141 let current_user = get_curent_user(git_repo)?; 141 let current_user = get_curent_user(git_repo)?;
142 142
143 for refstr in proposal_refs.keys() { 143 for refstr in proposal_refs.keys() {
144 if let Some((_, (_, patches))) = 144 if let Some((_, (_, patches))) = find_proposal_and_patches_by_branch_name(
145 find_proposal_and_patches_by_branch_name(refstr, &open_proposals, &current_user) 145 refstr,
146 { 146 &open_proposals,
147 current_user.as_ref(),
148 ) {
147 if let Err(error) = make_commits_for_proposal(git_repo, repo_ref, patches) { 149 if let Err(error) = make_commits_for_proposal(git_repo, repo_ref, patches) {
148 term.write_line( 150 term.write_line(
149 format!("WARNING: failed to create branch for {refstr}, error: {error}",) 151 format!("WARNING: failed to create branch for {refstr}, error: {error}",)
@@ -234,7 +236,7 @@ pub fn fetch_from_git_server(
234fn report_on_transfer_progress( 236fn report_on_transfer_progress(
235 progress_stats: &Progress<'_>, 237 progress_stats: &Progress<'_>,
236 start_time: &Instant, 238 start_time: &Instant,
237 end_time: &Option<Instant>, 239 end_time: Option<&Instant>,
238) -> Vec<String> { 240) -> Vec<String> {
239 let mut report = vec![]; 241 let mut report = vec![];
240 let total = progress_stats.total_objects() as f64; 242 let total = progress_stats.total_objects() as f64;
@@ -378,8 +380,11 @@ impl<'a> FetchReporter<'a> {
378 self.start_time = Some(Instant::now()); 380 self.start_time = Some(Instant::now());
379 } 381 }
380 let existing_lines = self.just_count_transfer_progress(); 382 let existing_lines = self.just_count_transfer_progress();
381 let updated = 383 let updated = report_on_transfer_progress(
382 report_on_transfer_progress(progress_stats, &self.start_time.unwrap(), &self.end_time); 384 progress_stats,
385 &self.start_time.unwrap(),
386 self.end_time.as_ref(),
387 );
383 if self.transfer_progress_msgs.len() <= updated.len() { 388 if self.transfer_progress_msgs.len() <= updated.len() {
384 if self.end_time.is_none() && updated.first().is_some_and(|f| f.contains("100%")) { 389 if self.end_time.is_none() && updated.first().is_some_and(|f| f.contains("100%")) {
385 self.end_time = Some(Instant::now()); 390 self.end_time = Some(Instant::now());
diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs
index 48122e3..f2ac169 100644
--- a/src/bin/git_remote_nostr/push.rs
+++ b/src/bin/git_remote_nostr/push.rs
@@ -299,7 +299,7 @@ async fn process_proposal_refspecs(
299 let tip_of_pushed_branch = git_repo.get_commit_or_tip_of_reference(from)?; 299 let tip_of_pushed_branch = git_repo.get_commit_or_tip_of_reference(from)?;
300 300
301 if let Some((_, (proposal, patches))) = 301 if let Some((_, (proposal, patches))) =
302 find_proposal_and_patches_by_branch_name(to, &all_proposals, &current_user) 302 find_proposal_and_patches_by_branch_name(to, &all_proposals, current_user.as_ref())
303 { 303 {
304 if [repo_ref.maintainers.clone(), vec![proposal.pubkey]] 304 if [repo_ref.maintainers.clone(), vec![proposal.pubkey]]
305 .concat() 305 .concat()
@@ -576,7 +576,7 @@ fn report_on_transfer_progress(
576 total: usize, 576 total: usize,
577 bytes: usize, 577 bytes: usize,
578 start_time: &Instant, 578 start_time: &Instant,
579 end_time: &Option<Instant>, 579 end_time: Option<&Instant>,
580) -> Option<String> { 580) -> Option<String> {
581 if total == 0 { 581 if total == 0 {
582 return None; 582 return None;
@@ -688,7 +688,7 @@ impl<'a> PushReporter<'a> {
688 total, 688 total,
689 bytes, 689 bytes,
690 &self.start_time.unwrap(), 690 &self.start_time.unwrap(),
691 &self.end_time, 691 self.end_time.as_ref(),
692 ) { 692 ) {
693 let existing_lines = self.count_all_existing_lines(); 693 let existing_lines = self.count_all_existing_lines();
694 if report.contains("100%") { 694 if report.contains("100%") {
@@ -1215,11 +1215,12 @@ async fn create_merge_events(
1215 signer, 1215 signer,
1216 repo_ref, 1216 repo_ref,
1217 &proposal, 1217 &proposal,
1218 &if let Some(revision_id) = revision_id { 1218 if let Some(revision_id) = revision_id {
1219 Some(get_event_from_cache_by_id(git_repo, revision_id).await?) 1219 Some(get_event_from_cache_by_id(git_repo, revision_id).await?)
1220 } else { 1220 } else {
1221 None 1221 None
1222 }, 1222 }
1223 .as_ref(),
1223 if let Some((commit, _)) = merged_patches 1224 if let Some((commit, _)) = merged_patches
1224 .iter() 1225 .iter()
1225 .find(|(_, m)| **m == MergedPRCommitType::MergeCommit) 1226 .find(|(_, m)| **m == MergedPRCommitType::MergeCommit)
@@ -1263,7 +1264,7 @@ async fn create_merge_status(
1263 signer: &Arc<dyn NostrSigner>, 1264 signer: &Arc<dyn NostrSigner>,
1264 repo_ref: &RepoRef, 1265 repo_ref: &RepoRef,
1265 proposal: &Event, 1266 proposal: &Event,
1266 revision: &Option<Event>, 1267 revision: Option<&Event>,
1267 merge_commits: Vec<Sha1Hash>, 1268 merge_commits: Vec<Sha1Hash>,
1268 merged_patches: Vec<EventId>, 1269 merged_patches: Vec<EventId>,
1269 applied: bool, 1270 applied: bool,
diff --git a/src/bin/git_remote_nostr/utils.rs b/src/bin/git_remote_nostr/utils.rs
index 5efb6e0..8e89652 100644
--- a/src/bin/git_remote_nostr/utils.rs
+++ b/src/bin/git_remote_nostr/utils.rs
@@ -188,7 +188,7 @@ pub async fn get_all_proposals(
188pub fn find_proposal_and_patches_by_branch_name<'a>( 188pub fn find_proposal_and_patches_by_branch_name<'a>(
189 refstr: &'a str, 189 refstr: &'a str,
190 open_proposals: &'a HashMap<EventId, (Event, Vec<Event>)>, 190 open_proposals: &'a HashMap<EventId, (Event, Vec<Event>)>,
191 current_user: &Option<PublicKey>, 191 current_user: Option<&PublicKey>,
192) -> Option<(&'a EventId, &'a (Event, Vec<Event>))> { 192) -> Option<(&'a EventId, &'a (Event, Vec<Event>))> {
193 open_proposals.iter().find(|(_, (proposal, _))| { 193 open_proposals.iter().find(|(_, (proposal, _))| {
194 is_event_proposal_root_for_branch(proposal, refstr, current_user).unwrap_or(false) 194 is_event_proposal_root_for_branch(proposal, refstr, current_user).unwrap_or(false)