From cae195a4b52bedadcd06ccd432682be70245f3fa Mon Sep 17 00:00:00 2001 From: BoYanZh Date: Wed, 2 Oct 2024 14:14:24 -0400 Subject: [PATCH] feat: unwatch all repos --- README.md | 8 ++++---- joint_teapot/app.py | 5 +++++ joint_teapot/workers/gitea.py | 6 ++++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c308139..e02fc28 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,10 @@ pytest -svv archive all repos in gitea organization +### `unwatch-all-repos` + +unwatch all repos in gitea organization + ### `check-issues` check the existence of issue by title on gitea @@ -124,7 +128,3 @@ upload assignment grades to canvas from grade file (GRADE.txt by default), read ## License MIT - -## Compile - -- case 0: 0 diff --git a/joint_teapot/app.py b/joint_teapot/app.py index 1fad06d..fb4c27a 100644 --- a/joint_teapot/app.py +++ b/joint_teapot/app.py @@ -128,6 +128,11 @@ def archive_all_repos() -> None: tea.pot.gitea.archive_all_repos() +@app.command("unwatch-all-repos", help="unwatch all repos in gitea organization") +def unwatch_all_repos() -> None: + tea.pot.gitea.unwatch_all_repos() + + @app.command("get-no-collaborator-repos", help="list all repos with no collaborators") def get_no_collaborator_repos() -> None: tea.pot.gitea.get_no_collaborator_repos() diff --git a/joint_teapot/workers/gitea.py b/joint_teapot/workers/gitea.py index 337668b..6986355 100644 --- a/joint_teapot/workers/gitea.py +++ b/joint_teapot/workers/gitea.py @@ -415,6 +415,12 @@ class Gitea: self.org_name, repo.name, body={"archived": True} ) + def unwatch_all_repos(self) -> None: + for repo in list_all(self.organization_api.org_list_repos, self.org_name): + self.repository_api.user_current_delete_subscription( + self.org_name, repo.name + ) + def get_all_teams(self) -> Dict[str, List[str]]: res: Dict[str, List[str]] = {} for team in list_all(self.organization_api.org_list_teams, self.org_name):