diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-09-13 20:55:12 +0100 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-09-13 20:55:12 +0100 |
| commit | fb48125595af09c557d03013e4e096d1d072e791 (patch) | |
| tree | 7011c39d48fb44b8bc39b6b7ee5a1e825290d971 /src/bin/git_remote_nostr/utils.rs | |
| parent | b685eefd3ca2821cba3d740d6f114db2d9649a5a (diff) | |
fix(remote): add robustness to push reporting
by avoiding bugs where lines are removed accidentally by storing
report in a mutex and rewriting the entire report at each update
Diffstat (limited to 'src/bin/git_remote_nostr/utils.rs')
| -rw-r--r-- | src/bin/git_remote_nostr/utils.rs | 18 |
1 files changed, 0 insertions, 18 deletions
diff --git a/src/bin/git_remote_nostr/utils.rs b/src/bin/git_remote_nostr/utils.rs index bbe7cfa..a13d398 100644 --- a/src/bin/git_remote_nostr/utils.rs +++ b/src/bin/git_remote_nostr/utils.rs | |||
| @@ -293,24 +293,6 @@ pub fn error_might_be_authentication_related(error: &anyhow::Error) -> bool { | |||
| 293 | false | 293 | false |
| 294 | } | 294 | } |
| 295 | 295 | ||
| 296 | pub fn report_on_sideband_progress(data: &[u8], term: &console::Term) { | ||
| 297 | if let Ok(data) = str::from_utf8(data) { | ||
| 298 | let data = data | ||
| 299 | .split(['\n', '\r']) | ||
| 300 | .find(|line| !line.is_empty()) | ||
| 301 | .unwrap_or(""); | ||
| 302 | if !data.is_empty() { | ||
| 303 | let s = format!("remote: {data}"); | ||
| 304 | let _ = term.clear_last_lines(1); | ||
| 305 | let _ = term.write_line(s.as_str()); | ||
| 306 | if !s.contains('%') || s.contains("100%") { | ||
| 307 | // print it twice so the next sideband_progress doesn't delete it | ||
| 308 | let _ = term.write_line(s.as_str()); | ||
| 309 | } | ||
| 310 | } | ||
| 311 | } | ||
| 312 | } | ||
| 313 | |||
| 314 | #[cfg(test)] | 296 | #[cfg(test)] |
| 315 | mod tests { | 297 | mod tests { |
| 316 | use super::*; | 298 | use super::*; |