upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/ngit/sub_commands/init.rs24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs
index 1b8268c..dc8c673 100644
--- a/src/bin/ngit/sub_commands/init.rs
+++ b/src/bin/ngit/sub_commands/init.rs
@@ -16,6 +16,7 @@ use ngit::{
16 show_multi_input_prompt_success, 16 show_multi_input_prompt_success,
17 }, 17 },
18 client::{Params, get_state_from_cache, send_events}, 18 client::{Params, get_state_from_cache, send_events},
19 fetch::fetch_from_git_server,
19 git::nostr_url::{CloneUrl, NostrUrlDecoded}, 20 git::nostr_url::{CloneUrl, NostrUrlDecoded},
20 list::list_from_remote, 21 list::list_from_remote,
21 repo_ref::{ 22 repo_ref::{
@@ -789,8 +790,27 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
789 || key.starts_with("refs/tags/") 790 || key.starts_with("refs/tags/")
790 || key.starts_with("HEAD") 791 || key.starts_with("HEAD")
791 }); 792 });
792 // TODO ngit sync will error if any of these remote refs are not available 793 let mut required_oids = vec![];
793 // locally 794 for tip in origin_state.values() {
795 if let Ok(exist) = git_repo.does_commit_exist(tip) {
796 if !exist {
797 required_oids.push(tip.clone());
798 }
799 }
800 }
801 if required_oids.is_empty() {
802 println!("fetching refs missing locally from existing origin...");
803 if let Err(error) = fetch_from_git_server(
804 &git_repo,
805 &required_oids,
806 url,
807 &nostr_url_decoded,
808 &Term::stdout(),
809 false,
810 ) {
811 println!("error fetching refs which will make ngit sync fail: {error}");
812 }
813 }
794 let new_state_event = 814 let new_state_event =
795 RepoState::build(repo_ref.identifier.clone(), origin_state, &signer) 815 RepoState::build(repo_ref.identifier.clone(), origin_state, &signer)
796 .await? 816 .await?