mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-04-21 01:56:47 +00:00
Merge pull request #11 from arunsnt/CICO-111286
CICO-111286: Added framework parameter to specify the framework.
This commit is contained in:
commit
6caec65a97
3 changed files with 21 additions and 5 deletions
11
dist/index.js
vendored
11
dist/index.js
vendored
|
@ -51,7 +51,7 @@ const minimatch_1 = __importDefault(__nccwpck_require__(2002));
|
||||||
const GITHUB_TOKEN = core.getInput("GITHUB_TOKEN");
|
const GITHUB_TOKEN = core.getInput("GITHUB_TOKEN");
|
||||||
const OPENAI_API_KEY = core.getInput("OPENAI_API_KEY");
|
const OPENAI_API_KEY = core.getInput("OPENAI_API_KEY");
|
||||||
const OPENAI_API_MODEL = core.getInput("OPENAI_API_MODEL");
|
const OPENAI_API_MODEL = core.getInput("OPENAI_API_MODEL");
|
||||||
const FRAMEWORK = core.getInput("framework"); // New input for framework
|
const FRAMEWORK = core.getInput("framework");
|
||||||
const octokit = new rest_1.Octokit({ auth: GITHUB_TOKEN });
|
const octokit = new rest_1.Octokit({ auth: GITHUB_TOKEN });
|
||||||
const openai = new openai_1.default({
|
const openai = new openai_1.default({
|
||||||
apiKey: OPENAI_API_KEY,
|
apiKey: OPENAI_API_KEY,
|
||||||
|
@ -462,12 +462,19 @@ function createComment(file, chunk, aiResponses) {
|
||||||
}
|
}
|
||||||
function createReviewComment(owner, repo, pull_number, comments) {
|
function createReviewComment(owner, repo, pull_number, comments) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const validComments = comments.filter(comment => comment.path && comment.line > 0 && comment.body.trim() !== "");
|
||||||
|
if (validComments.length === 0) {
|
||||||
|
console.log("No valid comments to add");
|
||||||
|
return;
|
||||||
|
}
|
||||||
yield octokit.pulls.createReview({
|
yield octokit.pulls.createReview({
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
pull_number,
|
pull_number,
|
||||||
comments,
|
comments: validComments,
|
||||||
event: "COMMENT",
|
event: "COMMENT",
|
||||||
|
}).catch(error => {
|
||||||
|
console.error("Error creating review comment:", error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
13
src/main.ts
13
src/main.ts
|
@ -8,7 +8,7 @@ import minimatch from "minimatch";
|
||||||
const GITHUB_TOKEN: string = core.getInput("GITHUB_TOKEN");
|
const GITHUB_TOKEN: string = core.getInput("GITHUB_TOKEN");
|
||||||
const OPENAI_API_KEY: string = core.getInput("OPENAI_API_KEY");
|
const OPENAI_API_KEY: string = core.getInput("OPENAI_API_KEY");
|
||||||
const OPENAI_API_MODEL: string = core.getInput("OPENAI_API_MODEL");
|
const OPENAI_API_MODEL: string = core.getInput("OPENAI_API_MODEL");
|
||||||
const FRAMEWORK: string = core.getInput("framework"); // New input for framework
|
const FRAMEWORK: string = core.getInput("framework");
|
||||||
|
|
||||||
const octokit = new Octokit({ auth: GITHUB_TOKEN });
|
const octokit = new Octokit({ auth: GITHUB_TOKEN });
|
||||||
|
|
||||||
|
@ -469,12 +469,21 @@ async function createReviewComment(
|
||||||
pull_number: number,
|
pull_number: number,
|
||||||
comments: Array<{ body: string; path: string; line: number }>
|
comments: Array<{ body: string; path: string; line: number }>
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
const validComments = comments.filter(comment => comment.path && comment.line > 0 && comment.body.trim() !== "");
|
||||||
|
|
||||||
|
if (validComments.length === 0) {
|
||||||
|
console.log("No valid comments to add");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await octokit.pulls.createReview({
|
await octokit.pulls.createReview({
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
pull_number,
|
pull_number,
|
||||||
comments,
|
comments: validComments,
|
||||||
event: "COMMENT",
|
event: "COMMENT",
|
||||||
|
}).catch(error => {
|
||||||
|
console.error("Error creating review comment:", error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue