-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Git quick open should correct invalid branch names #12194
Git quick open should correct invalid branch names #12194
Conversation
this function will convert any invalid charcters from the branch name to -
instead of not showing any branches when trying to create a new branch
Hi @barakd, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! TTYL, MSBOT; |
@barakd, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -339,7 +339,11 @@ export interface IAskpassService { | |||
} | |||
|
|||
// Utils | |||
const invalidBranchPatternName = /(^\.)|(\/\.)|(\.\.)|(~)|(\^)|(:)|(\/$)|(\.lock$)|(\.lock\/)|(\\)|(\*)|(\s)|(^\s*$)|(\.$)/g; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why wrapping everything in groups? The regex is now broken since the ^
and $
were making sure the whole string is matched.
} else if (exactMatches.length === 0 && isValidBranchName(input)) { | ||
} else if (exactMatches.length === 0) { | ||
if (!isValidBranchName(input)) { | ||
input = correctBranchName(input); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we do the same for the git branch
command?
…ttps://github.com/barakd/vscode into git_quick_open_should_correct_invalid_branch_names
Awesome, thanks! |
Currently whenever you try to checkout to a new branch, using the git quick open,
it will only work as long as your branch name is valid.
if your branch name is invalid you will only get "No other branches".
On this PR I am adjusting this behaviour so vscode will correct any invalid characters from the branch name, and still offer the option of creating a new branch.
Original Behaviour:
New Behaviour: