Skip to content

Commit

Permalink
DEVEX-43: Log repo details
Browse files Browse the repository at this point in the history
  • Loading branch information
unalpolat committed Nov 22, 2023
1 parent ada2a95 commit ad1ae51
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
8 changes: 5 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ const client = new openai_1.OpenAIClient(AZURE_BASE_URL, new openai_1.AzureKeyCr
function getPRDetails() {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
const { repository, issue } = JSON.parse((0, fs_1.readFileSync)(process.env.GITHUB_EVENT_PATH || "", "utf8"));
const { repository, number } = JSON.parse((0, fs_1.readFileSync)(process.env.GITHUB_EVENT_PATH || "", "utf8"));
const prResponse = yield octokit.pulls.get({
owner: repository.owner.login,
repo: repository.name,
pull_number: issue.number,
pull_number: number,
});
return {
owner: repository.owner.login,
repo: repository.name,
pull_number: issue.number,
pull_number: number,
title: (_a = prResponse.data.title) !== null && _a !== void 0 ? _a : "",
description: (_b = prResponse.data.body) !== null && _b !== void 0 ? _b : "",
};
Expand All @@ -93,7 +93,9 @@ function analyzeCode(parsedDiff, prDetails) {
continue; // Ignore deleted files
for (const chunk of file.chunks) {
const prompt = createPrompt(file, chunk, prDetails);
console.log(prompt);
const aiResponse = yield getAIResponse(prompt);
console.log(aiResponse);
if (aiResponse) {
const newComments = createComment(file, chunk, aiResponse);
if (newComments) {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ interface PRDetails {
}

async function getPRDetails(): Promise<PRDetails> {
const { repository, issue } = JSON.parse(
const { repository, number } = JSON.parse(
readFileSync(process.env.GITHUB_EVENT_PATH || "", "utf8")
);
const prResponse = await octokit.pulls.get({
owner: repository.owner.login,
repo: repository.name,
pull_number: issue.number,
pull_number: number,
});
return {
owner: repository.owner.login,
repo: repository.name,
pull_number: issue.number,
pull_number: number,
title: prResponse.data.title ?? "",
description: prResponse.data.body ?? "",
};
Expand Down Expand Up @@ -71,7 +71,9 @@ async function analyzeCode(
if (file.to === "/dev/null") continue; // Ignore deleted files
for (const chunk of file.chunks) {
const prompt = createPrompt(file, chunk, prDetails);
console.log(prompt)
const aiResponse = await getAIResponse(prompt);
console.log(aiResponse)
if (aiResponse) {
const newComments = createComment(file, chunk, aiResponse);
if (newComments) {
Expand Down

0 comments on commit ad1ae51

Please sign in to comment.