Skip to content

Commit cf72aeb

Browse files
authored
Merge pull request #59 from legendu-net/dev
Merge dev Into main
2 parents 3ab6abb + 68a0714 commit cf72aeb

4 files changed

Lines changed: 17 additions & 3 deletions

File tree

github_rest_api/github.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,12 @@ def get_branches(self) -> list[dict[str, Any]]:
255255
"""List branches in this repository."""
256256
return self._get(url=self._url_branches).json()
257257

258+
def get_branch(self, branch: str) -> dict[str, Any]:
259+
"""Get information about a specific branch.
260+
:param branch: The name of the branch.
261+
"""
262+
return self._get(url=f"{self._url_branches}/{branch}").json()
263+
258264
def delete(self) -> requests.Response:
259265
"""Delete this repository from GitHub."""
260266
return self._delete(url=self._url_repo)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ requires = [ "hatchling" ]
44

55
[project]
66
name = "github-rest-api"
7-
version = "0.33.1"
7+
version = "0.34.0"
88
description = "Simple wrapper of GitHub REST APIs."
99
readme = "README.md"
1010
authors = [ { name = "Ben Du", email = "longendu@yahoo.com" } ]

tests/test_github.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from github_rest_api.github import User, Organization
1+
from github_rest_api.github import User, Organization, Repository
22

33

44
def test_user_get_repositories():
@@ -15,3 +15,11 @@ def test_organization_get_repositories():
1515
org = Organization(token, org_name)
1616
repos = org.get_repositories()
1717
assert len(repos) > 0
18+
19+
20+
def test_repository_get_branch():
21+
token = ""
22+
repo_name = "legendu-net/github_rest_api"
23+
repo = Repository(token, repo_name)
24+
branch = repo.get_branch("main")
25+
assert branch["name"] == "main"

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)