diff --git a/docs/options.md b/docs/options.md index ecbd5571..7bf13b99 100644 --- a/docs/options.md +++ b/docs/options.md @@ -58,6 +58,10 @@ Via the configuration file you can have more complex grouping, using labels in a In this case `gren` will group all the issues labeled with `enhancement` and `internal` under the title _"Enhancements: "_ and all the ones with `bug` under the title _"Bug Fixes: "_. +#### Issues with multiple labels + +In case an issue has more than a specified label (e.g. both "enhancement" and "bug"), `gren` will prioritise based on the order (i.e. the issue will only appear in the "Enhancements" group). + ### Extensions The accepted file extensions are the following: diff --git a/lib/src/Gren.js b/lib/src/Gren.js index 940ee1f3..f4fb9bdb 100644 --- a/lib/src/Gren.js +++ b/lib/src/Gren.js @@ -748,7 +748,7 @@ class Gren { } const allLabels = Object.values(groupBy).reduce((carry, group) => carry.concat(group), []); - const groups = Object.keys(groupBy).reduce((carry, group) => { + const groups = Object.keys(groupBy).reduce((carry, group, i, arr) => { const groupIssues = issues.filter(issue => { if (!issue.labels.length && this.options.template.noLabel) { issue.labels.push({name: this.options.template.noLabel}); @@ -758,7 +758,7 @@ class Gren { const isOtherLabel = groupBy[group].indexOf('...') !== -1 && allLabels.indexOf(label.name) === -1; return groupBy[group].indexOf(label.name) !== -1 || isOtherLabel; - }); + }) && !arr.filter(title => carry[title]).some(title => carry[title].indexOf(this._templateIssue(issue)) !== -1); }).map(this._templateIssue.bind(this)); if (groupIssues.length) {