From ba9967c5046cb900fba87df742c735ca7973c418 Mon Sep 17 00:00:00 2001 From: Mikhail Bulash Date: Thu, 3 Mar 2022 21:33:40 +0100 Subject: [PATCH] Filter by `commitish` regardless of the `refs/heads` prefix (#1089) Co-authored-by: Mikhail Bulash --- dist/index.js | 8 +++++++- lib/releases.js | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 083d74fe1..6e5a773ba 100644 --- a/dist/index.js +++ b/dist/index.js @@ -129153,8 +129153,14 @@ const findReleases = async ({ log({ context, message: `Found ${releases.length} releases` }) + // `refs/heads/branch` and `branch` are the same thing in this context + const headRefRegex = /^refs\/heads\// + const targetCommitishName = targetCommitish.replace(headRefRegex, '') const filteredReleases = filterByCommitish - ? releases.filter((r) => targetCommitish.match(`/${r.target_commitish}$`)) + ? releases.filter( + (r) => + targetCommitishName === r.target_commitish.replace(headRefRegex, '') + ) : releases const sortedPublishedReleases = sortReleases( filteredReleases.filter((r) => !r.draft) diff --git a/lib/releases.js b/lib/releases.js index 009c2747d..2881311cc 100644 --- a/lib/releases.js +++ b/lib/releases.js @@ -43,8 +43,14 @@ const findReleases = async ({ log({ context, message: `Found ${releases.length} releases` }) + // `refs/heads/branch` and `branch` are the same thing in this context + const headRefRegex = /^refs\/heads\// + const targetCommitishName = targetCommitish.replace(headRefRegex, '') const filteredReleases = filterByCommitish - ? releases.filter((r) => targetCommitish.match(`/${r.target_commitish}$`)) + ? releases.filter( + (r) => + targetCommitishName === r.target_commitish.replace(headRefRegex, '') + ) : releases const sortedPublishedReleases = sortReleases( filteredReleases.filter((r) => !r.draft)