feat: archive repos by regex (#54)
This commit is contained in:
parent
183f4267de
commit
396329f4b6
|
@ -36,9 +36,9 @@ pytest -svv
|
|||
|
||||
## Commands & Features
|
||||
|
||||
### `archive-all-repos`
|
||||
### `archive-repos`
|
||||
|
||||
archive all repos in gitea organization
|
||||
archive repos in gitea organization according to regex (dry-run enabled by default)
|
||||
|
||||
### `unwatch-all-repos`
|
||||
|
||||
|
|
|
@ -141,9 +141,11 @@ def close_all_issues() -> None:
|
|||
tea.pot.gitea.close_all_issues()
|
||||
|
||||
|
||||
@app.command("archive-all-repos", help="archive all repos in gitea organization")
|
||||
def archive_all_repos() -> None:
|
||||
tea.pot.gitea.archive_all_repos()
|
||||
@app.command(
|
||||
"archive-repos", help="archive repos in gitea organization according to regex"
|
||||
)
|
||||
def archive_repos(regex: str = Argument(".+"), dry_run: bool = Option(True)) -> None:
|
||||
tea.pot.gitea.archive_repos(regex, dry_run)
|
||||
|
||||
|
||||
@app.command("unwatch-all-repos", help="unwatch all repos in gitea organization")
|
||||
|
|
|
@ -413,11 +413,17 @@ class Gitea:
|
|||
self.org_name, repo_name, issue.number, body={"state": "closed"}
|
||||
)
|
||||
|
||||
def archive_all_repos(self) -> None:
|
||||
for repo in list_all(self.organization_api.org_list_repos, self.org_name):
|
||||
self.repository_api.repo_edit(
|
||||
self.org_name, repo.name, body={"archived": True}
|
||||
)
|
||||
def archive_repos(self, regex: str = ".+", dry_run: bool = True) -> None:
|
||||
if dry_run:
|
||||
logger.info("Dry run enabled. No changes will be made to the repositories.")
|
||||
logger.info(f"Archiving repos with name matching {regex}")
|
||||
for repo_name in self.get_all_repo_names():
|
||||
if re.match(regex, repo_name):
|
||||
logger.info(f"Archived {repo_name}")
|
||||
if not dry_run:
|
||||
self.repository_api.repo_edit(
|
||||
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):
|
||||
|
|
Loading…
Reference in New Issue
Block a user