@@ -199,21 +199,6 @@ def get_issue(self, repo_id: str, issue_id: int) -> Issue:
199199 labels = [label .name for label in issue .labels ],
200200 )
201201
202- def create_issue_comment (self , repo_id : str , issue_id : int , body : str ) -> str | None :
203- """
204- Comment on an issue.
205-
206- Returns:
207- The comment ID.
208- """
209- return self .client .get_repo (repo_id , lazy = True ).get_issue (issue_id ).create_comment (body ).id
210-
211- def update_issue_comment (self , repo_id : str , issue_id : int , comment_id : int , body : str ):
212- """
213- Update a comment on an issue.
214- """
215- self .client .get_repo (repo_id , lazy = True ).get_issue (issue_id ).get_comment (comment_id ).edit (body )
216-
217202 def create_issue_note_emoji (self , repo_id : str , issue_id : int , emoji : Emoji , note_id : str ):
218203 """
219204 Create an emoji in a note of an issue.
@@ -225,56 +210,56 @@ def create_issue_note_emoji(self, repo_id: str, issue_id: int, emoji: Emoji, not
225210 emoji_reaction
226211 )
227212
228- def get_issue_discussion (
229- self , repo_id : str , issue_id : int , discussion_id : str , only_resolvable : bool = True
230- ) -> Discussion :
213+ def get_issue_comment (self , repo_id : str , issue_id : int , comment_id : str ) -> Discussion :
231214 """
232- Get a discussion from an issue.
215+ Get a comment from an issue.
233216
234- For GitHub, there's no distinction between discussions and notes.
217+ For GitHub, there's no distinction between comments and notes.
235218
236219 Args:
237220 repo_id: The repository ID.
238221 issue_id: The issue ID.
239- discussion_id: The discussion ID. This is not used for GitHub.
240- only_resolvable: Whether to only return resolvable notes. This is not used for GitHub.
222+ comment_id: The comment ID.
241223
242224 Returns:
243225 The discussion object.
244226 """
245227 issue = self .client .get_repo (repo_id , lazy = True ).get_issue (issue_id )
246228 # GitHub doesn't have discussions like GitLab. This is a workaround to get the notes of an issue.
247- return Discussion (id = discussion_id , notes = self ._serialize_comments (issue .get_comments ()), is_reply = False )
229+ return Discussion (id = comment_id , notes = self ._serialize_comments (issue .get_comments ()))
248230
249- def create_issue_discussion_note (
250- self , repo_id : str , issue_id : int , body : str , discussion_id : str | None = None
231+ def create_issue_comment (
232+ self , repo_id : str , issue_id : int , body : str , reply_to_id : str | None = None , as_thread : bool = False
251233 ) -> str | None :
252234 """
253- Create a comment on an issue.
254-
255- For GitHub, there's no distinction between discussions and notes. This method creates a comment on the issue.
235+ Comment on an issue.
256236
257237 Args:
258238 repo_id: The repository ID.
259239 issue_id: The issue ID.
260240 body: The comment body.
261- discussion_id: The discussion ID. This is not used for GitHub.
241+ reply_to_id: The ID of the comment to reply to. This is not supported for GitHub.
242+ as_thread: Whether to create a thread. This is not supported for GitHub.
243+
244+ Returns:
245+ The comment ID.
262246 """
263- # GitHub doesn't have discussions like GitLab. This is a workaround to create a comment on the issue.
264- return self .create_issue_comment (repo_id , issue_id , body )
247+ return self .client .get_repo (repo_id , lazy = True ).get_issue (issue_id ).create_comment (body ).id
265248
266- def update_issue_discussion_note (self , repo_id : str , issue_id : int , discussion_id : str , note_id : str , body : str ):
249+ def update_issue_comment (
250+ self , repo_id : str , issue_id : int , comment_id : int , body : str , reply_to_id : str | None = None
251+ ):
267252 """
268253 Update a comment on an issue.
269254
270255 Args:
271256 repo_id: The repository ID.
272257 issue_id: The issue ID.
273- discussion_id: The discussion ID. This is not used for GitHub.
274- note_id: The note ID.
258+ comment_id: The comment ID.
275259 body: The comment body.
260+ reply_to_id: The ID of the comment to reply to. This is not supported for GitHub.
276261 """
277- self .update_issue_comment (repo_id , issue_id , note_id , body )
262+ self .client . get_repo (repo_id , lazy = True ). get_issue ( issue_id ). get_comment ( comment_id ). edit ( body )
278263
279264 @cached_property
280265 def current_user (self ) -> User :
@@ -557,17 +542,14 @@ def get_merge_request_diff(self, repo_id: str, merge_request_id: int) -> PatchSe
557542 headers , data = self .client .requester .requestJsonAndCheck ("GET" , pr .diff_url , follow_302_redirect = True )
558543 return PatchSet .from_string (data ["data" ])
559544
560- def get_merge_request_discussion (
561- self , repo_id : str , merge_request_id : int , discussion_id : str , only_resolvable : bool = True
562- ) -> Discussion :
545+ def get_merge_request_comment (self , repo_id : str , merge_request_id : int , comment_id : str ) -> Discussion :
563546 """
564- Get a discussion from a merge request.
547+ Get a comment from a merge request.
565548
566549 Args:
567550 repo_id: The repository ID.
568551 merge_request_id: The merge request ID.
569- discussion_id: The discussion ID.
570- only_resolvable: Whether to only return resolvable notes (review comments).
552+ comment_id: The comment ID.
571553
572554 Returns:
573555 The discussion object.
@@ -576,22 +558,14 @@ def get_merge_request_discussion(
576558
577559 comment = None
578560 try :
579- comment = pr .get_issue_comment (discussion_id )
561+ comment = pr .get_issue_comment (comment_id )
580562 except UnknownObjectException :
581- comment = pr .get_review_comment (discussion_id )
582-
583- if only_resolvable :
584- if isinstance (comment , IssueComment ) and comment .reactions .get ("rocket" , 0 ) > 0 :
585- comment = None
586- elif isinstance (comment , PullRequestComment ):
587- unresolved_comment_ids , _ = self ._unresolved_comment_ids (repo_id , merge_request_id )
588- if comment .id not in unresolved_comment_ids :
589- comment = None
563+ comment = pr .get_review_comment (comment_id )
590564
591565 if comment is None :
592- return Discussion (id = discussion_id , notes = [])
566+ return Discussion (id = comment_id , notes = [])
593567
594- return Discussion (id = discussion_id , notes = self ._serialize_comments ([comment ], from_merge_request = True ))
568+ return Discussion (id = comment_id , notes = self ._serialize_comments ([comment ], from_merge_request = True ))
595569
596570 def get_merge_request_review_comments (self , repo_id : str , merge_request_id : int ) -> list [Discussion ]:
597571 """
0 commit comments