diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-08-02 16:40:19 +0100 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-08-02 19:13:04 +0100 |
| commit | bd3f081f27d219f9bafbb00135918f315176f983 (patch) | |
| tree | 6b77ffc13d324d5d7a9a916f0cf46db41d90fc1d | |
| parent | 2014d1990081c4e802bf9a68e9a55c79faaa6328 (diff) | |
feat(remote): improve warning copy
so it is more concise and clear
| -rw-r--r-- | src/git_remote_helper.rs | 10 | ||||
| -rw-r--r-- | tests/git_remote_helper.rs | 44 |
2 files changed, 30 insertions, 24 deletions
diff --git a/src/git_remote_helper.rs b/src/git_remote_helper.rs index 8417415..026c06b 100644 --- a/src/git_remote_helper.rs +++ b/src/git_remote_helper.rs | |||
| @@ -235,7 +235,7 @@ async fn list( | |||
| 235 | } | 235 | } |
| 236 | Err(error) => { | 236 | Err(error) => { |
| 237 | term.write_line( | 237 | term.write_line( |
| 238 | format!("WARNING: failed to list refs git server in nostr events from {url} error: {error}").as_str(), | 238 | format!("WARNING: failed to list refs from {url} error: {error}").as_str(), |
| 239 | )?; | 239 | )?; |
| 240 | } | 240 | } |
| 241 | } | 241 | } |
| @@ -248,15 +248,13 @@ async fn list( | |||
| 248 | if let Some(remote_value) = remote_state.get(name) { | 248 | if let Some(remote_value) = remote_state.get(name) { |
| 249 | if value.ne(remote_value) { | 249 | if value.ne(remote_value) { |
| 250 | term.write_line( | 250 | term.write_line( |
| 251 | format!( | 251 | format!("WARNING: {name} out of sync with nostr on {url}").as_str(), |
| 252 | "WARNING: git server {url} is out of sync with nostr for {name}" | ||
| 253 | ) | ||
| 254 | .as_str(), | ||
| 255 | )?; | 252 | )?; |
| 256 | } | 253 | } |
| 257 | } else { | 254 | } else { |
| 258 | term.write_line( | 255 | term.write_line( |
| 259 | format!("WARNING: git server {url} is out of sync with nostr. it is missing {name}. if you are a maintainer consider pushing it.").as_str(), | 256 | format!("WARNING: {name} is missing from {url} but tracked on nostr") |
| 257 | .as_str(), | ||
| 260 | )?; | 258 | )?; |
| 261 | } | 259 | } |
| 262 | } | 260 | } |
diff --git a/tests/git_remote_helper.rs b/tests/git_remote_helper.rs index b63345c..a9e60ae 100644 --- a/tests/git_remote_helper.rs +++ b/tests/git_remote_helper.rs | |||
| @@ -207,6 +207,7 @@ mod list { | |||
| 207 | 207 | ||
| 208 | async fn async_run_test() -> Result<()> { | 208 | async fn async_run_test() -> Result<()> { |
| 209 | let source_git_repo = prep_git_repo()?; | 209 | let source_git_repo = prep_git_repo()?; |
| 210 | let source_path = source_git_repo.dir.to_str().unwrap().to_string(); | ||
| 210 | std::fs::write(source_git_repo.dir.join("commit.md"), "some content")?; | 211 | std::fs::write(source_git_repo.dir.join("commit.md"), "some content")?; |
| 211 | let main_commit_id = source_git_repo.stage_and_commit("commit.md")?; | 212 | let main_commit_id = source_git_repo.stage_and_commit("commit.md")?; |
| 212 | 213 | ||
| @@ -239,10 +240,15 @@ mod list { | |||
| 239 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { | 240 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { |
| 240 | let mut p = cli_tester_after_fetch(&git_repo)?; | 241 | let mut p = cli_tester_after_fetch(&git_repo)?; |
| 241 | p.send_line("list")?; | 242 | p.send_line("list")?; |
| 243 | p.expect(format!("fetching refs list: {}...\r\n\r", source_path).as_str())?; | ||
| 242 | // println!("{}", p.expect_eventually("\r\n\r\n")?); | 244 | // println!("{}", p.expect_eventually("\r\n\r\n")?); |
| 245 | let res = p.expect_eventually("\r\n\r\n")?; | ||
| 246 | p.exit()?; | ||
| 247 | for p in [51, 52, 53, 55, 56, 57] { | ||
| 248 | relay::shutdown_relay(8000 + p)?; | ||
| 249 | } | ||
| 243 | assert_eq!( | 250 | assert_eq!( |
| 244 | p.expect_eventually("\r\n\r\n")? | 251 | res.split("\r\n") |
| 245 | .split("\r\n") | ||
| 246 | .map(|e| e.to_string()) | 252 | .map(|e| e.to_string()) |
| 247 | .collect::<HashSet<String>>(), | 253 | .collect::<HashSet<String>>(), |
| 248 | HashSet::from([ | 254 | HashSet::from([ |
| @@ -251,10 +257,6 @@ mod list { | |||
| 251 | format!("{} refs/heads/vnext", vnext_commit_id), | 257 | format!("{} refs/heads/vnext", vnext_commit_id), |
| 252 | ]), | 258 | ]), |
| 253 | ); | 259 | ); |
| 254 | p.exit()?; | ||
| 255 | for p in [51, 52, 53, 55, 56, 57] { | ||
| 256 | relay::shutdown_relay(8000 + p)?; | ||
| 257 | } | ||
| 258 | Ok(()) | 260 | Ok(()) |
| 259 | }); | 261 | }); |
| 260 | // launch relays | 262 | // launch relays |
| @@ -286,6 +288,7 @@ mod list { | |||
| 286 | 288 | ||
| 287 | async fn async_run_test() -> Result<()> { | 289 | async fn async_run_test() -> Result<()> { |
| 288 | let (state_event, source_git_repo) = generate_repo_with_state_event().await?; | 290 | let (state_event, source_git_repo) = generate_repo_with_state_event().await?; |
| 291 | let source_path = source_git_repo.dir.to_str().unwrap().to_string(); | ||
| 289 | 292 | ||
| 290 | let main_commit_id = source_git_repo.get_tip_of_local_branch("main")?; | 293 | let main_commit_id = source_git_repo.get_tip_of_local_branch("main")?; |
| 291 | let example_commit_id = | 294 | let example_commit_id = |
| @@ -315,10 +318,15 @@ mod list { | |||
| 315 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { | 318 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { |
| 316 | let mut p = cli_tester_after_fetch(&git_repo)?; | 319 | let mut p = cli_tester_after_fetch(&git_repo)?; |
| 317 | p.send_line("list")?; | 320 | p.send_line("list")?; |
| 321 | p.expect(format!("fetching refs list: {}...\r\n\r", source_path).as_str())?; | ||
| 318 | // println!("{}", p.expect_eventually("\r\n\r\n")?); | 322 | // println!("{}", p.expect_eventually("\r\n\r\n")?); |
| 323 | let res = p.expect_eventually("\r\n\r\n")?; | ||
| 324 | p.exit()?; | ||
| 325 | for p in [51, 52, 53, 55, 56, 57] { | ||
| 326 | relay::shutdown_relay(8000 + p)?; | ||
| 327 | } | ||
| 319 | assert_eq!( | 328 | assert_eq!( |
| 320 | p.expect_eventually("\r\n\r\n")? | 329 | res.split("\r\n") |
| 321 | .split("\r\n") | ||
| 322 | .map(|e| e.to_string()) | 330 | .map(|e| e.to_string()) |
| 323 | .collect::<HashSet<String>>(), | 331 | .collect::<HashSet<String>>(), |
| 324 | HashSet::from([ | 332 | HashSet::from([ |
| @@ -327,10 +335,7 @@ mod list { | |||
| 327 | format!("{} refs/heads/example-branch", example_commit_id), | 335 | format!("{} refs/heads/example-branch", example_commit_id), |
| 328 | ]), | 336 | ]), |
| 329 | ); | 337 | ); |
| 330 | p.exit()?; | 338 | |
| 331 | for p in [51, 52, 53, 55, 56, 57] { | ||
| 332 | relay::shutdown_relay(8000 + p)?; | ||
| 333 | } | ||
| 334 | Ok(()) | 339 | Ok(()) |
| 335 | }); | 340 | }); |
| 336 | // launch relays | 341 | // launch relays |
| @@ -358,6 +363,7 @@ mod list { | |||
| 358 | 363 | ||
| 359 | async fn async_run_test() -> Result<()> { | 364 | async fn async_run_test() -> Result<()> { |
| 360 | let (state_event, source_git_repo) = generate_repo_with_state_event().await?; | 365 | let (state_event, source_git_repo) = generate_repo_with_state_event().await?; |
| 366 | let source_path = source_git_repo.dir.to_str().unwrap().to_string(); | ||
| 361 | let main_original_commit_id = source_git_repo.get_tip_of_local_branch("main")?; | 367 | let main_original_commit_id = source_git_repo.get_tip_of_local_branch("main")?; |
| 362 | 368 | ||
| 363 | { | 369 | { |
| @@ -398,10 +404,16 @@ mod list { | |||
| 398 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { | 404 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { |
| 399 | let mut p = cli_tester_after_fetch(&git_repo)?; | 405 | let mut p = cli_tester_after_fetch(&git_repo)?; |
| 400 | p.send_line("list")?; | 406 | p.send_line("list")?; |
| 407 | p.expect(format!("fetching refs list: {}...\r\n\r", source_path).as_str())?; | ||
| 408 | |||
| 401 | // println!("{}", p.expect_eventually("\r\n\r\n")?); | 409 | // println!("{}", p.expect_eventually("\r\n\r\n")?); |
| 410 | let res = p.expect_eventually("\r\n\r\n")?; | ||
| 411 | p.exit()?; | ||
| 412 | for p in [51, 52, 53, 55, 56, 57] { | ||
| 413 | relay::shutdown_relay(8000 + p)?; | ||
| 414 | } | ||
| 402 | assert_eq!( | 415 | assert_eq!( |
| 403 | p.expect_eventually("\r\n\r\n")? | 416 | res.split("\r\n") |
| 404 | .split("\r\n") | ||
| 405 | .map(|e| e.to_string()) | 417 | .map(|e| e.to_string()) |
| 406 | .collect::<HashSet<String>>(), | 418 | .collect::<HashSet<String>>(), |
| 407 | HashSet::from([ | 419 | HashSet::from([ |
| @@ -410,10 +422,6 @@ mod list { | |||
| 410 | format!("{} refs/heads/example-branch", example_commit_id), | 422 | format!("{} refs/heads/example-branch", example_commit_id), |
| 411 | ]), | 423 | ]), |
| 412 | ); | 424 | ); |
| 413 | p.exit()?; | ||
| 414 | for p in [51, 52, 53, 55, 56, 57] { | ||
| 415 | relay::shutdown_relay(8000 + p)?; | ||
| 416 | } | ||
| 417 | Ok(()) | 425 | Ok(()) |
| 418 | }); | 426 | }); |
| 419 | // launch relays | 427 | // launch relays |