- 응답
- 저장소 커밋 목록
- 여러 파일 및 작업으로 커밋 생성
- 단일 커밋 가져오기
- 커밋이 푸시된 참조 가져오기
- 커밋의 시퀀스 가져오기
- 커밋 체리픽
- 커밋 되돌리기
- 커밋의 차이점 가져오기
- 커밋의 댓글 가져오기
- 커밋에 댓글 추가하기
- 커밋의 토론 가져오기
- 커밋 상태
- 커밋과 연관된 병합 요청 목록
- 커밋의 서명 가져오기
커밋 API
이 API는 저장소 커밋에 대해 작동합니다. 커밋에 대한 GitLab 전용 정보를 자세히 읽어보세요.
응답
이 API의 응답에서 일부 날짜 필드는 중복된 정보처럼 보일 수 있습니다:
-
created_at
필드는 다른 GitLab API와의 일관성을 위해 존재합니다.
항상committed_date
필드와 동일합니다. -
committed_date
및authored_date
필드는 서로 다른 출처에서 생성되며, 동일하지 않을 수 있습니다.
저장소 커밋 목록
- 커밋 작성자 소개 - GitLab 15.10에서.
프로젝트의 저장소 커밋 목록을 가져옵니다.
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 트레일러를 구문 분석하고 포함합니다. |
curl --header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/5/repository/commits"
예시 응답:
[
{
"id": "ed899a2f4b50b4370feeea94676502b42383c746",
"short_id": "ed899a2f4b5",
"title": "Sanitize로 escape 한 번 교체하기",
"author_name": "예시 사용자",
"author_email": "user@example.com",
"authored_date": "2021-09-20T11:50:22.001+00:00",
"committer_name": "관리자",
"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": "Sanitize로 escape 한 번 교체하기",
"parent_ids": [
"6104942438c14ec7bd21c6cd5bd995272b3faff6"
],
"web_url": "https://gitlab.example.com/janedoe/gitlab-foss/-/commit/ed899a2f4b50b4370feeea94676502b42383c746",
"trailers": {},
"extended_trailers": {}
},
{
"id": "6104942438c14ec7bd21c6cd5bd995272b3faff6",
"short_id": "6104942438c",
"title": "네트워크 그래프를 위한 sanitize",
"author_name": "randx",
"author_email": "user@example.com",
"committer_name": "예시Name",
"committer_email": "user@example.com",
"created_at": "2021-09-20T09:06:12.201+00:00",
"message": "네트워크 그래프를 위한 sanitize\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 |
부울 | 아니오 | 커밋 통계를 포함합니다. 기본값은 true입니다. |
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. 오직 업데이트, 이동 및 삭제 작업에서만 고려됩니다. |
execute_filemode |
부울 | 아니오 |
true/false 인 경우 파일에 대한 실행 플래그를 활성화/비활성화합니다. 오직 chmod 작업에 대해서만 고려됩니다. |
PAYLOAD=$(cat << 'JSON'
{
"branch": "main",
"commit_message": "some commit message",
"actions": [
{
"action": "create",
"file_path": "foo/bar",
"content": "some content"
},
{
"action": "delete",
"file_path": "foo/bar2"
},
{
"action": "move",
"file_path": "foo/bar3",
"previous_path": "foo/bar4",
"content": "some content"
},
{
"action": "update",
"file_path": "foo/bar5",
"content": "new 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": "some commit message",
"author_name": "Example User",
"author_email": "user@example.com",
"committer_name": "Example User",
"committer_email": "user@example.com",
"created_at": "2016-09-20T09:26:24.000-07:00",
"message": "some commit 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은 폼 인코딩을 지원합니다. 다음은 폼 인코딩을 사용한 Commit API의 예시입니다:
curl --request POST \
--form "branch=main" \
--form "commit_message=some 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": "네트워크 그래프를 위한 정리",
"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": "네트워크 그래프를 위한 정리",
"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": "생성됨"
},
"stats": {
"additions": 15,
"deletions": 10,
"total": 25
},
"status": "실행 중",
"web_url": "https://gitlab.example.com/janedoe/gitlab-foss/-/commit/6104942438c14ec7bd21c6cd5bd995272b3faff6"
}
커밋이 푸시된 참조 가져오기
커밋이 푸시된 모든 참조(브랜치 또는 태그)를 가져옵니다. 페이지 매김 매개변수 page
및 per_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"}
]
커밋의 시퀀스 가져오기
- GitLab 16.9에 도입됨 (Introduced).
주어진 커밋의 부모 링크를 따라 프로젝트에서 커밋의 시퀀스 번호를 가져옵니다.
이 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
}
커밋 체리픽
지정된 브랜치에 커밋을 체리픽합니다.
POST /projects/:id/repository/commits/:sha/cherry_pick
매개변수:
속성 | 유형 | 필수 | 설명 |
---|---|---|---|
id |
정수/문자열 | 예 | 프로젝트의 ID 또는 URL 인코딩된 경로입니다. |
sha |
문자열 | 예 | 커밋 해시입니다. |
branch |
문자열 | 예 | 브랜치의 이름입니다. |
dry_run |
불리언 | 아니오 | 변경 사항을 커밋하지 않습니다. 기본값은 false입니다. |
message |
문자열 | 아니오 | 새 커밋에 사용할 사용자 지정 커밋 메시지입니다. |
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": "기능 추가됨",
"message": "기능 추가됨\n\n서명: Example User <user@example.com>\n",
"parent_ids": [
"a738f717824ff53aebad8b090c1b79a14f2bd9e8"
],
"web_url": "https://gitlab.example.com/janedoe/gitlab-foss/-/commit/8b090c1b79a14f2bd9e8a738f717824ff53aebad"
}
체리픽이 실패할 경우, 응답은 그 이유에 대한 맥락을 제공합니다:
{
"message": "죄송합니다. 이 커밋을 자동으로 체리픽할 수 없습니다. 이 커밋은 이미 체리픽되었거나 더 최근의 커밋이 일부 내용을 업데이트했을 수 있습니다.",
"error_code": "empty"
}
이 경우, 체리픽이 실패한 이유는 변경 사항 세트가 비어 있었고, 이는 커밋이 이미 대상 브랜치에 존재함을 나타냅니다. 다른 가능한 오류 코드는 conflict
이며, 이는 병합 충돌이 있음을 나타냅니다.
dry_run
이 활성화되면, 서버는 체리픽을 적용하려고 시도하지만 실제로 어떤 결과 변경 사항도 커밋하지 않습니다. 체리픽이 깨끗하게 적용되면, API는 200 OK
로 응답합니다:
{
"dry_run": "success"
}
오류가 발생하면, 오류 메시지는 드라이 런 없이 실패한 경우와 동일하게 표시됩니다.
커밋 되돌리기
주어진 브랜치에서 커밋을 되돌립니다.
POST /projects/:id/repository/commits/:sha/revert
매개변수:
속성 | 유형 | 필수 | 설명 |
---|---|---|---|
id |
integer/string | 예 | 프로젝트의 ID 또는 URL 인코딩 경로 |
sha |
string | 예 | 되돌릴 커밋 SHA |
branch |
string | 예 | 대상 브랜치 이름 |
dry_run |
boolean | 아니요 | 변경 사항을 커밋하지 않습니다. 기본값은 false입니다. |
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":"되돌리기 \"기능 추가됨\"",
"created_at":"2018-11-08T15:55:26.000Z",
"parent_ids":["a738f717824ff53aebad8b090c1b79a14f2bd9e8"],
"message":"되돌리기 \"기능 추가됨\"\n\n이것은 커밋 a738f717824ff53aebad8b090c1b79a14f2bd9e8을(를) 되돌립니다.",
"author_name":"관리자",
"author_email":"admin@example.com",
"authored_date":"2018-11-08T15:55:26.000Z",
"committer_name":"관리자",
"committer_email":"admin@example.com",
"committed_date":"2018-11-08T15:55:26.000Z",
"web_url": "https://gitlab.example.com/janedoe/gitlab-foss/-/commit/8b090c1b79a14f2bd9e8a738f717824ff53aebad"
}
되돌리기에 실패할 경우, 응답은 이유에 대한 정보를 제공합니다:
{
"message": "죄송합니다. 이 커밋을 자동으로 되돌릴 수 없습니다. 이 커밋은 이미 되돌려졌거나, 더 최근의 커밋이 일부 내용을 업데이트했을 수 있습니다.",
"error_code": "conflict"
}
이 경우, 되돌리기가 실패한 이유는 시도된 되돌리기가 병합 충돌을 초래했기 때문입니다.
다른 가능한 오류 코드는 empty
로, 이는 변경 세트가 비어 있음을 나타내며, 이는 변경이 이미 되돌려졌기 때문일 가능성이 큽니다.
dry_run
이 활성화된 경우, 서버는 되돌리기를 적용하려고 시도하지만 결과적으로 변경 사항을 실제로 커밋하지 않습니다.
되돌리기가 원활하게 적용되면, API는 200 OK
로 응답합니다:
{
"dry_run": "성공"
}
실패할 경우, 오류는 드라이 런 없이 실패하는 것과 동일하게 표시됩니다.
커밋의 차이점 가져오기
프로젝트에서 커밋의 차이점을 가져옵니다.
GET /projects/:id/repository/commits/:sha/diff
매개변수:
속성 | 유형 | 필수 | 설명 |
---|---|---|---|
id |
integer/string | 예 | 프로젝트의 ID 또는 URL 인코딩 경로 |
sha |
string | 예 | 커밋 해시 또는 리포지토리 브랜치 또는 태그의 이름 |
unidiff |
boolean | 아니요 | 통합 diff 형식으로 차이를 제시합니다. 기본값은 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. 구성 파일 업데이트",
"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 | 예 | 프로젝트의 ID 또는 URL 인코딩된 경로 |
sha |
string | 예 | 커밋 해시 또는 리포지토리의 브랜치 또는 태그 이름 |
curl --header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/5/repository/commits/main/comments"
예제 응답:
[
{
"note": "이 코드는 정말 멋져요",
"author": {
"id": 11,
"username": "admin",
"email": "admin@local.host",
"name": "관리자",
"state": "active",
"created_at": "2014-03-06T08:17:35.000Z"
}
}
]
커밋에 댓글 추가하기
커밋에 댓글을 추가합니다.
특정 파일의 특정 줄에 댓글을 추가하려면 전체 커밋 SHA, path
, line
, 및 line_type
을 new
로 지정해야 합니다.
댓글은 아래 조건 중 하나라도 유효하면 마지막 커밋의 끝에 추가됩니다:
-
sha
가 브랜치나 태그이고line
또는path
가 유효하지 않은 경우 -
line
번호가 유효하지 않은 경우 (존재하지 않음) -
path
가 유효하지 않은 경우 (존재하지 않음)
위의 경우에는 line
, line_type
및 path
의 응답이 null
로 설정됩니다.
병합 요청에 댓글을 다는 다른 방법에 대해서는 새 병합 요청 노트 만들기에서 확인하세요, 그리고 병합 요청의 차이에서 새 스레드 만들기에서 확인하세요.
POST /projects/:id/repository/commits/:sha/comments
속성 | 형식 | 필수 | 설명 |
---|---|---|---|
id |
integer/string | 예 | 프로젝트의 ID 또는 URL 인코딩된 경로 |
sha |
string | 예 | 커밋 SHA 또는 리포지토리의 브랜치 또는 태그 이름 |
note |
string | 예 | 댓글의 텍스트 |
path |
string | 아니요 | 리포지토리를 기준으로 한 파일 경로 |
line |
integer | 아니요 | 댓글이 위치해야 하는 줄 번호 |
line_type |
string | 아니요 | 줄의 유형. new 또는 old 인수를 사용합니다. |
curl --request POST \
--header "PRIVATE-TOKEN: <your_access_token>" \
--form "note=멋진 사진입니다\!" \
--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" : "제인 도",
"id" : 28
},
"created_at" : "2016-01-19T09:44:55.600Z",
"line_type" : "new",
"path" : "README.md",
"line" : 11,
"note" : "멋진 사진입니다!"
}
커밋의 토론 가져오기
프로젝트의 커밋에 대한 토론을 가져옵니다.
GET /projects/:id/repository/commits/:sha/discussions
매개변수:
속성 | 유형 | 필수 | 설명 |
---|---|---|---|
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/4604744a1c64de00ff62e1e8a6766919923d2b41/discussions"
예제 응답:
[
{
"id": "4604744a1c64de00ff62e1e8a6766919923d2b41",
"individual_note": true,
"notes": [
{
"id": 334686748,
"type": null,
"body": "멋진 코드 조각입니다!",
"attachment": null,
"author" : {
"id" : 28,
"name" : "제인 도",
"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.
커밋의 상태 목록
프로젝트의 커밋 상태를 나열합니다.
페이지 매개변수 page
와 per_page
를 사용하여 참조 목록을 제한할 수 있습니다.
GET /projects/:id/repository/commits/:sha/statuses
속성 | 유형 | 필수 | 설명 |
---|---|---|---|
id |
integer/string | yes | 프로젝트의 ID 또는 URL 인코딩된 경로 |
sha |
string | yes | 커밋 SHA |
ref |
string | no | 저장소 브랜치 또는 태그의 이름, 지정되지 않은 경우 기본 브랜치 |
stage |
string | no |
빌드 단계로 필터링, 예: test
|
name |
string | no |
작업 이름으로 필터링, 예: bundler:audit
|
all |
boolean | no | 최신 상태만이 아닌 모든 상태를 반환 |
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" : "제인 도"
},
"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" : "제인 도",
"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,
"milestone":null,
"merge_when_pipeline_succeeds":false,
"merge_status":"병합 가능",
"sha":"af5b13261899fb2c0db30abdd0af8b07cb44fdc5",
"merge_commit_sha":null,
"squash_commit_sha":null,
"user_notes_count":0,
"discussion_locked":null,
"should_remove_source_branch":null,
"force_remove_source_branch":false,
"web_url":"https://gitlab.example.com/root/test-project/merge_requests/1",
"time_stats":{
"time_estimate":0,
"total_time_spent":0,
"human_time_estimate":null,
"human_total_time_spent":null
}
}
]
커밋의 서명 가져오기
서명된 경우 커밋에서 서명 가져오기
서명되지 않은 커밋의 경우 404 응답이 반환됩니다.
GET /projects/:id/repository/commits/:sha/signature
매개변수:
속성 | 유형 | 필수 | 설명 |
---|---|---|---|
id |
integer/string | 예 | 프로젝트의 ID 또는 URL-인코딩된 경로 |
sha |
string | 예 | 커밋 해시 또는 리포지토리 브랜치 또는 태그의 이름 |
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"
}
커밋이 SSH로 서명된 경우의 응답 예시:
{
"signature_type": "SSH",
"verification_status": "verified",
"key": {
"id": 11,
"title": "Key",
"created_at": "2023-05-08T09:12:38.503Z",
"expires_at": "2024-05-07T00:00:00.000Z",
"key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILZzYDq6DhLp3aX84DGIV3F6Vf+Ae4yCTTz7RnqMJOlR MyKey)",
"usage_type": "auth_and_signing"
},
"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"
}