From 3a59a463adb50878a7e0d9a27db31b36a4d3f475 Mon Sep 17 00:00:00 2001 From: Mike Penz Date: Fri, 30 Apr 2021 10:29:09 +0200 Subject: [PATCH] - slightly improve filtering code - format config / readme --- README.md | 4 +- .../configuration_base_branches_develop.json | 39 +++++++++++-------- .../configuration_base_branches_main.json | 39 +++++++++++-------- src/releaseNotes.ts | 7 ++-- 4 files changed, 51 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index a28e2b7..02ae326 100644 --- a/README.md +++ b/README.md @@ -191,7 +191,9 @@ This configuration is a `.json` file in the following format. "tag_resolver": { "method": "semver" }, - "base_branches": [] + "base_branches": [ + "dev" + ] } ``` diff --git a/configs_test/configuration_base_branches_develop.json b/configs_test/configuration_base_branches_develop.json index dc1f435..ab7f59a 100644 --- a/configs_test/configuration_base_branches_develop.json +++ b/configs_test/configuration_base_branches_develop.json @@ -1,19 +1,24 @@ { - "categories": [ - { - "title": "", - "labels": ["dev", "Bump"] - } - ], - "ignore_labels": [], - "sort": "DESC", - "pr_template": "${{NUMBER}}", - "label_extractor": [ - { - "pattern": ".*(dev|Bump).*", - "target": "$1", - "on_property": "title" - } - ], - "base_branches": ["develop"] + "categories": [ + { + "title": "", + "labels": [ + "dev", + "Bump" + ] + } + ], + "ignore_labels": [], + "sort": "DESC", + "pr_template": "${{NUMBER}}", + "label_extractor": [ + { + "pattern": ".*(dev|Bump).*", + "target": "$1", + "on_property": "title" + } + ], + "base_branches": [ + "develop" + ] } \ No newline at end of file diff --git a/configs_test/configuration_base_branches_main.json b/configs_test/configuration_base_branches_main.json index 6a14020..6310639 100644 --- a/configs_test/configuration_base_branches_main.json +++ b/configs_test/configuration_base_branches_main.json @@ -1,19 +1,24 @@ { - "categories": [ - { - "title": "", - "labels": ["dev", "Bump"] - } - ], - "ignore_labels": [], - "sort": "DESC", - "pr_template": "${{NUMBER}}", - "label_extractor": [ - { - "pattern": ".*(dev|Bump).*", - "target": "$1", - "on_property": "title" - } - ], - "base_branches": ["main"] + "categories": [ + { + "title": "", + "labels": [ + "dev", + "Bump" + ] + } + ], + "ignore_labels": [], + "sort": "DESC", + "pr_template": "${{NUMBER}}", + "label_extractor": [ + { + "pattern": ".*(dev|Bump).*", + "target": "$1", + "on_property": "title" + } + ], + "base_branches": [ + "main" + ] } \ No newline at end of file diff --git a/src/releaseNotes.ts b/src/releaseNotes.ts index 4d4500b..c7d4d27 100755 --- a/src/releaseNotes.ts +++ b/src/releaseNotes.ts @@ -128,11 +128,12 @@ export class ReleaseNotes { return commmit.sha }) + // retrieve base branches we allow + const baseBranches = configuration.base_branches || DefaultConfiguration.base_branches + const allBaseBranchesAllowed = baseBranches.length === 0 + // return only the pull requests associated with this release return pullRequests.filter(pr => { - const baseBranches = configuration.base_branches || DefaultConfiguration.base_branches - const allBaseBranchesAllowed = baseBranches.length === 0 - return releaseCommitHashes.includes(pr.mergeCommitSha) && (allBaseBranchesAllowed || baseBranches.includes(pr.baseBranch)) })