From 7bc8fbdb1909471fccb680157c02c3389ab2b3be Mon Sep 17 00:00:00 2001 From: Mikhail Bulash Date: Mon, 28 Feb 2022 15:43:04 +0100 Subject: [PATCH] Filter by `commitish` regardless of the `refs/heads` prefix --- 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 eed174c963..6cd3fb6140 100644 --- a/dist/index.js +++ b/dist/index.js @@ -129086,8 +129086,14 @@ const findReleases = async ({ log({ context, message: `Found ${releases.length} releases` }) + const headRefRegex = /^refs\/heads\// const filteredReleases = filterByCommitish - ? releases.filter((r) => targetCommitish.match(`/${r.target_commitish}$`)) + ? releases.filter( + (r) => + // `refs/heads/branch` and `branch` are the same thing in this context + targetCommitish.replace(headRefRegex, '') === + 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 009c2747da..b1a5c81304 100644 --- a/lib/releases.js +++ b/lib/releases.js @@ -43,8 +43,14 @@ const findReleases = async ({ log({ context, message: `Found ${releases.length} releases` }) + const headRefRegex = /^refs\/heads\// const filteredReleases = filterByCommitish - ? releases.filter((r) => targetCommitish.match(`/${r.target_commitish}$`)) + ? releases.filter( + (r) => + // `refs/heads/branch` and `branch` are the same thing in this context + targetCommitish.replace(headRefRegex, '') === + r.target_commitish.replace(headRefRegex, '') + ) : releases const sortedPublishedReleases = sortReleases( filteredReleases.filter((r) => !r.draft)