Skip to content

Commit d339aa5

Browse files
remove hasura refs
1 parent bbbc261 commit d339aa5

File tree

6 files changed

+28
-28
lines changed

6 files changed

+28
-28
lines changed

__tests__/github.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@ describe('GitHub Functionality', () => {
3434
});
3535
it('Should be able to return the diff of a PR', async () => {
3636
const diffUrl: number = 262;
37-
const diff = await getDiff(diffUrl);
37+
const diff = await getDiff(diffUrl, 'hasura', 'v3-docs');
3838
expect(diff).toContain('diff');
3939
});
4040
it('Should be able to determine which files were changed in a PR', async () => {
4141
const diffUrl: number = 262;
42-
const diff = await getDiff(diffUrl);
42+
const diff = await getDiff(diffUrl, 'hasura', 'v3-docs');
4343
const files = getChangedFiles(diff);
4444
expect(files).toContain('docs/ci-cd/projects.mdx');
4545
});
4646
it('Should be able to get the contents of a file', async () => {
47-
const contents = await getFileContent(['README.md']);
47+
const contents = await getFileContent(['README.md'], 'hasura', 'v3-docs');
4848
expect(contents).toContain('Website');
4949
});
5050
});

__tests__/openai.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ describe('OpenAI Functionality', () => {
66
await expect(testConnection()).resolves.toBe(true);
77
});
88
it('Should be able to generate a prompt using the diff, assertion, and whole file', async () => {
9-
const diff: string = await getDiff(262);
9+
const diff: string = await getDiff(262, 'hasura', 'v3-docs');
1010
const assertion: string = 'The documentation is easy to read and understand.';
1111
const file: string = 'This is a test file.';
1212
const prompt: string = generatePrompt(diff, assertion, file);
@@ -22,9 +22,9 @@ describe('OpenAI Functionality', () => {
2222
const prNumber: number = 262;
2323
const PR = await getSinglePR('hasura', 'v3-docs', prNumber);
2424
const assertion = await getAssertion(PR?.body || '');
25-
const diff: string = await getDiff(prNumber);
25+
const diff: string = await getDiff(prNumber, 'hasura', 'v3-docs');
2626
const changedFiles = getChangedFiles(diff);
27-
const file: any = await getFileContent(changedFiles);
27+
const file: any = await getFileContent(changedFiles, 'hasura', 'v3-docs');
2828
const prompt: string = generatePrompt(diff, assertion, file);
2929
const response = await testAssertion(prompt);
3030
expect(response).toBeTruthy();

dist/github/index.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ const getAssertion = async (description) => {
100100
};
101101
exports.getAssertion = getAssertion;
102102
// If we have a diff_url we can get the diff
103-
const getDiff = async (prNumber) => {
103+
const getDiff = async (prNumber, owner, repo) => {
104104
const { data: diff } = await exports.github.pulls.get({
105-
owner: 'hasura',
106-
repo: 'v3-docs',
105+
owner,
106+
repo,
107107
pull_number: prNumber,
108108
mediaType: {
109109
format: 'diff',
@@ -129,14 +129,14 @@ const getChangedFiles = (diff) => {
129129
};
130130
exports.getChangedFiles = getChangedFiles;
131131
// We'll also need to get the whole file using the files changed from
132-
async function getFileContent(path) {
132+
async function getFileContent(path, owner, repo) {
133133
let content = '';
134134
// loop over the array of files
135135
for (let i = 0; i < path.length; i++) {
136136
// get the file content
137137
const { data } = await exports.github.repos.getContent({
138-
owner: 'hasura',
139-
repo: 'v3-docs',
138+
owner,
139+
repo,
140140
path: path[i],
141141
});
142142
// decode the file content

dist/index.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ const getAssertion = async (description) => {
107107
};
108108
exports.getAssertion = getAssertion;
109109
// If we have a diff_url we can get the diff
110-
const getDiff = async (prNumber) => {
110+
const getDiff = async (prNumber, owner, repo) => {
111111
const { data: diff } = await exports.github.pulls.get({
112-
owner: 'hasura',
113-
repo: 'v3-docs',
112+
owner,
113+
repo,
114114
pull_number: prNumber,
115115
mediaType: {
116116
format: 'diff',
@@ -136,14 +136,14 @@ const getChangedFiles = (diff) => {
136136
};
137137
exports.getChangedFiles = getChangedFiles;
138138
// We'll also need to get the whole file using the files changed from
139-
async function getFileContent(path) {
139+
async function getFileContent(path, owner, repo) {
140140
let content = '';
141141
// loop over the array of files
142142
for (let i = 0; i < path.length; i++) {
143143
// get the file content
144144
const { data } = await exports.github.repos.getContent({
145-
owner: 'hasura',
146-
repo: 'v3-docs',
145+
owner,
146+
repo,
147147
path: path[i],
148148
});
149149
// decode the file content
@@ -211,9 +211,9 @@ async function main() {
211211
return;
212212
}
213213
else {
214-
const diff = await (0, github_1.getDiff)(prNumber);
214+
const diff = await (0, github_1.getDiff)(prNumber, org, repoName);
215215
const changedFiles = (0, github_1.getChangedFiles)(diff);
216-
const file = await (0, github_1.getFileContent)(changedFiles);
216+
const file = await (0, github_1.getFileContent)(changedFiles, org, repoName);
217217
const prompt = (0, open_ai_1.generatePrompt)(diff, assertion, file);
218218
const rawAnalysis = await (0, open_ai_1.testAssertion)(prompt);
219219
const analysis = (0, open_ai_1.writeAnalysis)(rawAnalysis?.toString() ?? '');

src/github/index.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ export const getAssertion = async (description: string): Promise<string | null>
8282
};
8383

8484
// If we have a diff_url we can get the diff
85-
export const getDiff = async (prNumber: number): Promise<string> => {
85+
export const getDiff = async (prNumber: number, owner: string, repo: string): Promise<string> => {
8686
const { data: diff } = await github.pulls.get({
87-
owner: 'hasura',
88-
repo: 'v3-docs',
87+
owner,
88+
repo,
8989
pull_number: prNumber,
9090
mediaType: {
9191
format: 'diff',
@@ -112,14 +112,14 @@ export const getChangedFiles = (diff: string): string[] => {
112112
};
113113

114114
// We'll also need to get the whole file using the files changed from
115-
export async function getFileContent(path: string[]) {
115+
export async function getFileContent(path: string[], owner: string, repo: string) {
116116
let content: string = '';
117117
// loop over the array of files
118118
for (let i = 0; i < path.length; i++) {
119119
// get the file content
120120
const { data }: any = await github.repos.getContent({
121-
owner: 'hasura',
122-
repo: 'v3-docs',
121+
owner,
122+
repo,
123123
path: path[i],
124124
});
125125
// decode the file content

src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ async function main() {
2121
core.setFailed('No assertion found');
2222
return;
2323
} else {
24-
const diff: string = await getDiff(prNumber);
24+
const diff: string = await getDiff(prNumber, org, repoName);
2525
const changedFiles = getChangedFiles(diff);
26-
const file: any = await getFileContent(changedFiles);
26+
const file: any = await getFileContent(changedFiles, org, repoName);
2727
const prompt: string = generatePrompt(diff, assertion, file);
2828
const rawAnalysis = await testAssertion(prompt);
2929
const analysis = writeAnalysis(rawAnalysis?.toString() ?? '');

0 commit comments

Comments
 (0)