Merge pull request #8 from ingress-it-solutions/dev

Dev
This commit is contained in:
vandanafuletra 2023-04-06 10:15:00 +05:30 committed by GitHub
commit 00ddd9adf0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 56 deletions

View file

@ -106,11 +106,8 @@ ${file:dist/index.js}
## Screenshots ## Screenshots
## More Examples ## More Examples
## License ## License
The code in this repository is licensed under the MIT license. See `LICENSE` for more information. The code in this repository is licensed under the MIT license. See `LICENSE` for more information.

44
dist/index.js vendored
View file

@ -39231,16 +39231,18 @@ async function run() {
const prNumber = github.context.payload.number || github.context.payload.issue.number; // get number from a pull request event or comment event const prNumber = github.context.payload.number || github.context.payload.issue.number; // get number from a pull request event or comment event
// Get the code to analyze from the review comment // Get the code to analyze from the review comment
var content = comment && comment.body || "";
const url = `${githubBaseURL}/${repoOwner}/${repoName}/pulls/${prNumber}`;
core.debug(`diff url: ${url}`); var content = comment && comment.body || '';
var response = await axios.get(url, {
headers: { const url = `${giteaBaseURL}/api/v1/repos/${repoOwner}/${repoName}/pulls/${prNumber}/diff`;
Authorization: `Bearer ${githubToken}`, console.log(`diff url: ${url}`);
Accept: 'application/vnd.github.diff' var response = await axios.get(url, {
} headers: {
}); Authorization: `token ${giteaToken}`,
Accept: 'application/vnd.github.diff'
}
});
const code = response.data; const code = response.data;
core.debug(`diff code: ${code}`); core.debug(`diff code: ${code}`);
const files = parsePullRequestDiff(code); const files = parsePullRequestDiff(code);
@ -39298,25 +39300,17 @@ async function run() {
core.debug(`openai response: ${answer}`); core.debug(`openai response: ${answer}`);
// Reply to the review comment with the OpenAI response // Reply to the review comment with the OpenAI response
const octokit = github.getOctokit(githubToken, { const client = new github.GitHub(githubToken, {
baseUrl: githubBaseURL baseUrl: githubBaseURL
}); });
const commentUrl = `${githubBaseURL}/repos/${repoOwner}/${repoName}/pulls/${prNumber}`;
var response = await axios.post(commentUrl, { await client.issues.createComment({
body: answerTemplate.replace('${answer}', answer), owner: repoOwner,
headers: { repo: repoName,
Authorization: `Bearer ${githubToken}` issue_number: prNumber,
} body: answerTemplate.replace('${answer}', answer)
}); });
const output = response.data;
core.debug(`Output Values: ${output}`);
// await octokit.rest.issues.createComment({
// owner: repoOwner,
// repo: repoName,
// issue_number: prNumber,
// body: answerTemplate.replace('${answer}', answer)
// // in_reply_to: comment.id
// });
} catch (error) { } catch (error) {
core.setFailed(error.message); core.setFailed(error.message);
} }

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -45,16 +45,18 @@ async function run() {
const prNumber = github.context.payload.number || github.context.payload.issue.number; // get number from a pull request event or comment event const prNumber = github.context.payload.number || github.context.payload.issue.number; // get number from a pull request event or comment event
// Get the code to analyze from the review comment // Get the code to analyze from the review comment
var content = comment && comment.body || "";
const url = `${githubBaseURL}/${repoOwner}/${repoName}/pulls/${prNumber}`;
core.debug(`diff url: ${url}`); var content = comment && comment.body || '';
var response = await axios.get(url, {
headers: { const url = `${githubBaseURL}/api/v1/repos/${repoOwner}/${repoName}/pulls/${prNumber}/diff`;
Authorization: `Bearer ${githubToken}`, console.log(`diff url: ${url}`);
Accept: 'application/vnd.github.diff' var response = await axios.get(url, {
} headers: {
}); Authorization: `token ${giteaToken}`,
Accept: 'application/vnd.github.diff'
}
});
const code = response.data; const code = response.data;
core.debug(`diff code: ${code}`); core.debug(`diff code: ${code}`);
const files = parsePullRequestDiff(code); const files = parsePullRequestDiff(code);
@ -112,25 +114,17 @@ async function run() {
core.debug(`openai response: ${answer}`); core.debug(`openai response: ${answer}`);
// Reply to the review comment with the OpenAI response // Reply to the review comment with the OpenAI response
const octokit = github.getOctokit(githubToken, { const client = new github.GitHub(githubToken, {
baseUrl: githubBaseURL baseUrl: githubBaseURL
}); });
const commentUrl = `${githubBaseURL}/repos/${repoOwner}/${repoName}/pulls/${prNumber}`;
var response = await axios.post(commentUrl, { await client.issues.createComment({
body: answerTemplate.replace('${answer}', answer), owner: repoOwner,
headers: { repo: repoName,
Authorization: `Bearer ${githubToken}` issue_number: prNumber,
} body: answerTemplate.replace('${answer}', answer)
}); });
const output = response.data;
core.debug(`Output Values: ${output}`);
// await octokit.rest.issues.createComment({
// owner: repoOwner,
// repo: repoName,
// issue_number: prNumber,
// body: answerTemplate.replace('${answer}', answer)
// // in_reply_to: comment.id
// });
} catch (error) { } catch (error) {
core.setFailed(error.message); core.setFailed(error.message);
} }