diff --git a/src/util/pull-request-title.ts b/src/util/pull-request-title.ts index 375a7eef9..c9df13721 100644 --- a/src/util/pull-request-title.ts +++ b/src/util/pull-request-title.ts @@ -47,7 +47,7 @@ export function generateMatchPattern( .replace('(', '\\(') .replace(')', '\\)') .replace('${scope}', '(\\((?[\\w-./]+)\\))?') - .replace('${component}', ' ?(?[\\w-./]*)?') + .replace('${component}', ' ?(?@?[\\w-./]*)?') .replace('${version}', 'v?(?[0-9].*)') .replace('${branch}', '(?[\\w-./]+)?')}$` ); diff --git a/test/util/pull-request-title.ts b/test/util/pull-request-title.ts index 947b79d2b..c44447fbc 100644 --- a/test/util/pull-request-title.ts +++ b/test/util/pull-request-title.ts @@ -133,7 +133,7 @@ describe('PullRequestTitle', () => { it('return matchPattern with default Pattern', () => { const matchPattern = generateMatchPattern(); expect(matchPattern).to.eql( - /^chore(\((?[\w-./]+)\))?: release ?(?[\w-./]*)? v?(?[0-9].*)$/ + /^chore(\((?[\w-./]+)\))?: release ?(?@?[\w-./]*)? v?(?[0-9].*)$/ ); }); }); @@ -202,6 +202,16 @@ describe('PullRequestTitle with custom pullRequestTitlePattern', () => { expect(pullRequestTitle?.getVersion()?.toString()).to.eql('1.2.3'); }); + it('parses a component with @ sign prefix', () => { + const name = 'chore(main): 🔖 release @example/storage v1.2.3'; + const pullRequestTitle = PullRequestTitle.parse( + name, + 'chore${scope}: 🔖 release${component} ${version}' + ); + expect(pullRequestTitle).to.not.be.undefined; + expect(pullRequestTitle?.getComponent()).to.eql('@example/storage'); + }); + it('fails to parse', () => { const pullRequestTitle = PullRequestTitle.parse( 'release-foo', @@ -224,7 +234,7 @@ 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; @@ -232,7 +242,7 @@ describe('PullRequestTitle with custom pullRequestTitlePattern', () => { 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', () => { @@ -287,7 +297,7 @@ describe('PullRequestTitle with custom pullRequestTitlePattern', () => { 'chore${scope}: 🔖 release${component} ${version}' ); expect(matchPattern).to.eql( - /^chore(\((?[\w-./]+)\))?: 🔖 release ?(?[\w-./]*)? v?(?[0-9].*)$/ + /^chore(\((?[\w-./]+)\))?: 🔖 release ?(?@?[\w-./]*)? v?(?[0-9].*)$/ ); });