fix: gitea get team by name not found

This commit is contained in:
张泊明518370910136 2023-07-11 23:38:08 +08:00
parent 2303cf71a2
commit 78f29fc9f6
GPG Key ID: CA088E6D9284F870

View File

@ -62,7 +62,7 @@ class Gitea:
@lru_cache() @lru_cache()
def _get_team_id_by_name(self, name: str) -> int: def _get_team_id_by_name(self, name: str) -> int:
res = self.organization_api.team_search(self.org_name, q=str(name), limit=1) res = self.organization_api.team_search(self.org_name, q=str(name), limit=1)
if len(res["data"]) == 0: if len(res["data"] or []) == 0:
raise Exception(f"{name} not found by name in Gitea") raise Exception(f"{name} not found by name in Gitea")
return res["data"][0]["id"] return res["data"][0]["id"]
@ -339,7 +339,7 @@ class Gitea:
repo_name, repo_name,
body={"title": title, "body": body, "assignees": assignees}, body={"title": title, "body": body, "assignees": assignees},
) )
logger.info(f"Created issue \"{title}\" in {repo_name}") logger.info(f'Created issue "{title}" in {repo_name}')
def create_milestone( def create_milestone(
self, self,