Lowercase repo name

This commit is contained in:
Stéphane Bidoul 2021-11-21 18:38:50 +01:00
parent 83fb48d982
commit 89d9823992
No known key found for this signature in database
GPG key ID: BCAB2555446B5B92

View file

@ -2,7 +2,7 @@ from enum import Enum
from typing import Any, Optional from typing import Any, Optional
import httpx import httpx
from pydantic import BaseModel from pydantic import BaseModel, validator
from .exceptions import NotFoundOnGitHub from .exceptions import NotFoundOnGitHub
from .settings import settings from .settings import settings
@ -29,6 +29,11 @@ class CommitInfo(BaseModel):
pr: Optional[int] pr: Optional[int]
git_commit: str git_commit: str
@validator("repo")
@classmethod
def validate_repo(cls, v: str) -> str:
return v.lower()
async def get_branch_info(repo: str, branch: str) -> CommitInfo: async def get_branch_info(repo: str, branch: str) -> CommitInfo:
branch_data = await _github_request("GET", f"/repos/{repo}/git/ref/heads/{branch}") branch_data = await _github_request("GET", f"/repos/{repo}/git/ref/heads/{branch}")