mirror of
https://github.com/ingress-it-solutions/gitea-code-review-action.git
synced 2025-06-28 10:34:13 +00:00
commit
00ddd9adf0
4 changed files with 41 additions and 56 deletions
|
@ -106,11 +106,8 @@ ${file:dist/index.js}
|
|||
|
||||
## Screenshots
|
||||
|
||||
|
||||
## More Examples
|
||||
|
||||
|
||||
|
||||
## License
|
||||
|
||||
The code in this repository is licensed under the MIT license. See `LICENSE` for more information.
|
||||
|
|
44
dist/index.js
vendored
44
dist/index.js
vendored
|
@ -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
|
||||
|
||||
// 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 response = await axios.get(url, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${githubToken}`,
|
||||
Accept: 'application/vnd.github.diff'
|
||||
}
|
||||
});
|
||||
|
||||
var content = comment && comment.body || '';
|
||||
|
||||
const url = `${giteaBaseURL}/api/v1/repos/${repoOwner}/${repoName}/pulls/${prNumber}/diff`;
|
||||
console.log(`diff url: ${url}`);
|
||||
var response = await axios.get(url, {
|
||||
headers: {
|
||||
Authorization: `token ${giteaToken}`,
|
||||
Accept: 'application/vnd.github.diff'
|
||||
}
|
||||
});
|
||||
const code = response.data;
|
||||
core.debug(`diff code: ${code}`);
|
||||
const files = parsePullRequestDiff(code);
|
||||
|
@ -39298,25 +39300,17 @@ async function run() {
|
|||
core.debug(`openai response: ${answer}`);
|
||||
|
||||
// Reply to the review comment with the OpenAI response
|
||||
const octokit = github.getOctokit(githubToken, {
|
||||
const client = new github.GitHub(githubToken, {
|
||||
baseUrl: githubBaseURL
|
||||
});
|
||||
const commentUrl = `${githubBaseURL}/repos/${repoOwner}/${repoName}/pulls/${prNumber}`;
|
||||
var response = await axios.post(commentUrl, {
|
||||
body: answerTemplate.replace('${answer}', answer),
|
||||
headers: {
|
||||
Authorization: `Bearer ${githubToken}`
|
||||
}
|
||||
|
||||
await client.issues.createComment({
|
||||
owner: repoOwner,
|
||||
repo: repoName,
|
||||
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) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
|
|
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
44
index.js
44
index.js
|
@ -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
|
||||
|
||||
// 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 response = await axios.get(url, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${githubToken}`,
|
||||
Accept: 'application/vnd.github.diff'
|
||||
}
|
||||
});
|
||||
|
||||
var content = comment && comment.body || '';
|
||||
|
||||
const url = `${githubBaseURL}/api/v1/repos/${repoOwner}/${repoName}/pulls/${prNumber}/diff`;
|
||||
console.log(`diff url: ${url}`);
|
||||
var response = await axios.get(url, {
|
||||
headers: {
|
||||
Authorization: `token ${giteaToken}`,
|
||||
Accept: 'application/vnd.github.diff'
|
||||
}
|
||||
});
|
||||
const code = response.data;
|
||||
core.debug(`diff code: ${code}`);
|
||||
const files = parsePullRequestDiff(code);
|
||||
|
@ -112,25 +114,17 @@ async function run() {
|
|||
core.debug(`openai response: ${answer}`);
|
||||
|
||||
// Reply to the review comment with the OpenAI response
|
||||
const octokit = github.getOctokit(githubToken, {
|
||||
const client = new github.GitHub(githubToken, {
|
||||
baseUrl: githubBaseURL
|
||||
});
|
||||
const commentUrl = `${githubBaseURL}/repos/${repoOwner}/${repoName}/pulls/${prNumber}`;
|
||||
var response = await axios.post(commentUrl, {
|
||||
body: answerTemplate.replace('${answer}', answer),
|
||||
headers: {
|
||||
Authorization: `Bearer ${githubToken}`
|
||||
}
|
||||
|
||||
await client.issues.createComment({
|
||||
owner: repoOwner,
|
||||
repo: repoName,
|
||||
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) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue