Skip to content

Commit

Permalink
Filter by commitish regardless of the refs/heads prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Bulash committed Feb 28, 2022
1 parent d8ca1fa commit dc24635
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 @@ -129086,8 +129086,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 dc24635

Please sign in to comment.