From 74fc52d5cec8461184083f5fa2955038f245d2ed Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Mon, 3 Mar 2025 18:16:50 -0800 Subject: [PATCH] Git Beta: Fix a few cases of empty toasts showing up (#25985) Improve parsing of git remote outputs Release Notes: - N/A --- crates/git_ui/src/remote_output_toast.rs | 41 ++++++++++++++++-------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/crates/git_ui/src/remote_output_toast.rs b/crates/git_ui/src/remote_output_toast.rs index c156dcc0e7f9c37fd27bf0f72e385104062fc5b7..dd00da080b3dcc34346052b5af3b22e36b75162e 100644 --- a/crates/git_ui/src/remote_output_toast.rs +++ b/crates/git_ui/src/remote_output_toast.rs @@ -71,7 +71,7 @@ impl RemoteOutputToast { } }); - let message; + let mut message: SharedString; let remote; match action { @@ -86,19 +86,32 @@ impl RemoteOutputToast { RemoteAction::Push(remote_ref) => { message = output.stdout.trim().to_string().into(); - let remote_message = get_remote_lines(&output.stderr); - let finder = LinkFinder::new(); - let links = finder - .links(&remote_message) - .filter(|link| *link.kind() == LinkKind::Url) - .map(|link| link.start()..link.end()) - .collect_vec(); - - remote = Some(InfoFromRemote { - name: remote_ref.name, - remote_text: remote_message.into(), - links, - }); + if message.is_empty() { + message = output.stderr.trim().to_string().into(); + if message.is_empty() { + message = "Push Successful".into(); + } + remote = None; + } else { + let remote_message = get_remote_lines(&output.stderr); + + remote = if remote_message.is_empty() { + None + } else { + let finder = LinkFinder::new(); + let links = finder + .links(&remote_message) + .filter(|link| *link.kind() == LinkKind::Url) + .map(|link| link.start()..link.end()) + .collect_vec(); + + Some(InfoFromRemote { + name: remote_ref.name, + remote_text: remote_message.into(), + links, + }) + } + } } }