mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2024-11-26 22:19:03 +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);
|
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 diffUrl = yield getChangedFiles(prDetails.owner, prDetails.repo, baseSha, headSha);
|
const pushEvent = JSON.parse((0, fs_1.readFileSync)(process.env.GITHUB_EVENT_PATH || "", "utf8"));
|
||||||
if (diffUrl) {
|
const newBaseSha = pushEvent.before;
|
||||||
const diffResponse = yield octokit.request({ url: diffUrl });
|
const newHeadSha = pushEvent.after;
|
||||||
diff = diffResponse.data;
|
const response = yield octokit.repos.compareCommits({
|
||||||
}
|
owner: prDetails.owner,
|
||||||
else {
|
repo: prDetails.repo,
|
||||||
diff = null;
|
base: newBaseSha,
|
||||||
}
|
head: newHeadSha,
|
||||||
|
});
|
||||||
|
diff = response.data.diff_url
|
||||||
|
? yield octokit
|
||||||
|
.request({ url: response.data.diff_url })
|
||||||
|
.then((res) => res.data)
|
||||||
|
: null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.log("Unsupported event:", process.env.GITHUB_EVENT_NAME);
|
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
|
prDetails.pull_number
|
||||||
);
|
);
|
||||||
} else if (process.env.GITHUB_EVENT_NAME === "push") {
|
} else if (process.env.GITHUB_EVENT_NAME === "push") {
|
||||||
const diffUrl = await getChangedFiles(
|
const pushEvent = JSON.parse(
|
||||||
prDetails.owner,
|
readFileSync(process.env.GITHUB_EVENT_PATH || "", "utf8")
|
||||||
prDetails.repo,
|
|
||||||
baseSha,
|
|
||||||
headSha
|
|
||||||
);
|
);
|
||||||
if (diffUrl) {
|
const newBaseSha = pushEvent.before;
|
||||||
const diffResponse = await octokit.request({ url: diffUrl });
|
const newHeadSha = pushEvent.after;
|
||||||
diff = diffResponse.data;
|
|
||||||
} else {
|
const response = await octokit.repos.compareCommits({
|
||||||
diff = null;
|
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 {
|
} else {
|
||||||
console.log("Unsupported event:", process.env.GITHUB_EVENT_NAME);
|
console.log("Unsupported event:", process.env.GITHUB_EVENT_NAME);
|
||||||
return;
|
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