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

Add all tags option #38

Merged
merged 1 commit into from
Mar 10, 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
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ The module will look for the last tag, get all the issues closed in the time bet
Following the options for the module:

- `--action=release|changelog` The **gren** action to run. Default: `release` _(see details below for changelog generator)_
- `--tags=0.1.0|0.2.0,0.1.0` A specific tag or the range of tags to build the release notes from.
- `--tags=0.1.0|0.2.0,0.1.0|all` A specific tag or the range of tags to build the release notes from. You can also specify `all` to write all releases. _(To override existing releases use the --override flag)_
- `--ignore-labels=wont_fix|wont_fix,duplicate` One or more labels to ignore in the output. Default: `false` _(it will still output the issue, just without the specified labels)_
- `--ignore-issues-with=wont_fix|wont_fix,duplicate` Ignore issues that contains one of the specified labels. Default: `false`
- `--time-wrap=latest|history` The release notes you want to include in the changelog. Default: `latest` _Only applicable to the `changelog` action_
Expand Down Expand Up @@ -152,6 +152,14 @@ If you want then to override, simple use:
gren --override --tags=0.3.0
```

### Write all existing tags

You can run the task to generate release notes for all existing tags.
Releases that already exist will be skipped. To override them, use the flag `--override`

```
gren --override --tags=all
```

## Changelog Generator

Expand Down
26 changes: 17 additions & 9 deletions src/gren.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function editRelease(gren, releaseId, releaseOptions) {

var release = response.data;

console.log(chalk.green('\n\n' + release.name + ' has been successfully updated!'));
console.log(chalk.green(release.name + ' has been successfully updated!'));

return release;
});
Expand Down Expand Up @@ -92,7 +92,7 @@ function createRelease(gren, releaseOptions) {
loaded();
var release = response.data;

console.log(chalk.green('\n\n' + release.name + ' has been successfully created!'));
console.log(chalk.green(release.name + ' has been successfully created!'));

return release;
});
Expand All @@ -119,6 +119,12 @@ function prepareRelease(gren, block) {
};

if (block.id) {
if (!gren.options.override) {
console.warn(chalk.yellow('Skipping ' + block.release + ' (use --override to replace it)'));

return Promise.resolve();
}

return editRelease(gren, block.id, releaseOptions);
}

Expand All @@ -132,12 +138,16 @@ function prepareRelease(gren, block) {
* @since 0.5.0
* @private
*
* @param {Boolean|Array} selectedTags
* @param {Array|string} selectedTags
* @param {Object[]} tags
*
* @return {Boolean|Array}
*/
function getSelectedTags(optionTags, tags) {
if (optionTags.indexOf('all') >= 0) {
return tags;
}

if (!optionTags.length) {
return false;
}
Expand Down Expand Up @@ -185,10 +195,6 @@ function getLastTags(gren, releases) {
};
});

if (filteredTags[0].releaseId && !gren.options.override) {
throw chalk.red(filteredTags[0].tag.name + ' is a release, use --override flag to override an existing release!');
}

console.log('Tags found: ' + filteredTags.map(function(tag) {
return tag.tag.name;
}).join(', '));
Expand Down Expand Up @@ -575,7 +581,7 @@ function getClosedIssues(gren, releaseRanges) {
* @return {Promise[]}
*/
function getIssueBlocks(gren, releaseRanges) {
console.log('\nCreating the body blocks from releases:');
console.log('Creating the body blocks from releases:');

return getClosedIssues(gren, releaseRanges)
.then(function(issues) {
Expand Down Expand Up @@ -862,7 +868,9 @@ GithubReleaseNotes.prototype.release = function() {
);
})
.then(function(blocks) {
return prepareRelease(gren, blocks[0]);
return blocks.reduce(function(carry, block) {
return carry.then(prepareRelease.bind(null, gren, block));
}, Promise.resolve());
});
};

Expand Down
2 changes: 1 addition & 1 deletion test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ exports['utils'] = {

test.done();
}
};
};