변경 제안 API

Tier: Free, Premium, Ultimate Offering: GitLab.com, Self-managed, GitLab Dedicated

이 페이지는 변경 제안에 대한 API를 설명합니다.

모든 변경 제안 API 호출은 인증되어야 합니다.

제안 생성

API를 통해 제안을 생성하려면 Discussions API를 사용하여 병합 요청 차이에 새로운 스레드를 만듭니다. 제안의 형식은 다음과 같습니다:

```suggestion:-3+0
예시 텍스트
```

제안 적용

병합 요청에서 제안된 패치를 적용합니다. 사용자는 적어도 Developer 역할을 가져야 합니다.

PUT /suggestions/:id/apply
속성 유형 필수 여부 설명
id 정수 제안의 ID
commit_message 문자열 아니요 기본 생성된 메시지나 프로젝트의 기본 메시지 대신 사용할 사용자 정의 커밋 메시지
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/suggestions/5/apply"

예시 응답:

{
  "id": 5,
  "from_line": 10,
  "to_line": 10,
  "applicable": true,
  "applied": false,
  "from_content": "This is an eaxmple\n",
  "to_content": "This is an example\n"
}

다중 제안 적용

PUT /suggestions/batch_apply
속성 유형 필수 여부 설명
ids 정수 제안의 ID들
commit_message 문자열 아니요 기본 생성된 메시지나 프로젝트의 기본 메시지 대신 사용할 사용자 정의 커밋 메시지
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" --header 'Content-Type: application/json' --data '{"ids": [5, 6]}' "https://gitlab.example.com/api/v4/suggestions/batch_apply"

예시 응답:

[
  {
    "id": 5,
    "from_line": 10,
    "to_line": 10,
    "applicable": true,
    "applied": false,
    "from_content": "This is an eaxmple\n",
    "to_content": "This is an example\n"
  },
  {
    "id": 6,
    "from_line": 19,
    "to_line": 19,
    "applicable": true,
    "applied": false,
    "from_content": "This is another eaxmple\n",
    "to_content": "This is another example\n"
  }
 ]