Skip to content

Commit

Permalink
ensure PRs are merged (#1015)
Browse files Browse the repository at this point in the history
  • Loading branch information
jetersen committed Jan 16, 2022
1 parent 0bc3bc5 commit d51d5d1
Show file tree
Hide file tree
Showing 12 changed files with 307 additions and 119 deletions.
4 changes: 4 additions & 0 deletions bin/generate-fixtures.js
Expand Up @@ -3,7 +3,9 @@
const fs = require('fs')
const path = require('path')
const fetch = require('node-fetch')
const dotenv = require('dotenv')
const { findCommitsWithAssociatedPullRequestsQuery } = require('../lib/commits')
dotenv.config()

const REPO_NAME = 'release-drafter-test-repo'
const GITHUB_GRAPHQL_API_ENDPOINT = 'https://api.github.com/graphql'
Expand Down Expand Up @@ -53,6 +55,8 @@ for (const repo of repos) {
ref: repo.branch,
withPullRequestBody: true,
withPullRequestURL: true,
withBaseRefName: true,
withHeadRefName: true,
},
}),
}
Expand Down
5 changes: 4 additions & 1 deletion dist/index.js
Expand Up @@ -133128,6 +133128,7 @@ const findCommitsWithAssociatedPullRequestsQuery = /* GraphQL */ `
name
}
}
merged
baseRefName @include(if: $withBaseRefName)
headRefName @include(if: $withHeadRefName)
}
Expand Down Expand Up @@ -133192,7 +133193,9 @@ const findCommitsWithAssociatedPullRequests = async ({
const pullRequests = _.uniqBy(
commits.flatMap((commit) => commit.associatedPullRequests.nodes),
'number'
).filter((pr) => pr.baseRepository.nameWithOwner === repoNameWithOwner)
).filter(
(pr) => pr.baseRepository.nameWithOwner === repoNameWithOwner && pr.merged
)

return { commits, pullRequests }
}
Expand Down
5 changes: 4 additions & 1 deletion lib/commits.js
Expand Up @@ -52,6 +52,7 @@ const findCommitsWithAssociatedPullRequestsQuery = /* GraphQL */ `
name
}
}
merged
baseRefName @include(if: $withBaseRefName)
headRefName @include(if: $withHeadRefName)
}
Expand Down Expand Up @@ -116,7 +117,9 @@ const findCommitsWithAssociatedPullRequests = async ({
const pullRequests = _.uniqBy(
commits.flatMap((commit) => commit.associatedPullRequests.nodes),
'number'
).filter((pr) => pr.baseRepository.nameWithOwner === repoNameWithOwner)
).filter(
(pr) => pr.baseRepository.nameWithOwner === repoNameWithOwner && pr.merged
)

return { commits, pullRequests }
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -50,7 +50,7 @@
"mocked-env": "^1.3.5",
"nock": "13.2.2",
"nock-knock": "2.0.0",
"node-fetch": "3.1.0",
"node-fetch": "2.6.7",
"nodemon": "2.0.15",
"prettier": "2.5.1",
"smee-client": "1.2.2"
Expand Down
90 changes: 72 additions & 18 deletions test/fixtures/__generated__/graphql-commits-forking.json

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

0 comments on commit d51d5d1

Please sign in to comment.