Skip to content
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

Conversation

barakd
Copy link
Contributor

@barakd barakd commented Sep 17, 2016

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:
original - invalid branch name
New Behaviour:
after pr - invalid branch name

barakd added 3 commits September 17, 2016 19:47
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
@msftclas
Copy link

Hi @barakd, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!

In order for us to evaluate and accept your PR, we ask that you sign a contribution license agreement. It's all electronic and will take just minutes. I promise there's no faxing. https://cla.microsoft.com.

TTYL, MSBOT;

@msftclas
Copy link

@barakd, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR.

Thanks, MSBOT;

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0003%) to 61.105% when pulling 8421e72 on barakd:git_quick_open_should_correct_invalid_branch_names into 1316454 on Microsoft:master.

Copy link
Member

@joaomoreno joaomoreno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall great idea, just needs some tweaking.

On top of the inline comments, there is also the following issue:

When running the git checkout command without a branch name, there is a suggestion to create a - branch.

image

@@ -339,7 +339,11 @@ export interface IAskpassService {
}

// Utils
const invalidBranchPatternName = /(^\.)|(\/\.)|(\.\.)|(~)|(\^)|(:)|(\/$)|(\.lock$)|(\.lock\/)|(\\)|(\*)|(\s)|(^\s*$)|(\.$)/g;
Copy link
Member

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);
Copy link
Member

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?

@joaomoreno joaomoreno merged commit 7d89faa into microsoft:master Oct 21, 2016
@joaomoreno
Copy link
Member

Awesome, thanks!

@barakd barakd deleted the git_quick_open_should_correct_invalid_branch_names branch October 21, 2016 15:29
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants