Add skills/gitea/references/pull-requests.md
This commit is contained in:
@@ -0,0 +1,123 @@
|
|||||||
|
# Pull Requests API reference
|
||||||
|
|
||||||
|
Base: `https://git.mpm.to/api/v1`
|
||||||
|
|
||||||
|
Note: In Gitea, pull requests are fetched via the issues endpoint with `type=pulls`, or via the dedicated `/pulls` endpoint.
|
||||||
|
|
||||||
|
## List pull requests for a repository
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -s -H "Authorization: token e82a7235b948fbbeea60329422fcac89fa5a5ce8" \
|
||||||
|
"https://git.mpm.to/api/v1/repos/{owner}/{repo}/pulls?state=open&limit=50&page=1"
|
||||||
|
```
|
||||||
|
|
||||||
|
Query params:
|
||||||
|
- `state`: `open` | `closed` | `all`
|
||||||
|
- `sort`: `oldest` | `recentupdate` | `leastupdate` | `mostcomment` | `leastcomment` | `priority`
|
||||||
|
- `milestone`: milestone ID
|
||||||
|
- `labels`: comma-separated label IDs
|
||||||
|
|
||||||
|
Key response fields: `number`, `title`, `body`, `state`, `user.login`, `head.label`, `base.label`, `mergeable`, `merged`, `merged_at`, `created_at`, `html_url`.
|
||||||
|
|
||||||
|
## Get a single pull request
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -s -H "Authorization: token e82a7235b948fbbeea60329422fcac89fa5a5ce8" \
|
||||||
|
"https://git.mpm.to/api/v1/repos/{owner}/{repo}/pulls/{index}"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Create a pull request
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -s -X POST \
|
||||||
|
-H "Authorization: token e82a7235b948fbbeea60329422fcac89fa5a5ce8" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{
|
||||||
|
"title": "PR title",
|
||||||
|
"body": "Description (markdown supported)",
|
||||||
|
"head": "feature-branch",
|
||||||
|
"base": "main",
|
||||||
|
"assignees": ["username"],
|
||||||
|
"labels": [123],
|
||||||
|
"milestone": 1
|
||||||
|
}' \
|
||||||
|
"https://git.mpm.to/api/v1/repos/{owner}/{repo}/pulls"
|
||||||
|
```
|
||||||
|
|
||||||
|
`head` is the branch with changes; `base` is the branch to merge into.
|
||||||
|
|
||||||
|
## Update a pull request
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -s -X PATCH \
|
||||||
|
-H "Authorization: token e82a7235b948fbbeea60329422fcac89fa5a5ce8" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{
|
||||||
|
"title": "Updated title",
|
||||||
|
"body": "Updated description",
|
||||||
|
"state": "closed"
|
||||||
|
}' \
|
||||||
|
"https://git.mpm.to/api/v1/repos/{owner}/{repo}/pulls/{index}"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Merge a pull request
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -s -X POST \
|
||||||
|
-H "Authorization: token e82a7235b948fbbeea60329422fcac89fa5a5ce8" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{
|
||||||
|
"Do": "merge",
|
||||||
|
"merge_message_field": "Merge PR #N: title",
|
||||||
|
"merge_style": "merge"
|
||||||
|
}' \
|
||||||
|
"https://git.mpm.to/api/v1/repos/{owner}/{repo}/pulls/{index}/merge"
|
||||||
|
```
|
||||||
|
|
||||||
|
`merge_style` options: `merge` | `rebase` | `rebase-merge` | `squash`. Always confirm with the user before merging.
|
||||||
|
|
||||||
|
## Check if a pull request is merged
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -s -o /dev/null -w "%{http_code}" \
|
||||||
|
-H "Authorization: token e82a7235b948fbbeea60329422fcac89fa5a5ce8" \
|
||||||
|
"https://git.mpm.to/api/v1/repos/{owner}/{repo}/pulls/{index}/merge"
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns `204` if merged, `404` if not merged.
|
||||||
|
|
||||||
|
## List PR reviews
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -s -H "Authorization: token e82a7235b948fbbeea60329422fcac89fa5a5ce8" \
|
||||||
|
"https://git.mpm.to/api/v1/repos/{owner}/{repo}/pulls/{index}/reviews"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Submit a PR review
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -s -X POST \
|
||||||
|
-H "Authorization: token e82a7235b948fbbeea60329422fcac89fa5a5ce8" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{
|
||||||
|
"body": "Review comment",
|
||||||
|
"event": "APPROVED"
|
||||||
|
}' \
|
||||||
|
"https://git.mpm.to/api/v1/repos/{owner}/{repo}/pulls/{index}/reviews"
|
||||||
|
```
|
||||||
|
|
||||||
|
`event` options: `APPROVED` | `REQUEST_CHANGES` | `COMMENT`.
|
||||||
|
|
||||||
|
## List PR commits
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -s -H "Authorization: token e82a7235b948fbbeea60329422fcac89fa5a5ce8" \
|
||||||
|
"https://git.mpm.to/api/v1/repos/{owner}/{repo}/pulls/{index}/commits"
|
||||||
|
```
|
||||||
|
|
||||||
|
## List PR files changed
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -s -H "Authorization: token e82a7235b948fbbeea60329422fcac89fa5a5ce8" \
|
||||||
|
"https://git.mpm.to/api/v1/repos/{owner}/{repo}/pulls/{index}/files"
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user