Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions dist/654.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/654.index.js.map

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

24 changes: 16 additions & 8 deletions src/helpers/filter-paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,22 @@ export class FilterPaths extends HelperInputs {
}

export const filterPaths = async ({ paths, globs, sha }: FilterPaths) => {
const prNumberFromSha = sha
? (
await octokit.repos.listPullRequestsAssociatedWithCommit({
commit_sha: sha,
...context.repo
})
).data.find(Boolean)?.number
: undefined;
const prNumberFromSha =
context.eventName === 'merge_group'
? Number(
context.ref
.split('/')
.find(part => part.includes('pr-'))
?.match(/\d+/)?.[0]
)
: sha
? (
await octokit.repos.listPullRequestsAssociatedWithCommit({
commit_sha: sha,
...context.repo
})
).data.find(Boolean)?.number
: undefined;
const pull_number = prNumberFromSha ?? context.issue.number;

const { data } = await octokit.pulls.listFiles({
Expand Down
14 changes: 14 additions & 0 deletions test/helpers/filter-paths.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,18 @@ describe('filterPaths', () => {

expect(octokit.repos.listPullRequestsAssociatedWithCommit).not.toHaveBeenCalled();
});

it('should not call listPullRequestsAssociatedWithCommit if sha is omitted', async () => {
context.eventName = 'merge_group';
context.ref = 'refs/heads/gh-readonly-queue/branch-name/pr-12345-f0d9a4cb862b13cdaab6522f72d6dc17e4336b7f';
await filterPaths({
paths
});

expect(octokit.pulls.listFiles).toHaveBeenCalledWith({
per_page: 100,
pull_number: 12345,
...context.repo
});
});
});
Loading