Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create an option to ignore tags with Array of string #105

Merged
merged 1 commit into from
Oct 15, 2017
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
4 changes: 4 additions & 0 deletions lib/_examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ module.exports = {
description: 'Create release notes for all the tags in the repository.',
code: 'gren release --tags=all'
},
{
description: 'Ignore the tags including an Array of strings',
code: 'gren release --tags=all --ignore-tags-with="-rc","-alpha","-beta"'
},
{
name: 'Work with milestones',
description: 'Create release notes for a tag using the belonging to a milestone that matches the name of the tag. e.g. If the tag is 4.0.0, `gren` is going to match the milestone _"Release 4.0.0"_.',
Expand Down
9 changes: 8 additions & 1 deletion lib/_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,18 @@ module.exports = {
action: /^(merge|commits|all)$/i,
defaultValue: 'commits'
},
{
short: '-i',
name: 'ignore-tags-with',
valueType: '<string1>,<string2>',
description: 'Ignore tags that contain one of the specified strings.',
action: value => value.split(',')
},
{
short: '-C',
name: 'ignore-commits-with',
valueType: '<string1>,<string2>',
description: 'Ignore commits that contains one of the specified strings.',
description: 'Ignore commits that contain one of the specified strings.',
action: value => value.split(',')
},
{
Expand Down
5 changes: 4 additions & 1 deletion lib/src/Gren.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ class Gren {
tags,
ignoreLabels,
ignoreIssuesWith,
ignoreCommitsWith
ignoreCommitsWith,
ignoreTagsWith
} = this.options;

this.options.tags = utils.convertStringToArray(tags);
this.options.ignoreLabels = utils.convertStringToArray(ignoreLabels);
this.options.ignoreIssuesWith = utils.convertStringToArray(ignoreIssuesWith);
this.options.ignoreCommitsWith = utils.convertStringToArray(ignoreCommitsWith);
this.options.ignoreTagsWith = utils.convertStringToArray(ignoreTagsWith);
this.options.limit = this.options.tags.indexOf('all') >= 0 ? MAX_TAGS_LIMIT : TAGS_LIMIT;

if (!token) {
Expand Down Expand Up @@ -313,6 +315,7 @@ class Gren {

const filteredTags = (this._getSelectedTags(tags) || [tags[0], tags[1]])
.filter(Boolean)
.filter(({ name }) => this.options.ignoreTagsWith.every(ignoreTag => !name.match(ignoreTag)))
.map(tag => {
const tagRelease = releases ? releases.filter(release => release.tag_name === tag.name)[0] : false;
const releaseId = tagRelease ? tagRelease.id : null;
Expand Down
13 changes: 12 additions & 1 deletion test/Gren.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ describe('Gren', () => {
});

describe('_getSelectedTags', () => {
// gren.options.tags = [2, 1];
it('Should return all the tags', () => {
gren.options.tags = 'all';
assert.deepEqual(gren._getSelectedTags(tags), tags, 'The tags option is all');
Expand Down Expand Up @@ -546,6 +545,18 @@ describe('Gren', () => {
.catch(err => done(err));
});

it('_getLastTags', done => {
gren.options.ignoreTagsWith = ['11'];
gren.options.tags = ['0.12.0', '0.11.0'];

gren._getLastTags()
.then(tags => {
assert.notInclude(tags.map(({ name }) => name), '0.11.0', 'The ignored tag is not present');
done();
})
.catch(err => done(err));
});

it('_getReleaseBlocks', done => {
gren._getReleaseBlocks()
.then(releaseBlocks => {
Expand Down