diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-09-11 15:51:10 +0100 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-09-12 07:20:44 +0100 |
| commit | c7faf80ab9d2639211d3978f1527286b3ce86ce0 (patch) | |
| tree | f79cb9aceb925206d6fa6fc05268d3873a4ab4f5 | |
| parent | df1660b1b78b5881c64c6fadd4ae12c8c01c6684 (diff) | |
fix(remote): update copy
to make it more like native git
| -rw-r--r-- | src/bin/git_remote_nostr/fetch.rs | 6 | ||||
| -rw-r--r-- | src/bin/git_remote_nostr/list.rs | 6 | ||||
| -rw-r--r-- | src/bin/git_remote_nostr/push.rs | 6 | ||||
| -rw-r--r-- | src/lib/git/nostr_url.rs | 6 | ||||
| -rw-r--r-- | tests/git_remote_nostr/fetch.rs | 6 | ||||
| -rw-r--r-- | tests/git_remote_nostr/list.rs | 26 | ||||
| -rw-r--r-- | 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( | |||
| 121 | let mut success = false; | 121 | let mut success = false; |
| 122 | for protocol in &protocols_to_attempt { | 122 | for protocol in &protocols_to_attempt { |
| 123 | term.write_line( | 123 | term.write_line( |
| 124 | format!( | 124 | format!("fetching {} over {protocol}...", server_url.short_name(),).as_str(), |
| 125 | "fetching over {protocol} from {}...", | ||
| 126 | server_url.short_name(), | ||
| 127 | ) | ||
| 128 | .as_str(), | ||
| 129 | )?; | 125 | )?; |
| 130 | 126 | ||
| 131 | let formatted_url = server_url.format_as(protocol, &decoded_nostr_url.user)?; | 127 | 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( | |||
| 164 | 164 | ||
| 165 | for protocol in &protocols_to_attempt { | 165 | for protocol in &protocols_to_attempt { |
| 166 | term.write_line( | 166 | term.write_line( |
| 167 | format!( | 167 | format!("fetching {} ref list over {protocol}...", server_url.short_name(),).as_str(), |
| 168 | "fetching ref list over {protocol} from {}...", | ||
| 169 | server_url.short_name(), | ||
| 170 | ) | ||
| 171 | .as_str(), | ||
| 172 | )?; | 168 | )?; |
| 173 | 169 | ||
| 174 | let formatted_url = server_url.format_as(protocol, &decoded_nostr_url.user)?; | 170 | 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( | |||
| 355 | 355 | ||
| 356 | for protocol in &protocols_to_attempt { | 356 | for protocol in &protocols_to_attempt { |
| 357 | term.write_line( | 357 | term.write_line( |
| 358 | format!( | 358 | format!("fetching {} ref list over {protocol}...", server_url.short_name(),).as_str(), |
| 359 | "fetching ref list over {protocol} from {}...", | ||
| 360 | server_url.short_name(), | ||
| 361 | ) | ||
| 362 | .as_str(), | ||
| 363 | )?; | 359 | )?; |
| 364 | 360 | ||
| 365 | let formatted_url = server_url.format_as(protocol, &decoded_nostr_url.user)?; | 361 | 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 { | |||
| 28 | ServerProtocol::Git => write!(f, "git"), | 28 | ServerProtocol::Git => write!(f, "git"), |
| 29 | ServerProtocol::Filesystem => write!(f, "filesystem"), | 29 | ServerProtocol::Filesystem => write!(f, "filesystem"), |
| 30 | ServerProtocol::Unspecified => write!(f, "unsepcified"), | 30 | ServerProtocol::Unspecified => write!(f, "unsepcified"), |
| 31 | ServerProtocol::UnauthHttps => write!(f, "unauthenticated https"), | 31 | ServerProtocol::UnauthHttps => write!(f, "https (unauthenticated)"), |
| 32 | ServerProtocol::UnauthHttp => write!(f, "unauthenticated http"), | 32 | ServerProtocol::UnauthHttp => write!(f, "http (unauthenticated)"), |
| 33 | } | 33 | } |
| 34 | } | 34 | } |
| 35 | } | 35 | } |
| @@ -330,7 +330,7 @@ impl CloneUrl { | |||
| 330 | if domain.is_empty() { | 330 | if domain.is_empty() { |
| 331 | self.original_string.to_string() | 331 | self.original_string.to_string() |
| 332 | } else { | 332 | } else { |
| 333 | domain | 333 | format!("{domain}{}", self.path) |
| 334 | } | 334 | } |
| 335 | } | 335 | } |
| 336 | } | 336 | } |
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<()> { | |||
| 42 | p.send_line(format!("fetch {main_commit_id} main").as_str())?; | 42 | p.send_line(format!("fetch {main_commit_id} main").as_str())?; |
| 43 | p.send_line(format!("fetch {vnext_commit_id} vnext").as_str())?; | 43 | p.send_line(format!("fetch {vnext_commit_id} vnext").as_str())?; |
| 44 | p.send_line("")?; | 44 | p.send_line("")?; |
| 45 | p.expect(format!("fetching over filesystem from {source_path}...\r\n").as_str())?; | 45 | p.expect(format!("fetching {source_path} over filesystem...\r\n").as_str())?; |
| 46 | p.expect_eventually_and_print("\r\n")?; | 46 | p.expect_eventually_and_print("\r\n")?; |
| 47 | 47 | ||
| 48 | assert!(git_repo.git_repo.find_commit(main_commit_id).is_ok()); | 48 | assert!(git_repo.git_repo.find_commit(main_commit_id).is_ok()); |
| @@ -108,7 +108,7 @@ mod when_first_git_server_fails_ { | |||
| 108 | let mut p = cli_tester_after_fetch(&git_repo)?; | 108 | let mut p = cli_tester_after_fetch(&git_repo)?; |
| 109 | p.send_line(format!("fetch {main_commit_id} main").as_str())?; | 109 | p.send_line(format!("fetch {main_commit_id} main").as_str())?; |
| 110 | p.send_line("")?; | 110 | p.send_line("")?; |
| 111 | p.expect(format!("fetching over filesystem from {error_path}...\r\n").as_str())?; | 111 | p.expect(format!("fetching {error_path} over filesystem...\r\n").as_str())?; |
| 112 | // not sure why the below isn't appearing | 112 | // not sure why the below isn't appearing |
| 113 | // p.expect(format!("fetching over filesystem from | 113 | // p.expect(format!("fetching over filesystem from |
| 114 | // {source_path}...\r\n").as_str())?; | 114 | // {source_path}...\r\n").as_str())?; |
| @@ -166,7 +166,7 @@ async fn creates_commits_from_open_proposal_with_no_warngins_printed() -> Result | |||
| 166 | let mut p = cli_tester_after_fetch(&git_repo)?; | 166 | let mut p = cli_tester_after_fetch(&git_repo)?; |
| 167 | p.send_line(format!("fetch {proposal_tip} refs/heads/{branch_name}").as_str())?; | 167 | p.send_line(format!("fetch {proposal_tip} refs/heads/{branch_name}").as_str())?; |
| 168 | p.send_line("")?; | 168 | p.send_line("")?; |
| 169 | p.expect(format!("fetching over filesystem from {source_path}...\r\n").as_str())?; | 169 | p.expect(format!("fetching {source_path} over filesystem...\r\n").as_str())?; |
| 170 | // expect no errors | 170 | // expect no errors |
| 171 | p.expect_after_whitespace("\r\n")?; | 171 | p.expect_after_whitespace("\r\n")?; |
| 172 | p.exit()?; | 172 | 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 { | |||
| 41 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { | 41 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { |
| 42 | let mut p = cli_tester_after_fetch(&git_repo)?; | 42 | let mut p = cli_tester_after_fetch(&git_repo)?; |
| 43 | p.send_line("list")?; | 43 | p.send_line("list")?; |
| 44 | p.expect( | 44 | p.expect(format!("fetching {} ref list over filesystem...\r\n", source_path).as_str())?; |
| 45 | format!( | ||
| 46 | "fetching ref list over filesystem from {}...\r\n", | ||
| 47 | source_path | ||
| 48 | ) | ||
| 49 | .as_str(), | ||
| 50 | )?; | ||
| 51 | // println!("{}", p.expect_eventually("\r\n\r\n")?); | 45 | // println!("{}", p.expect_eventually("\r\n\r\n")?); |
| 52 | let res = p.expect_eventually("\r\n\r\n")?; | 46 | let res = p.expect_eventually("\r\n\r\n")?; |
| 53 | p.exit()?; | 47 | p.exit()?; |
| @@ -121,11 +115,7 @@ mod with_state_announcement { | |||
| 121 | let mut p = cli_tester_after_fetch(&git_repo)?; | 115 | let mut p = cli_tester_after_fetch(&git_repo)?; |
| 122 | p.send_line("list")?; | 116 | p.send_line("list")?; |
| 123 | p.expect( | 117 | p.expect( |
| 124 | format!( | 118 | format!("fetching {} ref list over filesystem...\r\n", source_path).as_str(), |
| 125 | "fetching ref list over filesystem from {}...\r\n", | ||
| 126 | source_path | ||
| 127 | ) | ||
| 128 | .as_str(), | ||
| 129 | )?; | 119 | )?; |
| 130 | // println!("{}", p.expect_eventually("\r\n\r\n")?); | 120 | // println!("{}", p.expect_eventually("\r\n\r\n")?); |
| 131 | let res = p.expect_eventually("\r\n\r\n")?; | 121 | let res = p.expect_eventually("\r\n\r\n")?; |
| @@ -208,11 +198,7 @@ mod with_state_announcement { | |||
| 208 | let mut p = cli_tester_after_fetch(&git_repo)?; | 198 | let mut p = cli_tester_after_fetch(&git_repo)?; |
| 209 | p.send_line("list")?; | 199 | p.send_line("list")?; |
| 210 | p.expect( | 200 | p.expect( |
| 211 | format!( | 201 | format!("fetching {} ref list over filesystem...\r\n", source_path).as_str(), |
| 212 | "fetching ref list over filesystem from {}...\r\n", | ||
| 213 | source_path | ||
| 214 | ) | ||
| 215 | .as_str(), | ||
| 216 | )?; | 202 | )?; |
| 217 | p.expect( | 203 | p.expect( |
| 218 | format!( | 204 | format!( |
| @@ -295,11 +281,7 @@ mod with_state_announcement { | |||
| 295 | let mut p = cli_tester_after_fetch(&git_repo)?; | 281 | let mut p = cli_tester_after_fetch(&git_repo)?; |
| 296 | p.send_line("list")?; | 282 | p.send_line("list")?; |
| 297 | p.expect( | 283 | p.expect( |
| 298 | format!( | 284 | format!("fetching {} ref list over filesystem...\r\n", source_path).as_str(), |
| 299 | "fetching ref list over filesystem from {}...\r\n", | ||
| 300 | source_path | ||
| 301 | ) | ||
| 302 | .as_str(), | ||
| 303 | )?; | 285 | )?; |
| 304 | // println!("{}", p.expect_eventually("\r\n\r\n")?); | 286 | // println!("{}", p.expect_eventually("\r\n\r\n")?); |
| 305 | let res = p.expect_eventually("\r\n\r\n")?; | 287 | 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() -> | |||
| 930 | 930 | ||
| 931 | let mut p = CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, ["push"]); | 931 | let mut p = CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, ["push"]); |
| 932 | cli_expect_nostr_fetch(&mut p)?; | 932 | cli_expect_nostr_fetch(&mut p)?; |
| 933 | p.expect( | 933 | p.expect(format!("fetching {} ref list over filesystem...\r\n", source_path).as_str())?; |
| 934 | format!( | ||
| 935 | "fetching ref list over filesystem from {}...\r\n", | ||
| 936 | source_path | ||
| 937 | ) | ||
| 938 | .as_str(), | ||
| 939 | )?; | ||
| 940 | 934 | ||
| 941 | p.expect("merge commit ")?; | 935 | p.expect("merge commit ")?; |
| 942 | // shorthand merge commit id appears in this gap | 936 | // shorthand merge commit id appears in this gap |
| @@ -1080,13 +1074,7 @@ async fn push_2_commits_to_existing_proposal() -> Result<()> { | |||
| 1080 | 1074 | ||
| 1081 | let mut p = CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, ["push"]); | 1075 | let mut p = CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, ["push"]); |
| 1082 | cli_expect_nostr_fetch(&mut p)?; | 1076 | cli_expect_nostr_fetch(&mut p)?; |
| 1083 | p.expect( | 1077 | p.expect(format!("fetching {} ref list over filesystem...\r\n", source_path).as_str())?; |
| 1084 | format!( | ||
| 1085 | "fetching ref list over filesystem from {}...\r\n", | ||
| 1086 | source_path | ||
| 1087 | ) | ||
| 1088 | .as_str(), | ||
| 1089 | )?; | ||
| 1090 | p.expect(format!("To {}\r\n", get_nostr_remote_url()?).as_str())?; | 1078 | p.expect(format!("To {}\r\n", get_nostr_remote_url()?).as_str())?; |
| 1091 | let output = p.expect_end_eventually()?; | 1079 | let output = p.expect_end_eventually()?; |
| 1092 | 1080 | ||
| @@ -1240,13 +1228,7 @@ async fn force_push_creates_proposal_revision() -> Result<()> { | |||
| 1240 | let mut p = | 1228 | let mut p = |
| 1241 | CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, ["push", "--force"]); | 1229 | CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, ["push", "--force"]); |
| 1242 | cli_expect_nostr_fetch(&mut p)?; | 1230 | cli_expect_nostr_fetch(&mut p)?; |
| 1243 | p.expect( | 1231 | p.expect(format!("fetching {} ref list over filesystem...\r\n", source_path).as_str())?; |
| 1244 | format!( | ||
| 1245 | "fetching ref list over filesystem from {}...\r\n", | ||
| 1246 | source_path | ||
| 1247 | ) | ||
| 1248 | .as_str(), | ||
| 1249 | )?; | ||
| 1250 | p.expect(format!("To {}\r\n", get_nostr_remote_url()?).as_str())?; | 1232 | p.expect(format!("To {}\r\n", get_nostr_remote_url()?).as_str())?; |
| 1251 | let output = p.expect_end_eventually()?; | 1233 | let output = p.expect_end_eventually()?; |
| 1252 | 1234 | ||
| @@ -1395,13 +1377,7 @@ async fn push_new_pr_branch_creates_proposal() -> Result<()> { | |||
| 1395 | ["push", "-u", "origin", branch_name], | 1377 | ["push", "-u", "origin", branch_name], |
| 1396 | ); | 1378 | ); |
| 1397 | cli_expect_nostr_fetch(&mut p)?; | 1379 | cli_expect_nostr_fetch(&mut p)?; |
| 1398 | p.expect( | 1380 | p.expect(format!("fetching {} ref list over filesystem...\r\n", source_path).as_str())?; |
| 1399 | format!( | ||
| 1400 | "fetching ref list over filesystem from {}...\r\n", | ||
| 1401 | source_path | ||
| 1402 | ) | ||
| 1403 | .as_str(), | ||
| 1404 | )?; | ||
| 1405 | p.expect(format!("To {}\r\n", get_nostr_remote_url()?).as_str())?; | 1381 | p.expect(format!("To {}\r\n", get_nostr_remote_url()?).as_str())?; |
| 1406 | let output = p.expect_end_eventually()?; | 1382 | let output = p.expect_end_eventually()?; |
| 1407 | 1383 | ||