diff --git a/changelogs/unreleased/api-refs-for-commit.yml b/changelogs/unreleased/api-refs-for-commit.yml new file mode 100644 index 0000000000000000000000000000000000000000..df8a2b0eccc9ec15c7dd695c1e7a00348a733c9f --- /dev/null +++ b/changelogs/unreleased/api-refs-for-commit.yml @@ -0,0 +1,5 @@ +--- +title: 'API: Get references a commit is pushed to' +merge_request: 15026 +author: Robert Schilling +type: added diff --git a/doc/api/commits.md b/doc/api/commits.md index 63554c63057623f9dde217c3c339dc9420105a69..3c12906def43c13fae4c476f1756bc930d6e9b92 100644 --- a/doc/api/commits.md +++ b/doc/api/commits.md @@ -198,6 +198,39 @@ Example response: } ``` +## Get references a commit is pushed to + +> [Introduced][ce-15026] in GitLab 10.6 + +Get all references (from branches or tags) a commit is pushed to. + +``` +GET /projects/:id/repository/commits/:sha/refs +``` + +Parameters: + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user +| `sha` | string | yes | The commit hash | +| `type` | string | no | The scope of commits. Possible values `branches`, `tags`, `all`. Default is a `all`. | + +```bash +curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --form "type=all" "https://gitlab.example.com/api/v4/projects/5/repository/commits/5937ac0a7beb003549fc5fd26fc247adbce4a52e/refs" +``` + +Example response: + +```json +[ + {"name": "'test'"}, + {"name": "master"}, + {"name": "v1.1.0"} +] + +``` + ## Cherry pick a commit > [Introduced][ce-8047] in GitLab 8.15. @@ -500,3 +533,4 @@ Example response: [ce-6096]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6096 "Multi-file commit" [ce-8047]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8047 +[ce-15026]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/15026