Skip to content

Commit

Permalink
fix: closing of previous release PRs (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
sparten11740 authored Jan 26, 2024
1 parent e8fc99b commit e0a52a4
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
4 changes: 1 addition & 3 deletions dist/publish/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/publish/index.js.map

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions dist/version/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/version/index.js.map

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions src/utils/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,7 @@ export async function getPullRequestsForLabels({
{ search }
)

return response.search.edges
.map((edge) => edge.node)
.filter((pr) => pr.labels.nodes.every((label) => labels.includes(label.name)))
return response.search.edges.map((edge) => edge.node)
}

type ClosePullRequestParams = {
Expand Down
12 changes: 11 additions & 1 deletion src/version/close-previous-prs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { RELEASE_PR_LABEL } from '../constants'
import * as path from 'path'
import { Repo } from '../utils/types'
import * as core from '@actions/core'
import { getPackagePaths } from '@exodus/lerna-utils'

type Params = {
client: GithubClient
Expand All @@ -18,9 +19,18 @@ type Params = {
}

export default async function closePreviousPrs({ client, repo, pullRequest, packages }: Params) {
const allPackages = await getPackagePaths()
const allPackageNames = new Set(allPackages.map((it) => path.basename(it)))
const labels = [RELEASE_PR_LABEL, ...packages.map((it) => path.basename(it))]
const previousPrs = await getPullRequestsForLabels({ client, repo, labels })
const filtered = previousPrs.filter((pr) => pr.number !== pullRequest.number)

const filtered = previousPrs.filter(
(pr) =>
pr.number !== pullRequest.number &&
pr.labels.nodes.every(
(label) => labels.includes(label.name) || !allPackageNames.has(label.name)
)
)

if (filtered.length === 0) {
core.info('Found no previous PRs releasing the same packages.')
Expand Down

0 comments on commit e0a52a4

Please sign in to comment.