From 73ccdb767561768b9b6d50252716b81e40d8f419 Mon Sep 17 00:00:00 2001 From: Tyler James Leonhardt Date: Mon, 9 May 2022 09:03:17 -0700 Subject: [PATCH] Inform the user the actual branch name that will be used in the branchName inputbox (#148964) --- extensions/git/src/commands.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index a3479a0b3b5..19cc2254a8b 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -5,7 +5,7 @@ import * as os from 'os'; import * as path from 'path'; -import { Command, commands, Disposable, LineChange, MessageOptions, Position, ProgressLocation, QuickPickItem, Range, SourceControlResourceState, TextDocumentShowOptions, TextEditor, Uri, ViewColumn, window, workspace, WorkspaceEdit, WorkspaceFolder, TimelineItem, env, Selection, TextDocumentContentProvider } from 'vscode'; +import { Command, commands, Disposable, LineChange, MessageOptions, Position, ProgressLocation, QuickPickItem, Range, SourceControlResourceState, TextDocumentShowOptions, TextEditor, Uri, ViewColumn, window, workspace, WorkspaceEdit, WorkspaceFolder, TimelineItem, env, Selection, TextDocumentContentProvider, InputBoxValidationSeverity } from 'vscode'; import TelemetryReporter from '@vscode/extension-telemetry'; import * as nls from 'vscode-nls'; import { Branch, ForcePushMode, GitErrorCodes, Ref, RefType, Status, CommitOptions, RemoteSourcePublisher } from './api/git'; @@ -1787,8 +1787,17 @@ export class CommandCenter { ignoreFocusOut: true, validateInput: (name: string) => { const validateName = new RegExp(branchValidationRegex); - if (validateName.test(sanitize(name))) { - return null; + const sanitizedName = sanitize(name); + if (validateName.test(sanitizedName)) { + // If the sanitized name that we will use is different than what is + // in the input box, show an info message to the user informing them + // the branch name that will be used. + return name === sanitizedName + ? null + : { + message: localize('branch name does not match sanitized', "The new branch will be '{0}'", sanitizedName), + severity: InputBoxValidationSeverity.Info + }; } return localize('branch name format invalid', "Branch name needs to match regex: {0}", branchValidationRegex);