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

Prev Previous commit
Next Next commit
added correctBranchName function
this function will convert any invalid charcters from the branch name to -
  • Loading branch information
barakd committed Sep 17, 2016
commit 368dfc1e3c87d88549cf7b74bacbfbfbf3e4251e
3 changes: 1 addition & 2 deletions src/vs/workbench/parts/git/common/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,8 @@ export interface IAskpassService {
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.


export function isValidBranchName(value: string): boolean {
return !/^\.|\/\.|\.\.|~|\^|:|\/$|\.lock$|\.lock\/|\\|\*|\s|^\s*$/.test(value);
return !invalidBranchPatternName.test(value);
}

export function correctBranchName(branchName: string): string{
return branchName.replace(invalidBranchPatternName, '-');
}