diff --git a/github_rest_api/github.py b/github_rest_api/github.py index 988a5d2..f6d4db3 100644 --- a/github_rest_api/github.py +++ b/github_rest_api/github.py @@ -255,6 +255,12 @@ def get_branches(self) -> list[dict[str, Any]]: """List branches in this repository.""" return self._get(url=self._url_branches).json() + def get_branch(self, branch: str) -> dict[str, Any]: + """Get information about a specific branch. + :param branch: The name of the branch. + """ + return self._get(url=f"{self._url_branches}/{branch}").json() + def delete(self) -> requests.Response: """Delete this repository from GitHub.""" return self._delete(url=self._url_repo) diff --git a/pyproject.toml b/pyproject.toml index 292ff52..e13b244 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ requires = [ "hatchling" ] [project] name = "github-rest-api" -version = "0.33.1" +version = "0.34.0" description = "Simple wrapper of GitHub REST APIs." readme = "README.md" authors = [ { name = "Ben Du", email = "longendu@yahoo.com" } ] diff --git a/tests/test_github.py b/tests/test_github.py index 3c39683..cd83541 100644 --- a/tests/test_github.py +++ b/tests/test_github.py @@ -1,4 +1,4 @@ -from github_rest_api.github import User, Organization +from github_rest_api.github import User, Organization, Repository def test_user_get_repositories(): @@ -15,3 +15,11 @@ def test_organization_get_repositories(): org = Organization(token, org_name) repos = org.get_repositories() assert len(repos) > 0 + + +def test_repository_get_branch(): + token = "" + repo_name = "legendu-net/github_rest_api" + repo = Repository(token, repo_name) + branch = repo.get_branch("main") + assert branch["name"] == "main" diff --git a/uv.lock b/uv.lock index b139d14..f294986 100644 --- a/uv.lock +++ b/uv.lock @@ -195,7 +195,7 @@ wheels = [ [[package]] name = "github-rest-api" -version = "0.33.0" +version = "0.34.0" source = { editable = "." } dependencies = [ { name = "dulwich" },