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