Skip to content

Commit 5e14ac8

Browse files
authored
Add all tags option (#38)
1 parent 37d66e9 commit 5e14ac8

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ The module will look for the last tag, get all the issues closed in the time bet
6060
Following the options for the module:
6161

6262
- `--action=release|changelog` The **gren** action to run. Default: `release` _(see details below for changelog generator)_
63-
- `--tags=0.1.0|0.2.0,0.1.0` A specific tag or the range of tags to build the release notes from.
63+
- `--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)_
6464
- `--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)_
6565
- `--ignore-issues-with=wont_fix|wont_fix,duplicate` Ignore issues that contains one of the specified labels. Default: `false`
6666
- `--time-wrap=latest|history` The release notes you want to include in the changelog. Default: `latest` _Only applicable to the `changelog` action_
@@ -152,6 +152,14 @@ If you want then to override, simple use:
152152
gren --override --tags=0.3.0
153153
```
154154

155+
### Write all existing tags
156+
157+
You can run the task to generate release notes for all existing tags.
158+
Releases that already exist will be skipped. To override them, use the flag `--override`
159+
160+
```
161+
gren --override --tags=all
162+
```
155163

156164
## Changelog Generator
157165

src/gren.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function editRelease(gren, releaseId, releaseOptions) {
5959

6060
var release = response.data;
6161

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

6464
return release;
6565
});
@@ -92,7 +92,7 @@ function createRelease(gren, releaseOptions) {
9292
loaded();
9393
var release = response.data;
9494

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

9797
return release;
9898
});
@@ -119,6 +119,12 @@ function prepareRelease(gren, block) {
119119
};
120120

121121
if (block.id) {
122+
if (!gren.options.override) {
123+
console.warn(chalk.yellow('Skipping ' + block.release + ' (use --override to replace it)'));
124+
125+
return Promise.resolve();
126+
}
127+
122128
return editRelease(gren, block.id, releaseOptions);
123129
}
124130

@@ -132,12 +138,16 @@ function prepareRelease(gren, block) {
132138
* @since 0.5.0
133139
* @private
134140
*
135-
* @param {Boolean|Array} selectedTags
141+
* @param {Array|string} selectedTags
136142
* @param {Object[]} tags
137143
*
138144
* @return {Boolean|Array}
139145
*/
140146
function getSelectedTags(optionTags, tags) {
147+
if (optionTags.indexOf('all') >= 0) {
148+
return tags;
149+
}
150+
141151
if (!optionTags.length) {
142152
return false;
143153
}
@@ -185,10 +195,6 @@ function getLastTags(gren, releases) {
185195
};
186196
});
187197

188-
if (filteredTags[0].releaseId && !gren.options.override) {
189-
throw chalk.red(filteredTags[0].tag.name + ' is a release, use --override flag to override an existing release!');
190-
}
191-
192198
console.log('Tags found: ' + filteredTags.map(function(tag) {
193199
return tag.tag.name;
194200
}).join(', '));
@@ -575,7 +581,7 @@ function getClosedIssues(gren, releaseRanges) {
575581
* @return {Promise[]}
576582
*/
577583
function getIssueBlocks(gren, releaseRanges) {
578-
console.log('\nCreating the body blocks from releases:');
584+
console.log('Creating the body blocks from releases:');
579585

580586
return getClosedIssues(gren, releaseRanges)
581587
.then(function(issues) {
@@ -862,7 +868,9 @@ GithubReleaseNotes.prototype.release = function() {
862868
);
863869
})
864870
.then(function(blocks) {
865-
return prepareRelease(gren, blocks[0]);
871+
return blocks.reduce(function(carry, block) {
872+
return carry.then(prepareRelease.bind(null, gren, block));
873+
}, Promise.resolve());
866874
});
867875
};
868876

test/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ exports['utils'] = {
4040

4141
test.done();
4242
}
43-
};
43+
};

0 commit comments

Comments
 (0)