변경 제안 API

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

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

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

제안 생성

API를 통해 제안을 생성하려면 Discussions API를 사용하여 Merge Request 차이에서 새 스레드를 생성하세요. 제안의 형식은 다음과 같습니다:

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

제안 적용

Merge Request에서 제안된 패치를 적용합니다. 사용자는 이러한 작업을 수행하려면 적어도 개발자 역할이 있어야 합니다.

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"
  }
 ]