Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/util/pull-request-title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function generateMatchPattern(pullRequestTitlePattern?: string): RegExp {
.replace('[', '\\[') // TODO: handle all regex escaping
.replace(']', '\\]')
.replace('${scope}', '(\\((?<branch>[\\w-./]+)\\))?')
.replace('${component}', ' ?(?<component>[\\w-.]*)?')
.replace('${component}', ' ?(?<component>[\\w-./]*)?')
.replace('${version}', 'v?(?<version>[0-9].*)')
.replace('${branch}', '(?<branch>[\\w-./]+)?')}$`
);
Expand Down
13 changes: 11 additions & 2 deletions test/util/pull-request-title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ describe('PullRequestTitle', () => {
expect(pullRequestTitle?.getVersion()?.toString()).to.eql('1.2.3');
});

it('parses a target branch and component with a slash', () => {
const name = 'chore(main): release some/title-test 0.0.1';
const pullRequestTitle = PullRequestTitle.parse(name);
expect(pullRequestTitle).to.not.be.undefined;
expect(pullRequestTitle?.getTargetBranch()).to.eql('main');
expect(pullRequestTitle?.getComponent()).to.eql('some/title-test');
expect(pullRequestTitle?.getVersion()?.toString()).to.eql('0.0.1');
});

it('fails to parse', () => {
const pullRequestTitle = PullRequestTitle.parse('release-foo');
expect(pullRequestTitle).to.be.undefined;
Expand Down Expand Up @@ -124,7 +133,7 @@ describe('PullRequestTitle', () => {
it('return matchPattern with default Pattern', () => {
const matchPattern = generateMatchPattern();
expect(matchPattern).to.eql(
/^chore(\((?<branch>[\w-./]+)\))?: release ?(?<component>[\w-.]*)? v?(?<version>[0-9].*)$/
/^chore(\((?<branch>[\w-./]+)\))?: release ?(?<component>[\w-./]*)? v?(?<version>[0-9].*)$/
);
});
});
Expand Down Expand Up @@ -278,7 +287,7 @@ describe('PullRequestTitle with custom pullRequestTitlePattern', () => {
'chore${scope}: 🔖 release${component} ${version}'
);
expect(matchPattern).to.eql(
/^chore(\((?<branch>[\w-./]+)\))?: 🔖 release ?(?<component>[\w-.]*)? v?(?<version>[0-9].*)$/
/^chore(\((?<branch>[\w-./]+)\))?: 🔖 release ?(?<component>[\w-./]*)? v?(?<version>[0-9].*)$/
);
});

Expand Down