Skip to content

Commit

Permalink
remove unused variables and import
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangy10 committed Jun 25, 2024
1 parent 6597ddb commit 38bfacd
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions eng/copilot/testTranslation.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
import { Octokit } from "@octokit/rest";
import prompt from "./query.json" assert { type: "json" };
import { getSessionAccess, fetchDeepPromptWithQuery, parseResponseToJson } from './deepPromptFunctions.js'
import { getLatestCommitSha, getChangedFiles, createChangeBranch, createBlob, createCommit, updateBranch, createPR } from './octokitFunctions.js'

const githubToken = process.env.GITHUB_TOKEN;
const apiKey = process.env.API_KEY;
const apiBase = process.env.API_BASE;
const prId = process.env.PR_ID;
const branchRef = `heads/auto-generated-integration-test-from-pr${prId}`;
const targetRepoOwner = "Azure";
const targetRepo = "azure-webpubsub";
const mainRef = "heads/main";
const octokit = new Octokit({
auth: githubToken,
});

function getChangedFileLanguage(changedFiles) {
for (const file of changedFiles) {
Expand Down Expand Up @@ -85,7 +77,7 @@ async function translate(file, sessionId, accessToken, targetLanguage) {
File patch:###${file.patch}###`;
try {
while (true) {
const dpResponse = fetchDeepPromptWithQuery(query, sessionId, accessToken);
const dpResponse = await fetchDeepPromptWithQuery(query, sessionId, accessToken);
if (dpResponse && dpResponse.includes("fileName") && dpResponse.includes("fileContent")) {
return parseResponseToJson(dpResponse.response_text);
}
Expand All @@ -96,18 +88,4 @@ async function translate(file, sessionId, accessToken, targetLanguage) {
}
}

async function getChangedFiles(owner, repo, prId) {
try {
const { data: files } = await octokit.rest.pulls.listFiles({
owner,
repo,
pull_number: prId,
});
return files;
} catch (error) {
console.error(`Faield to load pull request ${prId}: `, error.message);
throw error;
}
}

syncPrChange();

0 comments on commit 38bfacd

Please sign in to comment.