mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2024-11-22 20:19:02 +00:00
only review changes between pushes
This commit is contained in:
parent
3413a8e8a0
commit
d60ebfdf3c
26
dist/index.js
vendored
26
dist/index.js
vendored
@ -216,14 +216,20 @@ function main() {
|
||||
diff = yield getDiff(prDetails.owner, prDetails.repo, prDetails.pull_number);
|
||||
}
|
||||
else if (process.env.GITHUB_EVENT_NAME === "push") {
|
||||
const diffUrl = yield getChangedFiles(prDetails.owner, prDetails.repo, baseSha, headSha);
|
||||
if (diffUrl) {
|
||||
const diffResponse = yield octokit.request({ url: diffUrl });
|
||||
diff = diffResponse.data;
|
||||
}
|
||||
else {
|
||||
diff = null;
|
||||
}
|
||||
const pushEvent = JSON.parse((0, fs_1.readFileSync)(process.env.GITHUB_EVENT_PATH || "", "utf8"));
|
||||
const newBaseSha = pushEvent.before;
|
||||
const newHeadSha = pushEvent.after;
|
||||
const response = yield octokit.repos.compareCommits({
|
||||
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;
|
||||
}
|
||||
else {
|
||||
console.log("Unsupported event:", process.env.GITHUB_EVENT_NAME);
|
||||
@ -247,10 +253,6 @@ function main() {
|
||||
}
|
||||
});
|
||||
}
|
||||
main().catch((error) => {
|
||||
console.error("Error:", error);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
33
src/main.ts
33
src/main.ts
@ -225,18 +225,24 @@ async function main() {
|
||||
prDetails.pull_number
|
||||
);
|
||||
} else if (process.env.GITHUB_EVENT_NAME === "push") {
|
||||
const diffUrl = await getChangedFiles(
|
||||
prDetails.owner,
|
||||
prDetails.repo,
|
||||
baseSha,
|
||||
headSha
|
||||
const pushEvent = JSON.parse(
|
||||
readFileSync(process.env.GITHUB_EVENT_PATH || "", "utf8")
|
||||
);
|
||||
if (diffUrl) {
|
||||
const diffResponse = await octokit.request({ url: diffUrl });
|
||||
diff = diffResponse.data;
|
||||
} else {
|
||||
diff = null;
|
||||
}
|
||||
const newBaseSha = pushEvent.before;
|
||||
const newHeadSha = pushEvent.after;
|
||||
|
||||
const response = await octokit.repos.compareCommits({
|
||||
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;
|
||||
} else {
|
||||
console.log("Unsupported event:", process.env.GITHUB_EVENT_NAME);
|
||||
return;
|
||||
@ -270,8 +276,3 @@ async function main() {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
console.error("Error:", error);
|
||||
process.exit(1);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user