8. GET /repos/{username}/{reponame}/compare/{basehead}
— сравнить две ветки/тега/коммитаNew
Описание
Сравнивает два тега, коммита или ветки и возвращает разницу между ними (аналог git diff
). Полезно для анализа изменений перед созданием запроса на слияние.
Тело запроса
Для этого метода нет тела запроса. Все параметры передаются через URL.
Параметры запроса
Поле | Тип | Описание |
---|---|---|
username | Path | Имя владельца репозитория (обязательный) |
reponame | Path | Название репозитория (обязательный) |
basehead | Path | Сравниваемые ссылки в формате base...head (обязательный) |
page | Query | Номер страницы (по умолчанию: 1) (необязательный) |
per_page | Query | Количество результатов на странице (максимум 50) (необязательный) |
Формат
basehead
:
base...head
— например:main...feature/new-ui
,v1.0.0...v1.1.0
,abc123...def456
.
Пример запроса
curl -X GET "https://api.gitverse.ru/repos/dlborun/APInewTestRepo4.3/compare/main...feature/new-ui" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Accept: application/vnd.gitverse.object+json;version=1"
Ответ (200 OK
)
{
"url": "https://api.gitverse.ru/repos/dlborun/APInewTestRepo4.3/compare/main...feature/new-ui",
"html_url": "https://gitverse.ru/dlborun/APInewTestRepo4.3/compare/main...feature/new-ui",
"status": "diverged",
"ahead_by": 3,
"behind_by": 2,
"total_commits": 5,
"base_commit": {
"sha": "main_sha...",
"url": "https://api.gitverse.ru/repos/dlborun/APInewTestRepo4.3/commits/main_sha...",
"html_url": "https://gitverse.ru/dlborun/APInewTestRepo4.3/commit/main_sha..."
},
"merge_base_commit": {
"sha": "common_ancestor_sha...",
"url": "https://api.gitverse.ru/repos/dlborun/APInewTestRepo4.3/commits/common_ancestor_sha...",
"html_url": "https://gitverse.ru/dlborun/APInewTestRepo4.3/commit/common_ancestor_sha..."
},
"commits": [
{
"sha": "commit1...",
"author": { "login": "user1" },
"commit": { "message": "Add new UI component" },
"stats": { "additions": 40, "deletions": 10 },
"files": [
{ "filename": "ui/button.js", "status": "modified" }
]
}
],
"files": [
{
"filename": "ui/button.js",
"status": "modified",
"additions": 15,
"deletions": 5,
"changes": 20,
"sha": "file_sha...",
"patch": "..."
}
]
}