Skip to content

Commit

Permalink
fix: adding additional labels could potentially break CHANGELOG gener…
Browse files Browse the repository at this point in the history
…ation logic (#133)
  • Loading branch information
bcoe committed May 17, 2019
1 parent ba68930 commit 75933dd
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/github.ts
Expand Up @@ -139,10 +139,7 @@ export class GitHub {
});
for (let i = 0, pull; i < pullsResponse.data.length; i++) {
pull = pullsResponse.data[i];
// we look for a PR that has autorelease: pending, and type: process; once
// a release occurs, the autorelease: pending label is removed.
if (pull.labels.map(l => l.name).sort().join(',') ===
labels.slice(0).sort().join(',')) {
if (this.hasAllLabels(labels, pull.labels.map(l => l.name))) {
// it's expected that a release PR will have a
// HEAD matching the format repo:release-v1.0.0.
if (!pull.head) continue;
Expand All @@ -158,6 +155,14 @@ export class GitHub {
return undefined;
}

private hasAllLabels(labelsA: string[], labelsB: string[]) {
let hasAll = true;
labelsA.forEach((label) => {
if (labelsB.indexOf(label) === -1) hasAll = false;
});
return hasAll;
}

async findOpenReleasePRs(labels: string[], perPage = 25):
Promise<PullsListResponseItem[]> {
const openReleasePRs: PullsListResponseItem[] = [];
Expand Down

0 comments on commit 75933dd

Please sign in to comment.