Skip to content

Commit

Permalink
feat: support for "@" sign in component name
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Russak authored and raaymax committed Mar 13, 2023
1 parent 9509dcf commit 87fb708
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/util/pull-request-title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function generateMatchPattern(
.replace('(', '\\(')
.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
8 changes: 4 additions & 4 deletions test/util/pull-request-title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,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 @@ -224,15 +224,15 @@ describe('PullRequestTitle with custom pullRequestTitlePattern', () => {

it('parses a complex title and pattern', () => {
const pullRequestTitle = PullRequestTitle.parse(
'[HOTFIX] - chore(hotfix/v3.1.0-bug): release 3.1.0-hotfix1 (storage)',
'[HOTFIX] - chore(hotfix/v3.1.0-bug): release 3.1.0-hotfix1 (@example/storage)',
'[HOTFIX] - chore${scope}: release ${version} (${component})'
);
expect(pullRequestTitle).to.not.be.undefined;
expect(pullRequestTitle?.getTargetBranch()).to.eql('hotfix/v3.1.0-bug');
expect(pullRequestTitle?.getVersion()?.toString()).to.eql(
'3.1.0-hotfix1'
);
expect(pullRequestTitle?.getComponent()).to.eql('storage');
expect(pullRequestTitle?.getComponent()).to.eql('@example/storage');
});
});
describe('ofVersion', () => {
Expand Down Expand Up @@ -287,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

0 comments on commit 87fb708

Please sign in to comment.