Поддержка этой версии GitHub Enterprise будет прекращена 2023-03-15. Исправления выпускаться не будут даже при критических проблемах безопасности. Для повышения производительности, укрепления безопасности и новых функций установите последнюю версию GitHub Enterprise. Чтобы получить справку по обновлению, обратитесь в службу поддержки GitHub Enterprise.
We've recently moved some of the REST API documentation. If you can't find what you're looking for, you might try the Actions REST API page.
Перехватчики предварительного получения репозитория
Используйте REST API для просмотра и изменения принудительного применения перехватчиков предварительного получения, доступных в репозитории.
Сведения о перехватчиках предварительного получения репозитория
Имя | Тип | Описание |
---|---|---|
name | string | Имя перехватчика. |
enforcement | string | Состояние принудительного применения перехватчика в этом репозитории. |
configuration_url | string | URL-адрес конечной точки, в которой задано принудительное применение. |
Возможные значения для принудительного применения: enabled
, disabled
и testing
. disabled
указывает, что перехватчик предварительного получения не будет выполняться. enabled
указывает, что он будет выполняться и отклонять все отправки, результатом которых является переход в ненулевое состояние. testing
означает, что скрипт будет выполняться, но отправки отклоняться не будут.
configuration_url
может быть ссылкой на этот репозиторий, это владелец организации или глобальная конфигурация. Авторизация на доступ к конечной точке в configuration_url
определяется на уровне владельца или администратора сайта.
List pre-receive hooks for a repository
List all pre-receive hooks that are enabled or testing for this repository as well as any disabled hooks that are allowed to be enabled at the repository level. Pre-receive hooks that are disabled at a higher level and are not configurable will not be listed.
Параметры
Заголовки |
---|
Имя, Тип, Описание |
accept stringSetting to |
Параметры пути |
Имя, Тип, Описание |
owner stringОбязательноThe account owner of the repository. The name is not case sensitive. |
repo stringОбязательноThe name of the repository. The name is not case sensitive. |
Параметры запроса |
Имя, Тип, Описание |
per_page integerThe number of results per page (max 100). Значение по умолчанию: |
page integerPage number of the results to fetch. Значение по умолчанию: |
direction stringThe direction to sort the results by. Значение по умолчанию: Может быть одним из: |
sort stringЗначение по умолчанию: Может быть одним из: |
Коды состояния HTTP-ответа
Код состояния | Описание |
---|---|
200 | OK |
Примеры кода
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/pre-receive-hooks
Response
Status: 200
[
{
"id": 42,
"name": "Check Commits",
"enforcement": "disabled",
"configuration_url": "https://github.example.com/api/v3/orgs/octocat/pre-receive-hooks/42"
}
]
Get a pre-receive hook for a repository
Параметры
Заголовки |
---|
Имя, Тип, Описание |
accept stringSetting to |
Параметры пути |
Имя, Тип, Описание |
owner stringОбязательноThe account owner of the repository. The name is not case sensitive. |
repo stringОбязательноThe name of the repository. The name is not case sensitive. |
pre_receive_hook_id integerОбязательноThe unique identifier of the pre-receive hook. |
Коды состояния HTTP-ответа
Код состояния | Описание |
---|---|
200 | OK |
Примеры кода
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/pre-receive-hooks/PRE_RECEIVE_HOOK_ID
Response
Status: 200
{
"id": 42,
"name": "Check Commits",
"enforcement": "disabled",
"configuration_url": "https://github.example.com/api/v3/orgs/octocat/pre-receive-hooks/42"
}
Update pre-receive hook enforcement for a repository
For pre-receive hooks which are allowed to be configured at the repo level, you can set enforcement
Параметры
Заголовки |
---|
Имя, Тип, Описание |
accept stringSetting to |
Параметры пути |
Имя, Тип, Описание |
owner stringОбязательноThe account owner of the repository. The name is not case sensitive. |
repo stringОбязательноThe name of the repository. The name is not case sensitive. |
pre_receive_hook_id integerОбязательноThe unique identifier of the pre-receive hook. |
Параметры запроса |
Имя, Тип, Описание |
enforcement stringThe state of enforcement for the hook on this repository. Может быть одним из: |
Коды состояния HTTP-ответа
Код состояния | Описание |
---|---|
200 | OK |
Примеры кода
curl \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/pre-receive-hooks/PRE_RECEIVE_HOOK_ID \
-d '{"enforcement":"enabled"}'
Response
Status: 200
{
"id": 42,
"name": "Check Commits",
"enforcement": "enabled",
"configuration_url": "https://github.example.com/api/v3/repos/octocat/hello-world/pre-receive-hooks/42"
}
Remove pre-receive hook enforcement for a repository
Deletes any overridden enforcement on this repository for the specified hook.
Responds with effective values inherited from owner and/or global level.
Параметры
Заголовки |
---|
Имя, Тип, Описание |
accept stringSetting to |
Параметры пути |
Имя, Тип, Описание |
owner stringОбязательноThe account owner of the repository. The name is not case sensitive. |
repo stringОбязательноThe name of the repository. The name is not case sensitive. |
pre_receive_hook_id integerОбязательноThe unique identifier of the pre-receive hook. |
Коды состояния HTTP-ответа
Код состояния | Описание |
---|---|
200 | Responds with effective values inherited from owner and/or global level. |
Примеры кода
curl \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/pre-receive-hooks/PRE_RECEIVE_HOOK_ID
Responds with effective values inherited from owner and/or global level.
Status: 200
{
"id": 42,
"name": "Check Commits",
"enforcement": "disabled",
"configuration_url": "https://github.example.com/api/v3/orgs/octocat/pre-receive-hooks/42"
}