Skip to content
This repository has been archived by the owner on Feb 5, 2018. It is now read-only.

Commit

Permalink
feat(reference): expose prefix
Browse files Browse the repository at this point in the history
Also fix the regex part in parser test as it wasn't testing the regex properly.

Closes #17
  • Loading branch information
stevemao committed Sep 12, 2015
1 parent 0272461 commit 9962dda
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 124 deletions.
10 changes: 6 additions & 4 deletions lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ function parser(raw, options, regex) {
action: action,
owner: owner,
repository: repository,
issue: referenceMatch[2],
raw: referenceMatch[0]
issue: referenceMatch[3],
raw: referenceMatch[0],
prefix: referenceMatch[2]
};
references.push(reference);
}
Expand Down Expand Up @@ -160,8 +161,9 @@ function parser(raw, options, regex) {
action: action,
owner: owner,
repository: repository,
issue: referenceMatch[2],
raw: referenceMatch[0]
issue: referenceMatch[3],
raw: referenceMatch[0],
prefix: referenceMatch[2]
};
references.push(reference);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/regex.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function getReferencePartsRegex(issuePrefixes) {
return reNomatch;
}

return new RegExp('(?:.*?)??\\s*(\\S*?)??(?:' + join(issuePrefixes, '|') + ')(\\d+)', 'gi');
return new RegExp('(?:.*?)??\\s*(\\S*?)??(' + join(issuePrefixes, '|') + ')(\\d+)', 'gi');
}

function getReferencesRegex(referenceActions) {
Expand Down
2 changes: 1 addition & 1 deletion test/cli.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('cli', function() {
cp.stdout
.pipe(concat(function(chunk) {
expect(chunk.toString()).to.include('"scope":"category","type":"fix:subcategory","subject":"My subject"');
expect(chunk.toString()).to.include('"references":[{"action":"Close","owner":null,"repository":null,"issue":"10036","raw":"#10036"},{"action":"fix","owner":null,"repository":null,"issue":"9338","raw":"#9338"}]');
expect(chunk.toString()).to.include('"references":[{"action":"Close","owner":null,"repository":null,"issue":"10036","raw":"#10036","prefix":"#"},{"action":"fix","owner":null,"repository":null,"issue":"9338","raw":"#9338","prefix":"#"}]');
expect(chunk.toString()).to.include('"notes":[{"title":"BREAKING NEWS","text":"A lot of changes!"}]');

done();
Expand Down
12 changes: 8 additions & 4 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,15 @@ describe('conventionalCommitsParser', function() {
owner: null,
repository: null,
issue: '123',
raw: '#123'
raw: '#123',
prefix: '#'
}, {
action: 'fix',
owner: null,
repository: null,
issue: '33',
raw: '#33'
raw: '#33',
prefix: '#'
}]);
} else if (i === 1) {
expect(chunk.type).to.equal('fix');
Expand Down Expand Up @@ -226,13 +228,15 @@ describe('conventionalCommitsParser', function() {
owner: null,
repository: null,
issue: '123',
raw: '#123'
raw: '#123',
prefix: '#'
}, {
action: 'fix',
owner: null,
repository: null,
issue: '33',
raw: '#33'
raw: '#33',
prefix: '#'
}]);
} else if (i === 1) {
expect(chunk.type).to.equal('ng-list');
Expand Down
Loading

0 comments on commit 9962dda

Please sign in to comment.