Fix: Git warning messages incorrectly shown with error styling#309944
Open
Nedunchezhiyan-M wants to merge 2 commits intomicrosoft:mainfrom
Open
Fix: Git warning messages incorrectly shown with error styling#309944Nedunchezhiyan-M wants to merge 2 commits intomicrosoft:mainfrom
Nedunchezhiyan-M wants to merge 2 commits intomicrosoft:mainfrom
Conversation
When git or SSH outputs lines prefixed with "warning:" (e.g.
"Warning: Permanently added 'gitlab.com' to the list of known hosts"),
VS Code was showing the notification with error-level styling (red icon)
because the default case in the command error handler never inspected the
message severity.
Check for a leading "warning:" prefix (case-insensitive) in the raw
stderr/stdout before showing the notification. When detected, use warning
styling and make the notification non-modal, matching the treatment of
known warning-level git error codes such as Conflict and StashConflict.
Also strip the "warning: " prefix from the displayed hint text so it is
not doubled up ("Git: Warning: ...").
Fixes microsoft#280834
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @lszomoruMatched files:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #280834
What changed
When
gitor SSH outputs a line prefixed withwarning:(e.g.Warning: Permanently added 'gitlab.com' to the list of known hosts), VS Code was displaying the notification with error-level styling (red icon, modal). This is misleading — the message is informational and a normal part of SSH's first-time host-key acceptance flow.Root cause: The
defaultbranch of thegitErrorCodeswitch inCommandCenternever inspected the raw message text, so all unrecognized errors fell through astype = 'error'.Fix: In the
defaultcase, test the raw stderr/stdout for a leadingwarning:prefix (case-insensitive, multiline). When matched:type = 'warning'→ yellow warning icon instead of red error iconoptions.modal = false→ non-blocking, consistent with howConflictandCherryPickConflictare shownwarning:prefix fromhintLines(mirrors existingerror:stripping) so the notification readsGit: Permanently added ...rather thanGit: Warning: Permanently added ...All existing known
GitErrorCodecases are unaffected.How to test
ssh-keygen -R gitlab.comAfter: yellow non-modal warning notification reading
Git: Permanently added 'gitlab.com' to the list of known hostsNotes
A previous attempt was opened and closed by its author who thought the issue was already addressed elsewhere — it was not. This PR implements the same intent but also strips the
warning:prefix from the displayed text.