Skip to content

Commit

Permalink
Filter by commitish regardless of the refs/heads prefix (#1089)
Browse files Browse the repository at this point in the history
Co-authored-by: Mikhail Bulash <scaryspiderpig@gmail.com>
  • Loading branch information
mikeroll and Mikhail Bulash committed Mar 3, 2022
1 parent 836e045 commit ba9967c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion dist/index.js
Expand Up @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion lib/releases.js
Expand Up @@ -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)
Expand Down

0 comments on commit ba9967c

Please sign in to comment.