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/git_remote_helper.rs45
1 files changed, 29 insertions, 16 deletions
diff --git a/src/git_remote_helper.rs b/src/git_remote_helper.rs
index 6f645da..8180175 100644
--- a/src/git_remote_helper.rs
+++ b/src/git_remote_helper.rs
@@ -237,12 +237,12 @@ async fn list(
237 if let Some(remote_value) = remote_state.get(name) { 237 if let Some(remote_value) = remote_state.get(name) {
238 if value.ne(remote_value) { 238 if value.ne(remote_value) {
239 term.write_line( 239 term.write_line(
240 format!("WARNING: {name} out of sync with nostr on {url}").as_str(), 240 format!("WARNING: {url} {name} out of sync with nostr ").as_str(),
241 )?; 241 )?;
242 } 242 }
243 } else { 243 } else {
244 term.write_line( 244 term.write_line(
245 format!("WARNING: {name} is missing from {url} but tracked on nostr") 245 format!("WARNING: {url} is missing {name} which is tracked on nostr")
246 .as_str(), 246 .as_str(),
247 )?; 247 )?;
248 } 248 }
@@ -289,7 +289,7 @@ fn list_from_remotes(
289 } 289 }
290 Err(error) => { 290 Err(error) => {
291 term.write_line( 291 term.write_line(
292 format!("WARNING: failed to list refs from {url} error: {error}").as_str(), 292 format!("WARNING: {url} failed to list refs error: {error}").as_str(),
293 )?; 293 )?;
294 } 294 }
295 } 295 }
@@ -466,8 +466,10 @@ async fn push(
466 remote_callbacks.push_update_reference(|name, error| { 466 remote_callbacks.push_update_reference(|name, error| {
467 if let Some(error) = error { 467 if let Some(error) = error {
468 term.write_line( 468 term.write_line(
469 format!("WARNING: error pushing {name} to {git_server_url} {error}") 469 format!(
470 .as_str(), 470 "WARNING: {git_server_url} failed to push {name} error: {error}"
471 )
472 .as_str(),
471 ) 473 )
472 .unwrap(); 474 .unwrap();
473 } 475 }
@@ -544,12 +546,12 @@ fn create_rejected_refspecs_and_remotes_refspecs(
544 { 546 {
545 if from_tip.eq(&remote_value_tip) { 547 if from_tip.eq(&remote_value_tip) {
546 // remote already at correct state 548 // remote already at correct state
547 term.write_line( 549 term.write_line(format!("{url} {to} already up-to-date").as_str())?;
548 format!("{to} already at pushed commit state on {url}").as_str(),
549 )?;
550 } 550 }
551 let (_, behind) = 551 let nostr_value_tip =
552 git_repo.get_commits_ahead_behind(&remote_value_tip, &from_tip)?; 552 git_repo.get_commit_or_tip_of_reference(nostr_value)?;
553 let (ahead, behind) = git_repo
554 .get_commits_ahead_behind(&remote_value_tip, &nostr_value_tip)?;
553 if behind.is_empty() { 555 if behind.is_empty() {
554 // can soft push 556 // can soft push
555 refspecs_for_remote.push(refspec.clone()); 557 refspecs_for_remote.push(refspec.clone());
@@ -560,7 +562,11 @@ fn create_rejected_refspecs_and_remotes_refspecs(
560 .and_modify(|a| a.push(url.to_string())) 562 .and_modify(|a| a.push(url.to_string()))
561 .or_insert(vec![url.to_string()]); 563 .or_insert(vec![url.to_string()]);
562 term.write_line( 564 term.write_line(
563 format!("ERROR: {to} on {url} conflicts with nostr and is {} behind local branch. either:\r\n 1. pull from that git server and resolve\r\n 2. force push your branch to the git server before pushing to nostr remote", behind.len()).as_str(), 565 format!(
566 "ERROR: {url} {to} conflicts with nostr ({} ahead {} behind). either:\r\n 1. pull from that git server and resolve\r\n 2. force push your branch to the git server before pushing to nostr remote",
567 ahead.len(),
568 behind.len(),
569 ).as_str(),
564 )?; 570 )?;
565 }; 571 };
566 } else { 572 } else {
@@ -573,20 +579,23 @@ fn create_rejected_refspecs_and_remotes_refspecs(
573 .and_modify(|a| a.push(url.to_string())) 579 .and_modify(|a| a.push(url.to_string()))
574 .or_insert(vec![url.to_string()]); 580 .or_insert(vec![url.to_string()]);
575 term.write_line( 581 term.write_line(
576 format!("ERROR: {to} on {url} conflicts with nostr and is not an ancestor of local branch. either:\r\n 1. pull from that git server and resolve\r\n 2. force push your branch to the git server before pushing to nostr remote").as_str(), 582 format!("ERROR: {url} {to} conflicts with nostr and is not an ancestor of local branch. either:\r\n 1. pull from that git server and resolve\r\n 2. force push your branch to the git server before pushing to nostr remote").as_str(),
577 )?; 583 )?;
578 } 584 }
579 } else { 585 } else {
580 // existing nostr branch not on remote 586 // existing nostr branch not on remote
581 // report - creating new branch 587 // report - creating new branch
582 term.write_line(format!("pushing {to} as new branch on {url}").as_str())?; 588 term.write_line(
589 format!("{url} {to} doesn't exist and will be added as a new branch")
590 .as_str(),
591 )?;
583 refspecs_for_remote.push(refspec.clone()); 592 refspecs_for_remote.push(refspec.clone());
584 } 593 }
585 } else if let Some(remote_value) = remote_value { 594 } else if let Some(remote_value) = remote_value {
586 // new to nostr but on remote 595 // new to nostr but on remote
587 if let Ok(remote_value_tip) = git_repo.get_commit_or_tip_of_reference(remote_value) 596 if let Ok(remote_value_tip) = git_repo.get_commit_or_tip_of_reference(remote_value)
588 { 597 {
589 let (_, behind) = 598 let (ahead, behind) =
590 git_repo.get_commits_ahead_behind(&remote_value_tip, &from_tip)?; 599 git_repo.get_commits_ahead_behind(&remote_value_tip, &from_tip)?;
591 if behind.is_empty() { 600 if behind.is_empty() {
592 // can soft push 601 // can soft push
@@ -598,7 +607,11 @@ fn create_rejected_refspecs_and_remotes_refspecs(
598 .and_modify(|a| a.push(url.to_string())) 607 .and_modify(|a| a.push(url.to_string()))
599 .or_insert(vec![url.to_string()]); 608 .or_insert(vec![url.to_string()]);
600 term.write_line( 609 term.write_line(
601 format!("ERROR: {to} not on nostr but on {url} is {} behind local branch. either:\r\n 1. pull from that git server and resolve\r\n 2. force push your branch to the git server before pushing to nostr remote", behind.len()).as_str(), 610 format!(
611 "ERROR: {url} already contains {to} {} ahead and {} behind local branch. either:\r\n 1. pull from that git server and resolve\r\n 2. force push your branch to the git server before pushing to nostr remote",
612 ahead.len(),
613 behind.len(),
614 ).as_str(),
602 )?; 615 )?;
603 } 616 }
604 } else { 617 } else {
@@ -610,7 +623,7 @@ fn create_rejected_refspecs_and_remotes_refspecs(
610 .and_modify(|a| a.push(url.to_string())) 623 .and_modify(|a| a.push(url.to_string()))
611 .or_insert(vec![url.to_string()]); 624 .or_insert(vec![url.to_string()]);
612 term.write_line( 625 term.write_line(
613 format!("ERROR: {to} not on nostr but on {url} is not an ancestor of local branch. either:\r\n 1. pull from that git server and resolve\r\n 2. force push your branch to the git server before pushing to nostr remote").as_str(), 626 format!("ERROR: {url} already contains {to} at {remote_value} which is not an ancestor of local branch. either:\r\n 1. pull from that git server and resolve\r\n 2. force push your branch to the git server before pushing to nostr remote").as_str(),
614 )?; 627 )?;
615 } 628 }
616 } else { 629 } else {