获取commit的patch¶
GET /api/v5/repos/{owner}/{repo}/commit/{sha}/patch
该接口用于获取指定仓库中某个 commit 的 patch 内容,以 unified diff 格式返回该提交带来的文件变更,便于查看提交的具体改动。
访问令牌支持说明¶
- AtomGit 用户访问令牌(AtomGit user access tokens)
是否允许匿名访问¶
此接口允许匿名访问
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
owner |
path | string | 是 | 仓库所属空间地址(企业、组织或个人的地址path) |
repo |
path | string | 是 | 仓库路径(path) |
sha |
path | string | 是 | commit的sha |
响应参数¶
响应体为指定 commit 的 patch 内容(string,纯文本),以 unified diff 格式描述该提交带来的文件变更。
Note: 返回的是 patch 文本本身,而非 JSON 对象。
请求示例¶
参数说明¶
<owner>替换为仓库所属空间地址 path(企业、组织或个人的地址 path);<repo>替换为仓库路径 path;<sha>替换为 commit 的 sha 值。
cURL¶
Note: 该接口允许匿名访问;如需访问私有仓库,可在 URL 后追加 ?access_token=<token>。
JavaScript¶
// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch("https://api.atomgit.com/api/v5/repos/<owner>/<repo>/commit/<sha>/patch", {
headers: {
"Accept": "text/plain",
},
});
if (!response.ok) {
throw new Error(`请求失败: ${response.status}`);
}
const data = await response.text();
console.log(data);
Python¶
import requests
resp = requests.get(
"https://api.atomgit.com/api/v5/repos/<owner>/<repo>/commit/<sha>/patch",
headers={"Accept": "text/plain"},
timeout=10,
)
resp.raise_for_status()
print(resp.text)
响应示例¶
状态码: 200
diff --git a/README.md b/README.md
index e69de29..d00491f 100644
--- a/README.md
+++ b/README.md
@@ -0,0 +1 @@
+# Example
失败响应¶
该接口未显式定义业务失败响应;出错时由网关/框架返回通用错误(如 401 未认证、404 资源不存在、500 内部错误),具体错误体以实际返回为准。
HTTP 响应状态码¶
| 状态码 | 说明 |
|---|---|
200 |
成功(OK) |
401 |
需要认证(Requires authentication) |
404 |
资源不存在(Not found) |
500 |
系统内部错误(Internal server error) |
错误码¶
| 错误码 | 说明 |
|---|---|
401 |
未认证或凭证无效(缺少/无效的访问凭证) |
404 |
请求的资源不存在 |
500 |
系统内部错误 |
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc