Skip to content

Commit 81a963d

Browse files
committed
test create pull request review comment working
1 parent 02e8433 commit 81a963d

File tree

2 files changed

+72
-7
lines changed

2 files changed

+72
-7
lines changed

packages/plugin-github/src/plugins/addCommentToPR.ts

+62-4
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ export const addCommentToPRAction: Action = {
7878
try {
7979
const comment = await githubService.addPRComment(
8080
content.pullRequest,
81-
content.comment,
82-
content.owner,
83-
content.repo
81+
content.comment
8482
);
8583

8684
elizaLogger.info(
@@ -110,7 +108,7 @@ export const addCommentToPRAction: Action = {
110108
examples: [
111109
[
112110
{
113-
user: "{{user1}}",
111+
user: "{{user}}",
114112
content: {
115113
text: "Add a comment to pull request #1 in repository user1/repo1: 'This is fixed in the latest release'",
116114
},
@@ -123,6 +121,66 @@ export const addCommentToPRAction: Action = {
123121
},
124122
},
125123
],
124+
[
125+
{
126+
user: "{{user}}",
127+
content: {
128+
text: "Add a comment to pull request #2 in repository user2/repo2: 'Please review the changes'",
129+
},
130+
},
131+
{
132+
user: "{{agentName}}",
133+
content: {
134+
text: "Added comment to pull request #2 successfully!",
135+
action: "ADD_COMMENT_PR",
136+
},
137+
},
138+
],
139+
[
140+
{
141+
user: "{{user}}",
142+
content: {
143+
text: "Add a comment to pull request #3 in repository user3/repo3: 'Great work on this feature!'",
144+
},
145+
},
146+
{
147+
user: "{{agentName}}",
148+
content: {
149+
text: "Added comment to pull request #3 successfully!",
150+
action: "ADD_COMMENT_PR",
151+
},
152+
},
153+
],
154+
[
155+
{
156+
user: "{{user}}",
157+
content: {
158+
text: "Add a comment to pull request #4 in repository user4/repo4: 'Can you add more tests?'",
159+
},
160+
},
161+
{
162+
user: "{{agentName}}",
163+
content: {
164+
text: "Added comment to pull request #4 successfully!",
165+
action: "ADD_COMMENT_PR",
166+
},
167+
},
168+
],
169+
[
170+
{
171+
user: "{{user}}",
172+
content: {
173+
text: "Add a comment to pull request #5 in repository user5/repo5: 'This needs some refactoring'",
174+
},
175+
},
176+
{
177+
user: "{{agentName}}",
178+
content: {
179+
text: "Added comment to pull request #5 successfully!",
180+
action: "ADD_COMMENT_PR",
181+
},
182+
},
183+
],
126184
],
127185
};
128186

packages/plugin-github/src/services/github.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,22 @@ export class GitHubService {
255255
return response.data;
256256
}
257257

258-
async addPRComment(pullRequestNumber: number, comment: string, commitId: string, path: string): Promise<RestEndpointMethodTypes["pulls"]["createReview"]["response"]["data"]> {
258+
async addPRComment(pullRequestNumber: number, comment: string): Promise<RestEndpointMethodTypes["pulls"]["createReview"]["response"]["data"]> {
259259
try {
260260
const response = await this.octokit.pulls.createReview({
261261
owner: this.config.owner,
262262
repo: this.config.repo,
263263
pull_number: pullRequestNumber,
264264
body: comment,
265-
commit_id: commitId,
266-
path: path,
265+
event: "COMMENT"
266+
// To add comments to specific files in the PR / specific lines
267+
// comments: [
268+
// {
269+
// path: path,
270+
// body: comment,
271+
// commit_id: commitId,
272+
// }
273+
// ]
267274
})
268275
return response.data;
269276
} catch (error) {

0 commit comments

Comments
 (0)