From df376b3174810427aed420679f78f83e3ca23eae Mon Sep 17 00:00:00 2001 From: Ben Du Date: Mon, 27 Apr 2026 20:24:20 -0700 Subject: [PATCH 1/3] add method get_branch --- github_rest_api/github.py | 6 ++++++ tests/test_github.py | 10 +++++++++- uv.lock | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) 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/tests/test_github.py b/tests/test_github.py index 3c39683..dfd3aab 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 = "dclong/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..ec3b722 100644 --- a/uv.lock +++ b/uv.lock @@ -195,7 +195,7 @@ wheels = [ [[package]] name = "github-rest-api" -version = "0.33.0" +version = "0.33.1" source = { editable = "." } dependencies = [ { name = "dulwich" }, From 0bb327bbcc867c5f3f3512121e27c1cb4192ab6b Mon Sep 17 00:00:00 2001 From: Ben Du Date: Mon, 27 Apr 2026 20:24:43 -0700 Subject: [PATCH 2/3] bump up version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" } ] From 68a07143cbde8f4388fadf555e8eb83e5b6812d8 Mon Sep 17 00:00:00 2001 From: Ben Du Date: Mon, 27 Apr 2026 20:29:39 -0700 Subject: [PATCH 3/3] use legendu-net/* instead of dclong/* --- tests/test_github.py | 2 +- uv.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_github.py b/tests/test_github.py index dfd3aab..cd83541 100644 --- a/tests/test_github.py +++ b/tests/test_github.py @@ -19,7 +19,7 @@ def test_organization_get_repositories(): def test_repository_get_branch(): token = "" - repo_name = "dclong/github_rest_api" + 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 ec3b722..f294986 100644 --- a/uv.lock +++ b/uv.lock @@ -195,7 +195,7 @@ wheels = [ [[package]] name = "github-rest-api" -version = "0.33.1" +version = "0.34.0" source = { editable = "." } dependencies = [ { name = "dulwich" },