Class GitClient
java.lang.Object
ink.icoding.github4j.GithubClient
ink.icoding.github4j.client.GitClient
Git 底层对象操作客户端。
提供对 Git 引用(refs)、提交(commits)、Blob、Tree、标签(tags)等底层对象的 CRUD 操作。 这些是 Git 数据模型的低级 API,适用于需要精细操作 Git 对象的场景。
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription创建新的 Git Blob 对象。创建新的 Git 提交对象。创建新引用(分支或标签)。创建新的 Git 标签对象(轻量标签应直接用 createRef)。创建新的 Git Tree 对象。void删除引用。获取指定 Git Blob 对象(文件内容)。获取指定 Git 提交对象。获取指定引用(分支/标签)。获取指定 Git 标签对象。获取指定 Git Tree 对象(目录结构)。列出指定命名空间下的所有引用。更新引用指向的提交。Methods inherited from class GithubClient
actions, builder, configureObjectMapper, delete, get, get, getPaged, getRaw, gists, git, issues, meta, notifications, orgs, patch, post, projects, pulls, put, putNoBody, releases, repos, search, teams, users, webhooksModifier and TypeMethodDescriptionactions()static GithubClientBuilderbuilder()protected com.fasterxml.jackson.databind.ObjectMapperconfigureObjectMapper(com.fasterxml.jackson.databind.ObjectMapper mapper) protected GithubResponse<Void> protected <T> GithubResponse<T> get(String path, com.fasterxml.jackson.core.type.TypeReference<T> typeRef, Map<String, String> queryParams) protected <T> GithubResponse<T> protected <T> Page<T> protected GithubResponse<byte[]> gists()git()issues()meta()orgs()protected <T> GithubResponse<T> protected <T> GithubResponse<T> projects()pulls()protected <T> GithubResponse<T> protected GithubResponse<Void> releases()repos()search()teams()users()webhooks()
-
Constructor Details
-
GitClient
-
-
Method Details
-
getRef
获取指定引用(分支/标签)。对应端点:
GET /repos/{owner}/{repo}/git/ref/{ref}示例:
getRef("owner", "repo", "heads/main")- Parameters:
owner- 仓库所有者repo- 仓库名称ref- 引用路径(如 "heads/main", "tags/v1.0")- Returns:
- 引用信息,包含 sha 和指向的对象
-
listRefs
-
createRef
-
updateRef
-
deleteRef
-
getCommit
获取指定 Git 提交对象。对应端点:
GET /repos/{owner}/{repo}/git/commits/{commit_sha}- Parameters:
owner- 仓库所有者repo- 仓库名称commitSha- 提交的 SHA 哈希- Returns:
- Git 提交对象,包含 tree、parent、author、committer、message 等
-
createCommit
-
getBlob
获取指定 Git Blob 对象(文件内容)。对应端点:
GET /repos/{owner}/{repo}/git/blobs/{file_sha}- Parameters:
owner- 仓库所有者repo- 仓库名称fileSha- Blob 的 SHA 哈希- Returns:
- Git Blob 对象,包含 content 和 encoding
-
createBlob
-
getTree
public GithubResponse<GitTree> getTree(String owner, String repo, String treeSha, boolean recursive) 获取指定 Git Tree 对象(目录结构)。对应端点:
GET /repos/{owner}/{repo}/git/trees/{tree_sha}- Parameters:
owner- 仓库所有者repo- 仓库名称treeSha- Tree 的 SHA 哈希recursive- 是否递归获取子树(设为 true 获取完整文件树)- Returns:
- Git Tree 对象,包含 tree 条目列表
-
createTree
-
getTag
获取指定 Git 标签对象。对应端点:
GET /repos/{owner}/{repo}/git/tags/{tag_sha}- Parameters:
owner- 仓库所有者repo- 仓库名称tagSha- 标签的 SHA 哈希- Returns:
- Git 标签对象,包含 tag、message、tagger、object 等
-
createTag
-