Skip to content

Commit

Permalink
Merge pull request aidar-freeed#14 from lfsevergnini/fix/access-diff-…
Browse files Browse the repository at this point in the history
…directly

fix: access diff directly to enable support to private repositories
villesau authored Jul 31, 2023
2 parents 2821669 + ee32849 commit 0939fc4
Showing 3 changed files with 9 additions and 11 deletions.
9 changes: 4 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -210,16 +210,15 @@ function main() {
const newBaseSha = eventData.before;
const newHeadSha = eventData.after;
const response = yield octokit.repos.compareCommits({
headers: {
accept: "application/vnd.github.v3.diff",
},
owner: prDetails.owner,
repo: prDetails.repo,
base: newBaseSha,
head: newHeadSha,
});
diff = response.data.diff_url
? yield octokit
.request({ url: response.data.diff_url })
.then((res) => res.data)
: null;
diff = String(response.data);
}
else {
console.log("Unsupported event:", process.env.GITHUB_EVENT_NAME);
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -213,17 +213,16 @@ async function main() {
const newHeadSha = eventData.after;

const response = await octokit.repos.compareCommits({
headers: {
accept: "application/vnd.github.v3.diff",
},
owner: prDetails.owner,
repo: prDetails.repo,
base: newBaseSha,
head: newHeadSha,
});

diff = response.data.diff_url
? await octokit
.request({ url: response.data.diff_url })
.then((res) => res.data)
: null;
diff = String(response.data);
} else {
console.log("Unsupported event:", process.env.GITHUB_EVENT_NAME);
return;

0 comments on commit 0939fc4

Please sign in to comment.