커밋 API

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

이 API는 리포지토리 커밋에 작용합니다. 커밋에 대한 GitLab 특정 정보를 더 읽어보세요.

응답

이 API의 응답에서 일부 날짜 필드는 중복된 정보로 나타날 수 있습니다.

  • created_at 필드는 다른 GitLab API와의 일관성을 유지하기 위해 존재합니다. 항상 committed_date 필드와 동일합니다.
  • committed_dateauthored_date 필드는 다른 소스에서 생성되며 동일하지 않을 수 있습니다.

리포지토리 커밋 목록

프로젝트에서 리포지토리 커밋 목록을 가져옵니다.

GET /projects/:id/repository/commits
속성 유형 필수 설명
id 정수/문자열 인증된 사용자가 소유한 프로젝트의 ID 또는 URL 인코딩된 경로
ref_name 문자열 아니요 저장소 브랜치, 태그 또는 리비전 범위의 이름 또는 지정되지 않으면 기본 브랜치
since 문자열 아니요 ISO 8601 형식인 YYYY-MM-DDTHH:MM:SSZ에서 이 날짜 이후 또는 이 날짜와 동일한 커밋만 반환
until 문자열 아니요 ISO 8601 형식인 YYYY-MM-DDTHH:MM:SSZ에서 이 날짜 이전 또는 이 날짜와 동일한 커밋만 반환
path 문자열 아니요 파일 경로
author 문자열 아니요 커밋 작성자별로 커밋 검색
all 부울 아니요 저장소에서 모든 커밋 검색
with_stats 부울 아니요 각 커밋에 대한 통계를 응답에 추가
first_parent 부울 아니요 병합 커밋을 볼 때 첫 번째 부모 커밋만 따름
order 문자열 아니요 커밋 순서로 커밋 목록합니다. 가능한 값: default, topo. 기본값은 default로, 커밋은 시간 순서로 역순으로 표시됩니다.
trailers 부울 아니요 모든 커밋에 대해 Git trailers를 구문 분석하여 포함합니다.
curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/5/repository/commits"

예시 응답:

[
  {
    "id": "ed899a2f4b50b4370feeea94676502b42383c746",
    "short_id": "ed899a2f4b5",
    "title": "Replace sanitize with escape once",
    "author_name": "Example User",
    "author_email": "user@example.com",
    "authored_date": "2021-09-20T11:50:22.001+00:00",
    "committer_name": "Administrator",
    "committer_email": "admin@example.com",
    "committed_date": "2021-09-20T11:50:22.001+00:00",
    "created_at": "2021-09-20T11:50:22.001+00:00",
    "message": "Replace sanitize with escape once",
    "parent_ids": [
      "6104942438c14ec7bd21c6cd5bd995272b3faff6"
    ],
    "web_url": "https://gitlab.example.com/janedoe/gitlab-foss/-/commit/ed899a2f4b50b4370feeea94676502b42383c746",
    "trailers": {},
    "extended_trailers": {}
  },
  {
    "id": "6104942438c14ec7bd21c6cd5bd995272b3faff6",
    "short_id": "6104942438c",
    "title": "Sanitize for network graph",
    "author_name": "randx",
    "author_email": "user@example.com",
    "committer_name": "ExampleName",
    "committer_email": "user@example.com",
    "created_at": "2021-09-20T09:06:12.201+00:00",
    "message": "Sanitize for network graph\nCc: John Doe <johndoe@gitlab.com>\nCc: Jane Doe <janedoe@gitlab.com>",
    "parent_ids": [
      "ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"
    ],
    "web_url": "https://gitlab.example.com/janedoe/gitlab-foss/-/commit/ed899a2f4b50b4370feeea94676502b42383c746",
    "trailers": { "Cc": "Jane Doe <janedoe@gitlab.com>" },
    "extended_trailers": { "Cc": ["John Doe <johndoe@gitlab.com>", "Jane Doe <janedoe@gitlab.com>"] }
  }
]

다중 파일 및 동작으로 커밋 만들기

JSON 페이로드를 게시하여 커밋을 만드세요

POST /projects/:id/repository/commits
속성 유형 필수 설명
id 정수/문자열 프로젝트의 ID 또는 URL 인코딩된 경로
branch 문자열 커밋할 브랜치의 이름. 새 브랜치를 만들려면 start_branch 또는 start_sha, 그리고 선택적으로 start_project를 제공하세요.
commit_message 문자열 커밋 메시지
start_branch 문자열 아니요 새 브랜치를 시작할 브랜치의 이름
start_sha 문자열 아니요 새 브랜치를 시작할 커밋의 SHA
start_project 정수/문자열 아니요 새 브랜치를 시작할 프로젝트의 ID 또는 URL 인코딩된 경로. 기본값은 id의 값입니다.
actions[] 배열 일괄 처리로 커밋할 동작 해시의 배열. 속성이 취할 수 있는 내용은 다음 표를 참조하세요.
author_email 문자열 아니요 커밋 작성자의 이메일 주소를 지정하세요
author_name 문자열 아니요 커밋 작성자의 이름을 지정하세요
stats 부울 아니요 커밋 통계를 포함합니다. 기본값은 참입니다
force 부울 아니요 true인 경우 start_branch 또는 start_sha를 기반으로 새 커밋으로 대상 브랜치를 덮어씁니다
actions[] 속성 유형 필수 설명
action 문자열 수행할 동작: create, delete, move, update, 또는 chmod
file_path 문자열 파일의 전체 경로. 예: lib/class.rb.
previous_path 문자열 아니요 이동될 파일의 원래 전체 경로. 예: lib/class1.rb. move 동작에 대해서만고려됩니다.
content 문자열 아니요 파일 내용, delete, chmod, 및 move를 제외한 모든 동작에 필요합니다. content를 지정하지 않은 이동 동작은 기존 파일 내용을 유지하며, content의 다른 값은 파일 내용을 덮어씁니다.
encoding 문자열 아니요 text 또는 base64. 기본값은 text입니다.
last_commit_id 문자열 아니요 마지막으로 알려진 파일 커밋 ID. update, move, 및 delete 동작에만 고려됩니다.
execute_filemode 부울 아니요 true/false인 경우 파일에서 실행 플래그를 활성화/비활성화합니다. chmod 동작에만 고려됩니다.
PAYLOAD=$(cat << 'JSON'
{
  "branch": "main",
  "commit_message": "커밋 메시지",
  "actions": [
    {
      "action": "create",
      "file_path": "foo/bar",
      "content": "일부 내용"
    },
    {
      "action": "delete",
      "file_path": "foo/bar2"
    },
    {
      "action": "move",
      "file_path": "foo/bar3",
      "previous_path": "foo/bar4",
      "content": "일부 내용"
    },
    {
      "action": "update",
      "file_path": "foo/bar5",
      "content": "새로운 내용"
    },
    {
      "action": "chmod",
      "file_path": "foo/bar5",
      "execute_filemode": true
    }
  ]
}
JSON
)
curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --header "Content-Type: application/json" \
  --data "$PAYLOAD" \
  --url "https://gitlab.example.com/api/v4/projects/1/repository/commits"

예시 응답:

{
  "id": "ed899a2f4b50b4370feeea94676502b42383c746",
  "short_id": "ed899a2f4b5",
  "title": "커밋 메시지",
  "author_name": "예제 사용자",
  "author_email": "user@example.com",
  "committer_name": "예제 사용자",
  "committer_email": "user@example.com",
  "created_at": "2016-09-20T09:26:24.000-07:00",
  "message": "커밋 메시지",
  "parent_ids": [
    "ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"
  ],
  "committed_date": "2016-09-20T09:26:24.000-07:00",
  "authored_date": "2016-09-20T09:26:24.000-07:00",
  "stats": {
    "additions": 2,
    "deletions": 2,
    "total": 4
  },
  "status": null,
  "web_url": "https://gitlab.example.com/janedoe/gitlab-foss/-/commit/ed899a2f4b50b4370feeea94676502b42383c746"
}

GitLab은 폼 인코딩을 지원합니다. 다음은 커밋 API를 폼 인코딩하여 사용하는 예시입니다:

curl --request POST \
     --form "branch=main" \
     --form "commit_message=커밋 메시지" \
     --form "start_branch=main" \
     --form "actions[][action]=create" \
     --form "actions[][file_path]=foo/bar" \
     --form "actions[][content]=</path/to/local.file" \
     --form "actions[][action]=delete" \
     --form "actions[][file_path]=foo/bar2" \
     --form "actions[][action]=move" \
     --form "actions[][file_path]=foo/bar3" \
     --form "actions[][previous_path]=foo/bar4" \
     --form "actions[][content]=</path/to/local1.file" \
     --form "actions[][action]=update" \
     --form "actions[][file_path]=foo/bar5" \
     --form "actions[][content]=</path/to/local2.file" \
     --form "actions[][action]=chmod" \
     --form "actions[][file_path]=foo/bar5" \
     --form "actions[][execute_filemode]=true" \
     --header "PRIVATE-TOKEN: <your_access_token>" \
     "https://gitlab.example.com/api/v4/projects/1/repository/commits"

단일 커밋 가져오기

커밋 해시 또는 브랜치 또는 태그의 이름으로 식별된 특정 커밋을 가져옵니다.

GET /projects/:id/repository/commits/:sha

매개변수:

속성 유형 필수 설명
id 정수/문자열 인증된 사용자가 소유한 프로젝트의 ID 또는 URL 인코딩된 경로
sha 문자열 커밋 해시 또는 리포지토리 브랜치 또는 태그의 이름
stats 부울 아니요 커밋 통계를 포함합니다. 기본값은 true입니다.
curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/5/repository/commits/main"

예시 응답:

{
  "id": "6104942438c14ec7bd21c6cd5bd995272b3faff6",
  "short_id": "6104942438c",
  "title": "Sanitize for network graph",
  "author_name": "randx",
  "author_email": "user@example.com",
  "committer_name": "Dmitriy",
  "committer_email": "user@example.com",
  "created_at": "2021-09-20T09:06:12.300+03:00",
  "message": "Sanitize for network graph",
  "committed_date": "2021-09-20T09:06:12.300+03:00",
  "authored_date": "2021-09-20T09:06:12.420+03:00",
  "parent_ids": [
    "ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"
  ],
  "last_pipeline" : {
    "id": 8,
    "ref": "main",
    "sha": "2dc6aa325a317eda67812f05600bdf0fcdc70ab0",
    "status": "created"
  },
  "stats": {
    "additions": 15,
    "deletions": 10,
    "total": 25
  },
  "status": "running",
  "web_url": "https://gitlab.example.com/janedoe/gitlab-foss/-/commit/6104942438c14ec7bd21c6cd5bd995272b3faff6"
}

커밋이 푸시된 참조 가져오기

커밋이 푸시된 모든 참조(브랜치 또는 태그) 가져오기 페이지네이션 매개변수 pageper_page를 사용하여 참조 목록을 제한할 수 있습니다.

GET /projects/:id/repository/commits/:sha/refs

매개변수:

속성 유형 필수 설명
id 정수/문자열 인증된 사용자가 소유한 프로젝트의 ID 또는 URL 인코딩된 경로
sha 문자열 커밋 해시
type 문자열 아니요 커밋의 범위입니다. 가능한 값은 branch, tag, all입니다. 기본값은 all입니다.
curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/5/repository/commits/5937ac0a7beb003549fc5fd26fc247adbce4a52e/refs?type=all"

예시 응답:

[
  {"type": "branch", "name": "'test'"},
  {"type": "branch", "name": "add-balsamiq-file"},
  {"type": "branch", "name": "wip"},
  {"type": "tag", "name": "v1.1.0"}
 ]

커밋의 시퀀스 가져오기

지정된 커밋으로부터 부모 링크를 따라 프로젝트 내의 커밋의 시퀀스 번호를 가져옵니다.

이 API는 본질적으로 지정된 커밋 SHA에 대한 git rev-list --count 명령과 동일한 기능을 제공합니다.

GET /projects/:id/repository/commits/:sha/sequence

매개변수:

속성 유형 필수 설명
id 정수/문자열 인증된 사용자가 소유한 프로젝트의 ID 또는 URL 인코딩된 경로
sha 문자열 커밋 해시
first_parent 부울 아니요 병합 커밋을 보고 첫 번째 부모 커밋만 따르세요.

예시 요청:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/5/repository/commits/5937ac0a7beb003549fc5fd26fc247adbce4a52e/sequence"

예시 응답:

{
  "count": 632
}

커밋 Cherry-pick

주어진 브랜치로 커밋을 Cherry-pick합니다.

POST /projects/:id/repository/commits/:sha/cherry_pick

매개변수:

속성 유형 필수 설명
id 정수/문자열 인증된 사용자가 소유한 프로젝트의 ID 또는 URL-인코딩된 경로
sha 문자열 커밋 해시
branch 문자열 브랜치의 이름
dry_run 부울 아니요 변경 사항을 커밋하지 않습니다. 기본값은 false입니다. GitLab 13.3에서 도입됨
message 문자열 아니요 새 커밋에 사용할 사용자 정의 커밋 메시지. GitLab 14.0에서 도입됨
curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --form "branch=main" \
  --url "https://gitlab.example.com/api/v4/projects/5/repository/commits/main/cherry_pick"

응답 예시:

{
  "id": "8b090c1b79a14f2bd9e8a738f717824ff53aebad",
  "short_id": "8b090c1b",
  "author_name": "Example User",
  "author_email": "user@example.com",
  "authored_date": "2016-12-12T20:10:39.000+01:00",
  "created_at": "2016-12-12T20:10:39.000+01:00",
  "committer_name": "Administrator",
  "committer_email": "admin@example.com",
  "committed_date": "2016-12-12T20:10:39.000+01:00",
  "title": "Feature added",
  "message": "Feature added\n\nSigned-off-by: Example User <user@example.com>\n",
  "parent_ids": [
    "a738f717824ff53aebad8b090c1b79a14f2bd9e8"
  ],
  "web_url": "https://gitlab.example.com/janedoe/gitlab-foss/-/commit/8b090c1b79a14f2bd9e8a738f717824ff53aebad"
}

Cherry-pick에 실패한 경우 응답은 실패 이유에 대한 상황을 제공합니다:

{
  "message": "죄송합니다,이 커밋을 자동으로 cherry-pick할 수 없습니다. 이 커밋은 이미 cherry-pick되었을 수 있으며 더 최신의 커밋이 변경 내용을 업데이트했을 수 있습니다.",
  "error_code": "empty"
}

이 경우 변경 세트가 비어 있어 cherry-pick에 실패하였으며 이는 해당 커밋이 이미 대상 브랜치에 존재한다는 것을 나타낼 수 있습니다. 다른 가능한 오류 코드는 conflict로, 병합 충돌이 있음을 나타냅니다.

dry_run이 활성화되어 있는 경우, 서버는 Cherry-pick을 적용하지만 실제로 발생하는 변경 사항을 커밋하지 않습니다. Cherry-pick이 깔끔하게 적용되면, API는 200 OK로 응답합니다:

{
  "dry_run": "success"
}

실패한 경우, dry run 없이 실패와 동일한 오류가 표시됩니다.

커밋 Revert

주어진 브랜치에서 커밋을 Revert합니다.

POST /projects/:id/repository/commits/:sha/revert

매개변수:

속성 유형 필수 설명
id 정수/문자열 인증된 사용자가 소유한 프로젝트의 ID 또는 URL-인코딩된 경로
sha 문자열 Revert 할 커밋 SHA
branch 문자열 대상 브랜치 이름
dry_run 부울 아니요 변경 사항을 커밋하지 않습니다. 기본값은 false입니다. 도입됨 in GitLab 13.3
curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --form "branch=main" \
  --url "https://gitlab.example.com/api/v4/projects/5/repository/commits/a738f717824ff53aebad8b090c1b79a14f2bd9e8/revert"

응답 예시:

{
  "id":"8b090c1b79a14f2bd9e8a738f717824ff53aebad",
  "short_id": "8b090c1b",
  "title":"Revert \"Feature added\"",
  "created_at":"2018-11-08T15:55:26.000Z",
  "parent_ids":["a738f717824ff53aebad8b090c1b79a14f2bd9e8"],
  "message":"Revert \"Feature added\"\n\nThis reverts commit a738f717824ff53aebad8b090c1b79a14f2bd9e8",
  "author_name":"Administrator",
  "author_email":"admin@example.com",
  "authored_date":"2018-11-08T15:55:26.000Z",
  "committer_name":"Administrator",
  "committer_email":"admin@example.com",
  "committed_date":"2018-11-08T15:55:26.000Z",
  "web_url": "https://gitlab.example.com/janedoe/gitlab-foss/-/commit/8b090c1b79a14f2bd9e8a738f717824ff53aebad"
}

Revert에 실패한 경우, 응답은 실패 이유에 대한 상황을 제공합니다:

{
  "message": "죄송합니다,이 커밋을 자동으로 되돌릴 수 없습니다. 이 커밋은 이미 되돌려졌을 수 있고 더 최신의 커밋이 변경 내용을 업데이트했을 수 있습니다.",
  "error_code": "conflict"
}

이 경우 Revert가 실패한 이유는 시도한 Revert가 병합 충돌을 생성하였기 때문입니다. 다른 가능한 오류 코드는 empty로, 변경 세트가 비어 있음을 나타내어 이미 Revert된 변경으로 인한 것입니다.

dry_run이 활성화되어 있는 경우, 서버는 Revert를 적용하지만 실제로 발생하는 변경 사항을 커밋하지 않습니다. Revert가 깔끔하게 적용되면, API는 200 OK로 응답합니다:

{
  "dry_run": "success"
}

실패한 경우, dry run 없이 실패와 동일한 오류가 표시됩니다.

커밋의 차이점 가져오기

프로젝트에서 커밋의 차이를 가져옵니다.

GET /projects/:id/repository/commits/:sha/diff

매개변수:

속성 유형 필수 설명
id integer/string yes 인증된 사용자가 소유한 프로젝트의 ID 또는 URL 인코딩된 경로
sha string yes 커밋 해시 또는 저장소 브랜치 또는 태그의 이름
unidiff boolean no 통일된 차이 형식으로 diffs를 나타냅니다. 기본값은 false입니다. GitLab 16.5에서 도입되었습니다.
curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/5/repository/commits/main/diff"

예시 응답:

[
  {
    "diff": "@@ -71,6 +71,8 @@\n sudo -u git -H bundle exec rake migrate_keys RAILS_ENV=production\n sudo -u git -H bundle exec rake migrate_inline_notes RAILS_ENV=production\n \n+sudo -u git -H bundle exec rake gitlab:assets:compile RAILS_ENV=production\n+\n ```\n \n ### 6. Update config files",
    "new_path": "doc/update/5.4-to-6.0.md",
    "old_path": "doc/update/5.4-to-6.0.md",
    "a_mode": null,
    "b_mode": "100644",
    "new_file": false,
    "renamed_file": false,
    "deleted_file": false
  }
]

커밋의 코멘트 가져오기

프로젝트에서 커밋의 코멘트를 가져옵니다.

GET /projects/:id/repository/commits/:sha/comments

매개변수:

속성 유형 필수 설명
id integer/string yes 인증된 사용자가 소유한 프로젝트의 ID 또는 URL 인코딩된 경로
sha string yes 커밋 해시 또는 저장소 브랜치 또는 태그의 이름
curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/5/repository/commits/main/comments"

예시 응답:

[
  {
    "note": "this code is really nice",
    "author": {
      "id": 11,
      "username": "admin",
      "email": "admin@local.host",
      "name": "Administrator",
      "state": "active",
      "created_at": "2014-03-06T08:17:35.000Z"
    }
  }
]

커밋에 코멘트 작성하기

커밋에 코멘트를 추가합니다.

특정 파일의 특정 라인에 코멘트를 작성하려면 전체 커밋 SHA, path, line, 그리고 line_typenew로 지정해야 합니다.

다음 경우 중 하나 이상이 유효한 경우 적어도 하나의 경우에 마지막 커밋의 끝에 코멘트가 추가됩니다:

  • ‘sha’ 대신 브랜치 또는 태그이고 ‘line’ 또는 ‘path’가 잘못된 경우
  • ‘line’ 번호가 잘못된 경우 (존재하지 않음)
  • ‘path’가 잘못된 경우 (존재하지 않음)

위의 경우 중 하나라도 해당되는 경우, line, line_type, path의 응답은 null로 설정됩니다.

병합 요청에 주석을 다는 다른 방법에 대해서는 병합 요청 노트 생성를 참조하십시오.

POST /projects/:id/repository/commits/:sha/comments
속성 유형 필수 설명
id integer/string yes 인증된 사용자가 소유한 프로젝트의 ID 또는 URL 인코딩된 경로
sha string yes 저장소 브랜치 또는 태그의 이름 또는 커밋 SHA
note string yes 코멘트의 텍스트
path string no 저장소와 관련된 파일 경로
line integer no 코멘트가 위치해야 하는 라인 번호
line_type string no 라인 유형. new 또는 old를 인수로 취합니다
curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --form "note=Nice picture\!" \
  --form "path=README.md" \
  --form "line=11" \
  --form "line_type=new" \
  --url "https://gitlab.example.com/api/v4/projects/17/repository/commits/18f3e63d05582537db6d183d9d557be09e1f90c8/comments"

예시 응답:

{
   "author" : {
      "web_url" : "https://gitlab.example.com/janedoe",
      "avatar_url" : "https://gitlab.example.com/uploads/user/avatar/28/jane-doe-400-400.png",
      "username" : "janedoe",
      "state" : "active",
      "name" : "Jane Doe",
      "id" : 28
   },
   "created_at" : "2016-01-19T09:44:55.600Z",
   "line_type" : "new",
   "path" : "README.md",
   "line" : 11,
   "note" : "Nice picture!"
}

커밋의 토론 가져오기

프로젝트에서 커밋의 토론을 가져옵니다.

GET /projects/:id/repository/commits/:sha/discussions

매개변수:

속성 유형 필수 설명
id 정수/문자열 인증된 사용자가 소유한 프로젝트의 ID 또는 URL-인코딩된 경로
sha 문자열 커밋 해시 또는 저장소 브랜치 또는 태그의 이름
curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/5/repository/commits/4604744a1c64de00ff62e1e8a6766919923d2b41/discussions"

예시 응답:

[
  {
    "id": "4604744a1c64de00ff62e1e8a6766919923d2b41",
    "individual_note": true,
    "notes": [
      {
        "id": 334686748,
        "type": null,
        "body": "좋은 코드 조각이네요!",
        "attachment": null,
        "author" : {
          "id" : 28,
          "name" : "Jane Doe",
          "username" : "janedoe",
          "web_url" : "https://gitlab.example.com/janedoe",
          "state" : "active",
          "avatar_url" : "https://gitlab.example.com/uploads/user/avatar/28/jane-doe-400-400.png"
        },
        "created_at": "2020-04-30T18:48:11.432Z",
        "updated_at": "2020-04-30T18:48:11.432Z",
        "system": false,
        "noteable_id": null,
        "noteable_type": "Commit",
        "resolvable": false,
        "confidential": null,
        "noteable_iid": null,
        "commands_changes": {}
      }
    ]
  }
]

커밋 상태

GitLab과 함께 사용하는 커밋 상태 API입니다.

커밋의 상태 나열

프로젝트의 커밋 상태를 나열합니다. 페이지네이션 매개변수 pageper_page를 사용하여 참조 목록을 제한할 수 있습니다.

GET /projects/:id/repository/commits/:sha/statuses
속성 유형 필수 설명
id 정수/문자열 인증된 사용자가 소유한 프로젝트의 ID 또는 URL-인코딩된 경로
sha 문자열 커밋 SHA
ref 문자열 아니오 저장소 브랜치 또는 태그의 이름 또는 제공되지 않은 경우 기본 브랜치
stage 문자열 아니오 빌드 단계로 필터링, 예: test
name 문자열 아니오 작업 이름으로 필터링, 예: bundler:audit
all 부울 아니오 가장 최신 상태뿐만 아니라 모든 상태를 반환합니다.
curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/17/repository/commits/18f3e63d05582537db6d183d9d557be09e1f90c8/statuses"

예시 응답:

[
   ...

   {
      "status" : "pending",
      "created_at" : "2016-01-19T08:40:25.934Z",
      "started_at" : null,
      "name" : "bundler:audit",
      "allow_failure" : true,
      "author" : {
         "username" : "janedoe",
         "state" : "active",
         "web_url" : "https://gitlab.example.com/janedoe",
         "avatar_url" : "https://gitlab.example.com/uploads/user/avatar/28/jane-doe-400-400.png",
         "id" : 28,
         "name" : "Jane Doe"
      },
      "description" : null,
      "sha" : "18f3e63d05582537db6d183d9d557be09e1f90c8",
      "target_url" : "https://gitlab.example.com/janedoe/gitlab-foss/builds/91",
      "finished_at" : null,
      "id" : 91,
      "ref" : "main"
   },
   {
      "started_at" : null,
      "name" : "test",
      "allow_failure" : false,
      "status" : "pending",
      "created_at" : "2016-01-19T08:40:25.832Z",
      "target_url" : "https://gitlab.example.com/janedoe/gitlab-foss/builds/90",
      "id" : 90,
      "finished_at" : null,
      "ref" : "main",
      "sha" : "18f3e63d05582537db6d183d9d557be09e1f90c8",
      "author" : {
         "id" : 28,
         "name" : "Jane Doe",
         "username" : "janedoe",
         "web_url" : "https://gitlab.example.com/janedoe",
         "state" : "active",
         "avatar_url" : "https://gitlab.example.com/uploads/user/avatar/28/jane-doe-400-400.png"
      },
      "description" : null
   },

   ...
]

커밋의 파이프라인 상태 설정

커밋의 파이프라인 상태를 추가하거나 업데이트합니다. 커밋이 병합 요청과 관련된 경우, API 호출은 병합 요청의 소스 브랜치에 대상 커밋을 지정해야 합니다.

POST /projects/:id/statuses/:sha
속성 유형 필수 여부 설명
id integer/string 인증된 사용자가 소유한 프로젝트의 ID 또는 URL 인코딩된 경로
sha string 커밋 SHA
state string 상태. 다음 중 하나일 수 있습니다: pending, running, success, failed, canceled
ref string 아니오 상태가 참조하는 ref (브랜치 또는 태그)
name 또는 context string 아니오 다른 시스템의 상태와 구분하기 위한 레이블. 기본값은 default
target_url string 아니오 이 상태와 연결할 대상 URL
description string 아니오 상태의 간단한 설명
coverage float 아니오 전체 코드 커버리지
pipeline_id integer 아니오 상태를 설정할 파이프라인의 ID. 동일한 SHA에 대한 여러 파이프라인의 경우 사용합니다.
curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/17/statuses/18f3e63d05582537db6d183d9d557be09e1f90c8?state=success"

예시 응답:

{
   "author" : {
      "web_url" : "https://gitlab.example.com/janedoe",
      "name" : "Jane Doe",
      "avatar_url" : "https://gitlab.example.com/uploads/user/avatar/28/jane-doe-400-400.png",
      "username" : "janedoe",
      "state" : "active",
      "id" : 28
   },
   "name" : "default",
   "sha" : "18f3e63d05582537db6d183d9d557be09e1f90c8",
   "status" : "success",
   "coverage": 100.0,
   "description" : null,
   "id" : 93,
   "target_url" : null,
   "ref" : null,
   "started_at" : null,
   "created_at" : "2016-01-19T09:05:50.355Z",
   "allow_failure" : false,
   "finished_at" : "2016-01-19T09:05:50.365Z"
}

커밋과 연관된 병합 요청 목록

특정 커밋을 처음 소개한 병합 요청에 대한 정보를 반환합니다.

GET /projects/:id/repository/commits/:sha/merge_requests
속성 유형 필수 여부 설명
id integer/string 인증된 사용자가 소유한 프로젝트의 ID 또는 URL 인코딩된 경로
sha string 커밋 SHA
curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/5/repository/commits/af5b13261899fb2c0db30abdd0af8b07cb44fdc5/merge_requests"

예시 응답:

[
   {
      "id":45,
      "iid":1,
      "project_id":35,
      "title":"새 파일 추가",
      "description":"",
      "state":"opened",
      "created_at":"2018-03-26T17:26:30.916Z",
      "updated_at":"2018-03-26T17:26:30.916Z",
      "target_branch":"main",
      "source_branch":"test-branch",
      "upvotes":0,
      "downvotes":0,
      "author" : {
        "web_url" : "https://gitlab.example.com/janedoe",
        "name" : "Jane Doe",
        "avatar_url" : "https://gitlab.example.com/uploads/user/avatar/28/jane-doe-400-400.png",
        "username" : "janedoe",
        "state" : "active",
        "id" : 28
      },
      "assignee":null,
      "source_project_id":35,
      "target_project_id":35,
      "labels":[ ],
      "draft":false,
      "work_in_progress":false,
    # 이하 생략
   }
]

커밋의 GPG 서명 얻기

커밋에서 GPG 서명을 가져옵니다, 만약 서명되어 있다면. 서명되지 않은 커밋의 경우 404 응답이 발생합니다.

GET /projects/:id/repository/commits/:sha/signature

매개변수:

속성 유형 필수 설명
id 정수/문자열 인증된 사용자가 소유한 프로젝트의 ID 또는 URL 인코딩된 경로
sha 문자열 리포지토리 브랜치 또는 태그의 커밋 해시 또는 이름
curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/1/repository/commits/da738facbc19eb2fc2cef57c49be0e6038570352/signature"

커밋이 GPG로 서명된 경우 예시 응답:

{
  "signature_type": "PGP",
  "verification_status": "verified",
  "gpg_key_id": 1,
  "gpg_key_primary_keyid": "8254AAB3FBD54AC9",
  "gpg_key_user_name": "John Doe",
  "gpg_key_user_email": "johndoe@example.com",
  "gpg_key_subkey_id": null,
  "commit_source": "gitaly"
}

커밋이 X.509로 서명된 경우 예시 응답:

{
  "signature_type": "X509",
  "verification_status": "unverified",
  "x509_certificate": {
    "id": 1,
    "subject": "CN=gitlab@example.org,OU=Example,O=World",
    "subject_key_identifier": "BC:BC:BC:BC:BC:BC:BC:BC:BC:BC:BC:BC:BC:BC:BC:BC:BC:BC:BC:BC",
    "email": "gitlab@example.org",
    "serial_number": 278969561018901340486471282831158785578,
    "certificate_status": "good",
    "x509_issuer": {
      "id": 1,
      "subject": "CN=PKI,OU=Example,O=World",
      "subject_key_identifier": "AB:AB:AB:AB:AB:AB:AB:AB:AB:AB:AB:AB:AB:AB:AB:AB:AB:AB:AB:AB",
      "crl_url": "http://example.com/pki.crl"
    }
  },
  "commit_source": "gitaly"
}

커밋이 서명되지 않은 경우 예시 응답:

{
  "message": "404 GPG Signature Not Found"
}