diff --git a/README.md b/README.md index a363501..94b32c9 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,10 @@ create channels for student groups according to group information on gitea. Opti Example: `python3 -m joint_teapot create-channels-on-mm --prefix p1 --suffix -private --invite-teaching-team` will fetch all repos whose names start with `"p1"` and create channels on mm for these repos like "p1team1-private". Members of a repo will be added to the corresponding channel. And teaching team (adjust in `.env`) will be invited to the channels. +### `create-comment` + +create a comment for an issue on gitea. + ### `create-issues` create issues on gitea. Specify a list of repos (use `--regex` to match against list of patterns), a title, and a body (use `--file` to read from file), in this order. diff --git a/joint_teapot/app.py b/joint_teapot/app.py index 9bb8822..9c634fc 100644 --- a/joint_teapot/app.py +++ b/joint_teapot/app.py @@ -75,6 +75,15 @@ def create_issue_for_repos( tea.pot.create_issue_for_repos(repo_names, title, body, from_file, use_regex) +@app.command("create-comment", help="create a comment for an issue on gitea") +def create_comment( + repo_name: str, + index: int, + body: str = Argument(..., help="comment body"), +) -> None: + tea.pot.create_comment(repo_name, index, body) + + @app.command("create-milestones", help="create milestones on gitea") def create_milestone_for_repos( repo_names: List[str], title: str, description: str, due_on: datetime diff --git a/joint_teapot/teapot.py b/joint_teapot/teapot.py index 3fbff58..e1a946d 100644 --- a/joint_teapot/teapot.py +++ b/joint_teapot/teapot.py @@ -152,6 +152,14 @@ class Teapot: for repo_name in affected_repos: self.gitea.create_issue(repo_name, title, content) + def create_comment( + self, + repo_name: str, + index: int, + body: str, + ) -> None: + self.gitea.create_comment(repo_name, index, body) + def create_milestone_for_repos( self, repo_names: List[str], title: str, description: str, due_on: datetime ) -> None: diff --git a/joint_teapot/workers/gitea.py b/joint_teapot/workers/gitea.py index 828f725..f2ea965 100644 --- a/joint_teapot/workers/gitea.py +++ b/joint_teapot/workers/gitea.py @@ -346,6 +346,20 @@ class Gitea: ) logger.info(f'Created issue "{title}" in {repo_name}') + def create_comment( + self, + repo_name: str, + index: int, + body: str, + ) -> None: + self.issue_api.issue_create_comment( + self.org_name, + repo_name, + index, + body={"body": body}, + ) + logger.info(f"Created comment in {repo_name}/issues/{index}") + def create_milestone( self, repo_name: str,