Skip to content

Commit

Permalink
Merge pull request #657 from fujifish/master
Browse files Browse the repository at this point in the history
filter releases to consider only the target branch
  • Loading branch information
jetersen committed Oct 19, 2020
2 parents 2debed0 + 7d76402 commit 90cb61d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -33,7 +33,7 @@ module.exports = (app) => {
return
}

const { draftRelease, lastRelease } = await findReleases({ app, context })
const { draftRelease, lastRelease } = await findReleases({ ref, app, context })
const {
commits,
pullRequests: mergedPullRequests,
Expand Down
9 changes: 5 additions & 4 deletions lib/releases.js
Expand Up @@ -17,7 +17,7 @@ const sortReleases = (releases) => {
}
}

module.exports.findReleases = async ({ app, context }) => {
module.exports.findReleases = async ({ ref, app, context }) => {
let releases = await context.github.paginate(
context.github.repos.listReleases.endpoint.merge(
context.repo({
Expand All @@ -27,9 +27,10 @@ module.exports.findReleases = async ({ app, context }) => {
)

log({ app, context, message: `Found ${releases.length} releases` })

const sortedPublishedReleases = sortReleases(releases.filter((r) => !r.draft))
const draftRelease = releases.find((r) => r.draft)

const filteredReleases = releases.filter((r) => ref.match(`/${r.target_commitish}$`))
const sortedPublishedReleases = sortReleases(filteredReleases.filter((r) => !r.draft))
const draftRelease = filteredReleases.find((r) => r.draft)
const lastRelease =
sortedPublishedReleases[sortedPublishedReleases.length - 1]

Expand Down

0 comments on commit 90cb61d

Please sign in to comment.