mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2024-11-26 22:19:03 +00:00
log the diff
This commit is contained in:
parent
d60ebfdf3c
commit
dd255bf5d5
16
dist/index.js
vendored
16
dist/index.js
vendored
@ -105,17 +105,6 @@ function analyzeCode(parsedDiff, prDetails) {
|
|||||||
return comments;
|
return comments;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function getChangedFiles(owner, repo, baseSha, headSha) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const response = yield octokit.repos.compareCommits({
|
|
||||||
owner,
|
|
||||||
repo,
|
|
||||||
base: baseSha,
|
|
||||||
head: headSha,
|
|
||||||
});
|
|
||||||
return response.data.diff_url;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function getBaseAndHeadShas(owner, repo, pull_number) {
|
function getBaseAndHeadShas(owner, repo, pull_number) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const prResponse = yield octokit.pulls.get({
|
const prResponse = yield octokit.pulls.get({
|
||||||
@ -210,13 +199,14 @@ function createReviewComment(owner, repo, pull_number, comments) {
|
|||||||
function main() {
|
function main() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const prDetails = yield getPRDetails();
|
const prDetails = yield getPRDetails();
|
||||||
const { baseSha, headSha } = yield getBaseAndHeadShas(prDetails.owner, prDetails.repo, prDetails.pull_number);
|
|
||||||
let diff;
|
let diff;
|
||||||
if (process.env.GITHUB_EVENT_NAME === "pull_request") {
|
if (process.env.GITHUB_EVENT_NAME === "pull_request") {
|
||||||
diff = yield getDiff(prDetails.owner, prDetails.repo, prDetails.pull_number);
|
diff = yield getDiff(prDetails.owner, prDetails.repo, prDetails.pull_number);
|
||||||
}
|
}
|
||||||
else if (process.env.GITHUB_EVENT_NAME === "push") {
|
else if (process.env.GITHUB_EVENT_NAME === "push") {
|
||||||
const pushEvent = JSON.parse((0, fs_1.readFileSync)(process.env.GITHUB_EVENT_PATH || "", "utf8"));
|
const pushEvent = JSON.parse((0, fs_1.readFileSync)(process.env.GITHUB_EVENT_PATH || "", "utf8"));
|
||||||
|
console.log("Push event:");
|
||||||
|
console.log(pushEvent);
|
||||||
const newBaseSha = pushEvent.before;
|
const newBaseSha = pushEvent.before;
|
||||||
const newHeadSha = pushEvent.after;
|
const newHeadSha = pushEvent.after;
|
||||||
const response = yield octokit.repos.compareCommits({
|
const response = yield octokit.repos.compareCommits({
|
||||||
@ -230,6 +220,8 @@ function main() {
|
|||||||
.request({ url: response.data.diff_url })
|
.request({ url: response.data.diff_url })
|
||||||
.then((res) => res.data)
|
.then((res) => res.data)
|
||||||
: null;
|
: null;
|
||||||
|
console.log("Diff:");
|
||||||
|
console.log(diff);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.log("Unsupported event:", process.env.GITHUB_EVENT_NAME);
|
console.log("Unsupported event:", process.env.GITHUB_EVENT_NAME);
|
||||||
|
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
25
src/main.ts
25
src/main.ts
@ -79,21 +79,6 @@ async function analyzeCode(
|
|||||||
return comments;
|
return comments;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getChangedFiles(
|
|
||||||
owner: string,
|
|
||||||
repo: string,
|
|
||||||
baseSha: string,
|
|
||||||
headSha: string
|
|
||||||
): Promise<string | null> {
|
|
||||||
const response = await octokit.repos.compareCommits({
|
|
||||||
owner,
|
|
||||||
repo,
|
|
||||||
base: baseSha,
|
|
||||||
head: headSha,
|
|
||||||
});
|
|
||||||
return response.data.diff_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getBaseAndHeadShas(
|
async function getBaseAndHeadShas(
|
||||||
owner: string,
|
owner: string,
|
||||||
repo: string,
|
repo: string,
|
||||||
@ -210,12 +195,6 @@ async function createReviewComment(
|
|||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const prDetails = await getPRDetails();
|
const prDetails = await getPRDetails();
|
||||||
const { baseSha, headSha } = await getBaseAndHeadShas(
|
|
||||||
prDetails.owner,
|
|
||||||
prDetails.repo,
|
|
||||||
prDetails.pull_number
|
|
||||||
);
|
|
||||||
|
|
||||||
let diff: string | null;
|
let diff: string | null;
|
||||||
|
|
||||||
if (process.env.GITHUB_EVENT_NAME === "pull_request") {
|
if (process.env.GITHUB_EVENT_NAME === "pull_request") {
|
||||||
@ -228,6 +207,8 @@ async function main() {
|
|||||||
const pushEvent = JSON.parse(
|
const pushEvent = JSON.parse(
|
||||||
readFileSync(process.env.GITHUB_EVENT_PATH || "", "utf8")
|
readFileSync(process.env.GITHUB_EVENT_PATH || "", "utf8")
|
||||||
);
|
);
|
||||||
|
console.log("Push event:");
|
||||||
|
console.log(pushEvent);
|
||||||
const newBaseSha = pushEvent.before;
|
const newBaseSha = pushEvent.before;
|
||||||
const newHeadSha = pushEvent.after;
|
const newHeadSha = pushEvent.after;
|
||||||
|
|
||||||
@ -243,6 +224,8 @@ async function main() {
|
|||||||
.request({ url: response.data.diff_url })
|
.request({ url: response.data.diff_url })
|
||||||
.then((res) => res.data)
|
.then((res) => res.data)
|
||||||
: null;
|
: null;
|
||||||
|
console.log("Diff:");
|
||||||
|
console.log(diff);
|
||||||
} else {
|
} else {
|
||||||
console.log("Unsupported event:", process.env.GITHUB_EVENT_NAME);
|
console.log("Unsupported event:", process.env.GITHUB_EVENT_NAME);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user