From c7faf80ab9d2639211d3978f1527286b3ce86ce0 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 11 Sep 2024 15:51:10 +0100 Subject: fix(remote): update copy to make it more like native git --- src/bin/git_remote_nostr/fetch.rs | 6 +----- src/bin/git_remote_nostr/list.rs | 6 +----- src/bin/git_remote_nostr/push.rs | 6 +----- src/lib/git/nostr_url.rs | 6 +++--- tests/git_remote_nostr/fetch.rs | 6 +++--- tests/git_remote_nostr/list.rs | 26 ++++---------------------- tests/git_remote_nostr/push.rs | 32 ++++---------------------------- 7 files changed, 17 insertions(+), 71 deletions(-) diff --git a/src/bin/git_remote_nostr/fetch.rs b/src/bin/git_remote_nostr/fetch.rs index 83b94b8..baf56ed 100644 --- a/src/bin/git_remote_nostr/fetch.rs +++ b/src/bin/git_remote_nostr/fetch.rs @@ -121,11 +121,7 @@ fn fetch_from_git_server( let mut success = false; for protocol in &protocols_to_attempt { term.write_line( - format!( - "fetching over {protocol} from {}...", - server_url.short_name(), - ) - .as_str(), + format!("fetching {} over {protocol}...", server_url.short_name(),).as_str(), )?; let formatted_url = server_url.format_as(protocol, &decoded_nostr_url.user)?; diff --git a/src/bin/git_remote_nostr/list.rs b/src/bin/git_remote_nostr/list.rs index c8843e3..d3682ec 100644 --- a/src/bin/git_remote_nostr/list.rs +++ b/src/bin/git_remote_nostr/list.rs @@ -164,11 +164,7 @@ pub fn list_from_remote( for protocol in &protocols_to_attempt { term.write_line( - format!( - "fetching ref list over {protocol} from {}...", - server_url.short_name(), - ) - .as_str(), + format!("fetching {} ref list over {protocol}...", server_url.short_name(),).as_str(), )?; let formatted_url = server_url.format_as(protocol, &decoded_nostr_url.user)?; diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs index 364555a..7f63eb0 100644 --- a/src/bin/git_remote_nostr/push.rs +++ b/src/bin/git_remote_nostr/push.rs @@ -355,11 +355,7 @@ fn push_to_remote( for protocol in &protocols_to_attempt { term.write_line( - format!( - "fetching ref list over {protocol} from {}...", - server_url.short_name(), - ) - .as_str(), + format!("fetching {} ref list over {protocol}...", server_url.short_name(),).as_str(), )?; let formatted_url = server_url.format_as(protocol, &decoded_nostr_url.user)?; diff --git a/src/lib/git/nostr_url.rs b/src/lib/git/nostr_url.rs index d0e6d8a..6fcc11d 100644 --- a/src/lib/git/nostr_url.rs +++ b/src/lib/git/nostr_url.rs @@ -28,8 +28,8 @@ impl fmt::Display for ServerProtocol { ServerProtocol::Git => write!(f, "git"), ServerProtocol::Filesystem => write!(f, "filesystem"), ServerProtocol::Unspecified => write!(f, "unsepcified"), - ServerProtocol::UnauthHttps => write!(f, "unauthenticated https"), - ServerProtocol::UnauthHttp => write!(f, "unauthenticated http"), + ServerProtocol::UnauthHttps => write!(f, "https (unauthenticated)"), + ServerProtocol::UnauthHttp => write!(f, "http (unauthenticated)"), } } } @@ -330,7 +330,7 @@ impl CloneUrl { if domain.is_empty() { self.original_string.to_string() } else { - domain + format!("{domain}{}", self.path) } } } diff --git a/tests/git_remote_nostr/fetch.rs b/tests/git_remote_nostr/fetch.rs index b7415b5..066e104 100644 --- a/tests/git_remote_nostr/fetch.rs +++ b/tests/git_remote_nostr/fetch.rs @@ -42,7 +42,7 @@ async fn fetch_downloads_speficied_commits_from_git_server() -> Result<()> { p.send_line(format!("fetch {main_commit_id} main").as_str())?; p.send_line(format!("fetch {vnext_commit_id} vnext").as_str())?; p.send_line("")?; - p.expect(format!("fetching over filesystem from {source_path}...\r\n").as_str())?; + p.expect(format!("fetching {source_path} over filesystem...\r\n").as_str())?; p.expect_eventually_and_print("\r\n")?; assert!(git_repo.git_repo.find_commit(main_commit_id).is_ok()); @@ -108,7 +108,7 @@ mod when_first_git_server_fails_ { let mut p = cli_tester_after_fetch(&git_repo)?; p.send_line(format!("fetch {main_commit_id} main").as_str())?; p.send_line("")?; - p.expect(format!("fetching over filesystem from {error_path}...\r\n").as_str())?; + p.expect(format!("fetching {error_path} over filesystem...\r\n").as_str())?; // not sure why the below isn't appearing // p.expect(format!("fetching over filesystem from // {source_path}...\r\n").as_str())?; @@ -166,7 +166,7 @@ async fn creates_commits_from_open_proposal_with_no_warngins_printed() -> Result let mut p = cli_tester_after_fetch(&git_repo)?; p.send_line(format!("fetch {proposal_tip} refs/heads/{branch_name}").as_str())?; p.send_line("")?; - p.expect(format!("fetching over filesystem from {source_path}...\r\n").as_str())?; + p.expect(format!("fetching {source_path} over filesystem...\r\n").as_str())?; // expect no errors p.expect_after_whitespace("\r\n")?; p.exit()?; diff --git a/tests/git_remote_nostr/list.rs b/tests/git_remote_nostr/list.rs index 3858ece..0753a24 100644 --- a/tests/git_remote_nostr/list.rs +++ b/tests/git_remote_nostr/list.rs @@ -41,13 +41,7 @@ mod without_state_announcement { let cli_tester_handle = std::thread::spawn(move || -> Result<()> { let mut p = cli_tester_after_fetch(&git_repo)?; p.send_line("list")?; - p.expect( - format!( - "fetching ref list over filesystem from {}...\r\n", - source_path - ) - .as_str(), - )?; + p.expect(format!("fetching {} ref list over filesystem...\r\n", source_path).as_str())?; // println!("{}", p.expect_eventually("\r\n\r\n")?); let res = p.expect_eventually("\r\n\r\n")?; p.exit()?; @@ -121,11 +115,7 @@ mod with_state_announcement { let mut p = cli_tester_after_fetch(&git_repo)?; p.send_line("list")?; p.expect( - format!( - "fetching ref list over filesystem from {}...\r\n", - source_path - ) - .as_str(), + format!("fetching {} ref list over filesystem...\r\n", source_path).as_str(), )?; // println!("{}", p.expect_eventually("\r\n\r\n")?); let res = p.expect_eventually("\r\n\r\n")?; @@ -208,11 +198,7 @@ mod with_state_announcement { let mut p = cli_tester_after_fetch(&git_repo)?; p.send_line("list")?; p.expect( - format!( - "fetching ref list over filesystem from {}...\r\n", - source_path - ) - .as_str(), + format!("fetching {} ref list over filesystem...\r\n", source_path).as_str(), )?; p.expect( format!( @@ -295,11 +281,7 @@ mod with_state_announcement { let mut p = cli_tester_after_fetch(&git_repo)?; p.send_line("list")?; p.expect( - format!( - "fetching ref list over filesystem from {}...\r\n", - source_path - ) - .as_str(), + format!("fetching {} ref list over filesystem...\r\n", source_path).as_str(), )?; // println!("{}", p.expect_eventually("\r\n\r\n")?); let res = p.expect_eventually("\r\n\r\n")?; diff --git a/tests/git_remote_nostr/push.rs b/tests/git_remote_nostr/push.rs index f0d519e..5066d33 100644 --- a/tests/git_remote_nostr/push.rs +++ b/tests/git_remote_nostr/push.rs @@ -930,13 +930,7 @@ async fn proposal_merge_commit_pushed_to_main_leads_to_status_event_issued() -> let mut p = CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, ["push"]); cli_expect_nostr_fetch(&mut p)?; - p.expect( - format!( - "fetching ref list over filesystem from {}...\r\n", - source_path - ) - .as_str(), - )?; + p.expect(format!("fetching {} ref list over filesystem...\r\n", source_path).as_str())?; p.expect("merge commit ")?; // shorthand merge commit id appears in this gap @@ -1080,13 +1074,7 @@ async fn push_2_commits_to_existing_proposal() -> Result<()> { let mut p = CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, ["push"]); cli_expect_nostr_fetch(&mut p)?; - p.expect( - format!( - "fetching ref list over filesystem from {}...\r\n", - source_path - ) - .as_str(), - )?; + p.expect(format!("fetching {} ref list over filesystem...\r\n", source_path).as_str())?; p.expect(format!("To {}\r\n", get_nostr_remote_url()?).as_str())?; let output = p.expect_end_eventually()?; @@ -1240,13 +1228,7 @@ async fn force_push_creates_proposal_revision() -> Result<()> { let mut p = CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, ["push", "--force"]); cli_expect_nostr_fetch(&mut p)?; - p.expect( - format!( - "fetching ref list over filesystem from {}...\r\n", - source_path - ) - .as_str(), - )?; + p.expect(format!("fetching {} ref list over filesystem...\r\n", source_path).as_str())?; p.expect(format!("To {}\r\n", get_nostr_remote_url()?).as_str())?; let output = p.expect_end_eventually()?; @@ -1395,13 +1377,7 @@ async fn push_new_pr_branch_creates_proposal() -> Result<()> { ["push", "-u", "origin", branch_name], ); cli_expect_nostr_fetch(&mut p)?; - p.expect( - format!( - "fetching ref list over filesystem from {}...\r\n", - source_path - ) - .as_str(), - )?; + p.expect(format!("fetching {} ref list over filesystem...\r\n", source_path).as_str())?; p.expect(format!("To {}\r\n", get_nostr_remote_url()?).as_str())?; let output = p.expect_end_eventually()?; -- cgit v1.2.3