mirror of
https://github.com/ingress-it-solutions/gitea-code-review-action.git
synced 2025-06-28 18:34:14 +00:00
commit
00ddd9adf0
4 changed files with 41 additions and 56 deletions
|
@ -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.
|
||||||
|
|
34
dist/index.js
vendored
34
dist/index.js
vendored
|
@ -39231,13 +39231,15 @@ 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 || '';
|
||||||
|
|
||||||
|
const url = `${giteaBaseURL}/api/v1/repos/${repoOwner}/${repoName}/pulls/${prNumber}/diff`;
|
||||||
|
console.log(`diff url: ${url}`);
|
||||||
var response = await axios.get(url, {
|
var response = await axios.get(url, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${githubToken}`,
|
Authorization: `token ${giteaToken}`,
|
||||||
Accept: 'application/vnd.github.diff'
|
Accept: 'application/vnd.github.diff'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -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
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
34
index.js
34
index.js
|
@ -45,13 +45,15 @@ 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 || '';
|
||||||
|
|
||||||
|
const url = `${githubBaseURL}/api/v1/repos/${repoOwner}/${repoName}/pulls/${prNumber}/diff`;
|
||||||
|
console.log(`diff url: ${url}`);
|
||||||
var response = await axios.get(url, {
|
var response = await axios.get(url, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${githubToken}`,
|
Authorization: `token ${giteaToken}`,
|
||||||
Accept: 'application/vnd.github.diff'
|
Accept: 'application/vnd.github.diff'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue