Skip to content
Snippets Groups Projects
Unverified Commit a2c39b91 authored by Rhys Arkins's avatar Rhys Arkins Committed by GitHub
Browse files

fix: branchName massage hyphens (#12622)

parent 1863c02e
No related branches found
No related tags found
No related merge requests found
...@@ -220,7 +220,7 @@ describe('workers/repository/updates/branch-name', () => { ...@@ -220,7 +220,7 @@ describe('workers/repository/updates/branch-name', () => {
}, },
{ {
upgrade: { branchName: 'renovate/~bad-branch-name2' }, upgrade: { branchName: 'renovate/~bad-branch-name2' },
expectedBranchName: 'renovate/-bad-branch-name2', expectedBranchName: 'renovate/bad-branch-name2',
}, },
{ {
upgrade: { branchName: 'renovate/bad-branch-^-name3' }, upgrade: { branchName: 'renovate/bad-branch-^-name3' },
...@@ -258,6 +258,10 @@ describe('workers/repository/updates/branch-name', () => { ...@@ -258,6 +258,10 @@ describe('workers/repository/updates/branch-name', () => {
upgrade: { branchName: 'renovate/bad--branch---name11' }, upgrade: { branchName: 'renovate/bad--branch---name11' },
expectedBranchName: 'renovate/bad-branch-name11', expectedBranchName: 'renovate/bad-branch-name11',
}, },
{
upgrade: { branchName: 'renovate-/[start]-something-[end]' },
expectedBranchName: 'renovate/start-something-end',
},
]; ];
fixtures.forEach((fixture) => { fixtures.forEach((fixture) => {
generateBranchName(fixture.upgrade); generateBranchName(fixture.upgrade);
......
...@@ -24,6 +24,8 @@ function cleanBranchName(branchName: string): string { ...@@ -24,6 +24,8 @@ function cleanBranchName(branchName: string): string {
.replace(regEx(/\/\./g), '/') // leading dot after slash .replace(regEx(/\/\./g), '/') // leading dot after slash
.replace(regEx(/\s/g), '') // whitespace .replace(regEx(/\s/g), '') // whitespace
.replace(regEx(/[[\]?:\\^~]/g), '-') // massage out all these characters: : ? [ \ ^ ~ .replace(regEx(/[[\]?:\\^~]/g), '-') // massage out all these characters: : ? [ \ ^ ~
.replace(regEx(/(^|\/)-+/g), '$1') // leading dashes
.replace(regEx(/-+(\/|$)/g), '$1') // trailing dashes
.replace(RE_MULTIPLE_DASH, '-'); // chained dashes .replace(RE_MULTIPLE_DASH, '-'); // chained dashes
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment