feat: create comment

This commit is contained in:
张泊明518370910136 2024-07-05 04:11:18 -04:00
parent dac569259b
commit a497f03089
GPG Key ID: CA088E6D9284F870
4 changed files with 35 additions and 0 deletions

View File

@ -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. 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`
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. 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.

View File

@ -75,6 +75,15 @@ def create_issue_for_repos(
tea.pot.create_issue_for_repos(repo_names, title, body, from_file, use_regex) 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") @app.command("create-milestones", help="create milestones on gitea")
def create_milestone_for_repos( def create_milestone_for_repos(
repo_names: List[str], title: str, description: str, due_on: datetime repo_names: List[str], title: str, description: str, due_on: datetime

View File

@ -152,6 +152,14 @@ class Teapot:
for repo_name in affected_repos: for repo_name in affected_repos:
self.gitea.create_issue(repo_name, title, content) 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( def create_milestone_for_repos(
self, repo_names: List[str], title: str, description: str, due_on: datetime self, repo_names: List[str], title: str, description: str, due_on: datetime
) -> None: ) -> None:

View File

@ -346,6 +346,20 @@ class Gitea:
) )
logger.info(f'Created issue "{title}" in {repo_name}') 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( def create_milestone(
self, self,
repo_name: str, repo_name: str,