Skip to content

Commit bf4cc4b

Browse files
committed
Add ability to post a Request comment #348
Signed-off-by: tdruez <[email protected]>
1 parent d03c97a commit bf4cc4b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

workflow/integrations/sourcehut.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,32 @@ def update_issue(self, repo_id, issue_id, title=None, body=None, state=None, lab
128128
)
129129
return response.get("data", {}).get("updateTicket")
130130

131+
def post_comment(self, repo_id, issue_id, comment_body, base_url=None):
132+
"""Post a comment on an existing SourceHut ticket."""
133+
mutation = """
134+
mutation SubmitComment($trackerId: Int!, $ticketId: Int!, $input: SubmitCommentInput!) {
135+
submitComment(trackerId: $trackerId, ticketId: $ticketId, input: $input) {
136+
id
137+
created
138+
ticket {
139+
id
140+
subject
141+
}
142+
}
143+
}
144+
"""
145+
variables = {
146+
"trackerId": self.get_tracker_id(repo_id),
147+
"ticketId": int(issue_id),
148+
"input": {"text": comment_body},
149+
}
150+
151+
response = self.post(
152+
self.api_url,
153+
json={"query": mutation, "variables": variables},
154+
)
155+
return response.get("data", {}).get("submitComment")
156+
131157
@staticmethod
132158
def extract_sourcehut_project(url):
133159
"""Extract the project slug (e.g., ~user/project-name) from a SourceHut URL."""

0 commit comments

Comments
 (0)