mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-06-29 04:24:13 +00:00
add test file
This commit is contained in:
parent
1d3ce203be
commit
5264aea6ca
4 changed files with 166 additions and 126 deletions
38
src/test.ts
Normal file
38
src/test.ts
Normal file
|
@ -0,0 +1,38 @@
|
|||
import { Octokit } from "@octokit/rest";
|
||||
import OpenAI from "openai";
|
||||
import parseDiff, { File } from "parse-diff";
|
||||
import minimatch from "minimatch";
|
||||
import dotenv from "dotenv";
|
||||
import { getDiff, diffToString } from "./main"; // Import the functions from main.ts
|
||||
|
||||
// Load environment variables
|
||||
dotenv.config();
|
||||
|
||||
const GITHUB_TOKEN = process.env.GITHUB_TOKEN;
|
||||
const OPENAI_API_KEY = process.env.OPENAI_API_KEY;
|
||||
const INCLUDE_PATHS = process.env.INCLUDE_PATHS?.split(",").map(p => p.trim()) || [];
|
||||
|
||||
const octokit = new Octokit({ auth: GITHUB_TOKEN });
|
||||
|
||||
// const openai = new OpenAI({
|
||||
// apiKey: OPENAI_API_KEY,
|
||||
// });
|
||||
|
||||
// Copy the necessary functions from your main.ts file
|
||||
// Include getDiff, diffToString, fileToString, chunkToString, etc.
|
||||
|
||||
async function testGetDiff() {
|
||||
const owner = "yousef-hindy-ai";
|
||||
const repo = "diffusion_demos";
|
||||
const pull_number = 5; // Replace with an actual PR number
|
||||
|
||||
const diff = await getDiff(owner, repo, pull_number);
|
||||
if (diff) {
|
||||
console.log("Filtered diff:");
|
||||
console.log(diffToString(diff));
|
||||
} else {
|
||||
console.log("No diff found");
|
||||
}
|
||||
}
|
||||
|
||||
testGetDiff().catch(console.error);
|
Loading…
Add table
Add a link
Reference in a new issue