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
10 changes: 7 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30274,9 +30274,13 @@ function decodeDiff(data) {
}
throw new Error(`The pull request diff was returned as ${typeof data} rather than text, so no issue can be matched against the pull request`);
}
async function getPrDiff(githubToken, owner, repo, prNumber) {
async function getPrDiff(githubToken, owner, repo) {
const octokit = (0, github_1.getOctokit)(githubToken);
const { base, head } = (await octokit.rest.pulls.get({ owner, repo, pull_number: prNumber })).data;
const pr = github_1.context.payload.pull_request;
if (pr == null) {
throw new Error('No pull request payload found.');
}
const { base, head } = pr;
return decodeDiff((await octokit.rest.repos.compareCommits({ owner, repo, base: base.sha, head: head.sha, mediaType: { format: 'diff' } })).data);
}
function parseDiffLines(diff) {
Expand Down Expand Up @@ -32338,7 +32342,7 @@ async function run() {
if (prNumber == null) {
throw new Error('No pull request number found.');
}
pullRequest ??= [prNumber, await (0, bugalint_1.getPrDiff)(githubToken, github_1.context.repo.owner, github_1.context.repo.repo, prNumber)];
pullRequest ??= [prNumber, await (0, bugalint_1.getPrDiff)(githubToken, github_1.context.repo.owner, github_1.context.repo.repo)];
return pullRequest;
};
let issues = [...parser(input)];
Expand Down
10 changes: 7 additions & 3 deletions src/bugalint.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Log, Region, ReportingDescriptor, Result } from 'sarif'
import { getOctokit } from '@actions/github'
import { context, getOctokit } from '@actions/github'
import { debug, warning, summary } from '@actions/core'
import path from 'path'
import parseDiff from 'parse-diff'
Expand Down Expand Up @@ -387,9 +387,13 @@ function decodeDiff(data: unknown): string {
throw new Error(`The pull request diff was returned as ${typeof data} rather than text, so no issue can be matched against the pull request`)
}

export async function getPrDiff(githubToken: string, owner: string, repo: string, prNumber: number): Promise<string> {
export async function getPrDiff(githubToken: string, owner: string, repo: string): Promise<string> {
const octokit = getOctokit(githubToken)
const { base, head } = (await octokit.rest.pulls.get({ owner, repo, pull_number: prNumber })).data
const pr = context.payload.pull_request as ({ base: { sha: string } } & { head: { sha: string } }) | undefined
if (pr == null) {
throw new Error('No pull request payload found.')
}
const { base, head } = pr
return decodeDiff((await octokit.rest.repos.compareCommits({ owner, repo, base: base.sha, head: head.sha, mediaType: { format: 'diff' } })).data)
}

Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export async function run(): Promise<void> {
if (prNumber == null) {
throw new Error('No pull request number found.')
}
pullRequest ??= [prNumber, await getPrDiff(githubToken, context.repo.owner, context.repo.repo, prNumber)]
pullRequest ??= [prNumber, await getPrDiff(githubToken, context.repo.owner, context.repo.repo)]
return pullRequest
}

Expand Down
Loading