Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions github_rest_api/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" } ]
Expand Down
10 changes: 9 additions & 1 deletion tests/test_github.py
Original file line number Diff line number Diff line change
@@ -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():
Expand All @@ -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"
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading