Skip to content

Commit

Permalink
dist
Browse files Browse the repository at this point in the history
  • Loading branch information
Devon Stewart committed Mar 2, 2022
1 parent 0847b10 commit 16afe74
Showing 1 changed file with 78 additions and 3 deletions.
81 changes: 78 additions & 3 deletions dist/index.js
Expand Up @@ -128596,6 +128596,8 @@ module.exports = (app, { getRouter }) => {

if (config === null || disableReleaser) return

const includePaths = config['include-paths']

// GitHub Actions merge payloads slightly differ, in that their ref points
// to the PR branch instead of refs/heads/master
const ref = process.env['GITHUB_REF'] || context.payload.ref
Expand All @@ -128619,6 +128621,7 @@ module.exports = (app, { getRouter }) => {
targetCommitish,
lastRelease,
config,
includePaths,
})

const sortedMergedPullRequests = sortPullRequests(
Expand Down Expand Up @@ -128725,6 +128728,34 @@ const _ = __nccwpck_require__(90250)
const { log } = __nccwpck_require__(71911)
const { paginate } = __nccwpck_require__(46418)

const findCommitsWithPathChangesQuery = ({ includePaths }) => /* GraphQL */ `
query findCommitsWithPathChangesQuery(
$name: String!
$owner: String!
$targetCommitish: String!
$since: GitTimestamp
$after: String
) {
repository(name: $name, owner: $owner) {
object(expression: $targetCommitish) {
... on Commit {
${includePaths
.map(
(path, idx) => `\
path${idx}: history(path: "${path}", since: $since, after: $after) {
nodes {
id
}
}
`
)
.join('\n')}
}
}
}
}
`

const findCommitsWithAssociatedPullRequestsQuery = /* GraphQL */ `
query findCommitsWithAssociatedPullRequests(
$name: String!
Expand Down Expand Up @@ -128793,6 +128824,7 @@ const findCommitsWithAssociatedPullRequests = async ({
targetCommitish,
lastRelease,
config,
includePaths,
}) => {
const { owner, repo } = context.repo()
const variables = {
Expand All @@ -128807,7 +128839,36 @@ const findCommitsWithAssociatedPullRequests = async ({
const dataPath = ['repository', 'object', 'history']
const repoNameWithOwner = `${owner}/${repo}`

let data, commits
let data,
allCommits,
includedIds = {}

if (includePaths.length > 0) {
const commitsWithPathChanges = await paginate(
context.octokit.graphql,
findCommitsWithPathChangesQuery({
includePaths,
}),
lastRelease ? { ...variables, since: lastRelease.created_at } : variables,
['repository', 'object']
)

var anyChanges = false
for (const [idx, path] of includePaths.entries()) {
const { nodes } = commitsWithPathChanges[`path${idx}`]
includedIds[path] = includedIds[path] || new Set([])
for (const { id } of nodes) {
anyChanges = true
includedIds[path].add(id)
}
}

if (!anyChanges) {
// Short circuit to avoid blowing GraphQL budget
return { commits: [], pullRequests: [] }
}
}

if (lastRelease) {
log({
context,
Expand All @@ -128822,7 +128883,7 @@ const findCommitsWithAssociatedPullRequests = async ({
)
// GraphQL call is inclusive of commits from the specified dates. This means the final
// commit from the last tag is included, so we remove this here.
commits = _.get(data, [...dataPath, 'nodes']).filter(
allCommits = _.get(data, [...dataPath, 'nodes']).filter(
(commit) => commit.committedDate != lastRelease.created_at
)
} else {
Expand All @@ -128834,9 +128895,16 @@ const findCommitsWithAssociatedPullRequests = async ({
variables,
dataPath
)
commits = _.get(data, [...dataPath, 'nodes'])
allCommits = _.get(data, [...dataPath, 'nodes'])
}

const commits =
includePaths.length > 0
? allCommits.filter((commit) =>
includePaths.some((path) => includedIds[path].has(commit.id))
)
: allCommits

const pullRequests = _.uniqBy(
commits.flatMap((commit) => commit.associatedPullRequests.nodes),
'number'
Expand All @@ -128850,6 +128918,8 @@ const findCommitsWithAssociatedPullRequests = async ({
exports.findCommitsWithAssociatedPullRequestsQuery =
findCommitsWithAssociatedPullRequestsQuery

exports.findCommitsWithPathChangesQuery = findCommitsWithPathChangesQuery

exports.findCommitsWithAssociatedPullRequests =
findCommitsWithAssociatedPullRequests

Expand Down Expand Up @@ -128944,6 +129014,7 @@ const DEFAULT_CONFIG = Object.freeze({
categories: [],
'exclude-labels': [],
'include-labels': [],
'include-paths': [],
'exclude-contributors': [],
'no-contributors-template': 'No contributors',
replacers: [],
Expand Down Expand Up @@ -129503,6 +129574,10 @@ const schema = (context) => {
.items(Joi.string())
.default(DEFAULT_CONFIG['include-labels']),

'include-paths': Joi.array()
.items(Joi.string())
.default(DEFAULT_CONFIG['include-paths']),

'exclude-contributors': Joi.array()
.items(Joi.string())
.default(DEFAULT_CONFIG['exclude-contributors']),
Expand Down

0 comments on commit 16afe74

Please sign in to comment.