커밋 API

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

이 API는 리포지터리 커밋에 작동합니다. 커밋에 대한 GitLab-specific 정보는 여기에서 자세히 알아보세요.

응답

이 API에서의 일부 날짜 필드는 중복된 정보인 것처럼 보일 수 있습니다.

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

리포지터리 커밋 디렉터리

  • GitLab 15.10에서 소개된 작성자별 커밋

프로젝트의 리포지터리 커밋 디렉터리을 가져옵니다.

GET /projects/:id/repository/commits
속성 유형 필수여부 설명
id integer/string yes 인증된 사용자가 소유한 프로젝트의 ID 또는 URL-encoded path
ref_name string no 리포지터리 브랜치, 태그 또는 리비전 범위의 이름 또는 지정되지 않은 경우 기본 브랜치
since string no ISO 8601 형식의 날짜인 이 날짜 이후 또는 이후의 커밋만 반환
until string no ISO 8601 형식의 날짜인 이 날짜 이전 또는 이전의 커밋만 반환
path string no 파일 경로
author string no 커밋 작성자별 커밋 검색
all boolean no 리포지터리에서 모든 커밋을 검색
with_stats boolean no 각 커밋에 대한 통계를 응답에 추가
first_parent boolean no Merge 커밋을 볼 때 첫 번째 부모 커밋만 따름
order string no 커밋 순서대로 나열. 가능한 값: default, topo. 기본값은 default이며, 커밋은 시간 역순으로 표시됩니다.
trailers boolean no 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": "예시 사용자",
    "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": "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 integer/string yes 프로젝트의 ID 또는 URL-encoded path
branch string yes 커밋을 수행할 브랜치의 이름. 새 브랜치를 만들려면 start_branch 또는 start_sha와 선택적으로 start_project를 제공
commit_message string yes 커밋 메시지
start_branch string no 새 브랜치를 시작할 브랜치의 이름
start_sha string no 새 브랜치를 시작할 커밋의 SHA
start_project integer/string no 새 브랜치를 시작할 프로젝트의 ID 또는 URL-encoded path. 기본값은 id의 값입니다.
actions[] array yes 배치로 커밋할 작업 해시의 배열. 사용할 수 있는 속성은 다음 테이블을 참조하세요.
author_email string no 커밋 작성자 이메일 주소 지정
author_name string no 커밋 작성자 이름 지정
stats boolean no 커밋 통계 포함. 기본값은 true
force boolean no true일 때 start_branch 또는 start_sha를 기반으로 새 커밋으로 대상 브랜치를 덮어씁니다.
actions[] 속성 유형 필수여부 설명
action string yes 수행할 작업: create, delete, move, update, 또는 chmod.
file_path string yes 파일의 전체 경로. 예: lib/class.rb.
previous_path string no 이동 중인 파일의 원래 전체 경로. 예: lib/class1.rb. move 동작에만 해당됨.
content string no 파일 내용. delete, chmod, move를 제외한 모든 것에 필요. content를 지정하지 않은 이동 작업은 존재하는 파일 내용을 보존하며, content의 다른 값은 파일 내용을 덮어씁니다.
encoding string no text 또는 base64. 기본값은 text입니다.
last_commit_id string no 알려진 파일 커밋 ID. update, move, delete 작업에서만 고려됨.
execute_filemode boolean no 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은 form encoding을 지원합니다. 다음은 폼 인코딩을 사용하는 커밋 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 부울 아니요 Merge 커밋을 볼 때 첫 번째 부모 커밋 만 따릅니다.

예시 요청:

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

예시 응답:

{
  "count": 632
}

커밋 가져오기

특정 브랜치에 커밋을 Cherry-pick합니다.

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": "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": "죄송합니다. 이 커밋을 자동으로 선택할 수 없습니다.이 커밋은 이미 선택되었을 수 있거나 더 최신의 커밋이 그 내용을 업데이트했을 수 있습니다.",
  "error_code": "empty"
}

이 경우 변경 세트가 비어 있고 해당 커밋이 이미 대상 브랜치에 존재할 가능성이 높기 때문에 Cherry-pick에 실패했습니다. 다른 가능한 오류 코드는 conflict이며, 이는 Merge 충돌이 발생했음을 나타냅니다.

dry_run이 활성화된 경우 서버는 Cherry-pick을 적용하려 시도하지만 실제로 어떤 결과 변경도 커밋하지 않습니다. Cherry-pick이 깨끗하게 적용되면 API는 200 OK로 응답합니다:

{
  "dry_run": "success"
}

실패 시, 드라이런 옵션이나 없는 실패와 동일한 오류가 표시됩니다.

커밋 되돌리기

주어진 브랜치에서 커밋을 되돌립니다.

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

매개변수:

속성 유형 필수여부 설명
id integer/string yes 프로젝트의 ID 또는 URL-인코딩된 경로
sha string yes 되돌릴 커밋 SHA
branch string yes 대상 브랜치 이름
dry_run boolean no 변경 내용을 커밋하지 않습니다. 기본값은 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":"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"
}

되돌림에 실패한 경우, 응답에 실패한 이유에 대한 상황이 제공됩니다:

{
  "message": "Sorry, we cannot revert this commit automatically. This commit may already have been reverted, or a more recent commit may have updated some of its content.",
  "error_code": "conflict"
}

이 경우, 되돌림이 실패한 이유는 시도한 되돌림이 Merge 충돌을 생성했기 때문입니다. 다른 가능한 오류 코드는 empty로, 이는 변경 세트가 이미 되돌려진 것으로 추정되어 비어 있는 것을 나타냅니다.

dry_run이 활성화된 경우, 서버는 되돌림을 적용하지만 실제로 결과적인 변경내용을 커밋하지는 않습니다. 되돌림이 깨끗하게 적용되면, 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 unified diff 형식으로 차이를 확인합니다. 기본값은 false입니다. Introduced in 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_typepath에 대한 응답은 null로 설정됩니다.

Merge Request에 코멘트를 추가하는 다른 방법은 Notes API에서 새 Merge Request 노트 생성 및 Discussions API에서 Merge Request diff에 새로운 스레드 생성을 참조하세요.

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
   },
   
   ...
]

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

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

POST /projects/:id/statuses/:sha
속성 유형 필수 설명
id 정수/문자열 인증된 사용자가 소유한 프로젝트의 ID 또는 URL 인코딩된 경로
sha 문자열 커밋 SHA
state 문자열 상태의 상태. 다음 중 하나일 수 있습니다: pending, running, success, failed, canceled
ref 문자열 아니요 상태가 참조하는 ref (브랜치 또는 태그)
name or context 문자열 아니요 이 상태를 다른 시스템의 상태와 구별하는 데 사용되는 레이블. 기본값은 default
target_url 문자열 아니요 이 상태와 관련된 대상 URL
description 문자열 아니요 상태의 간단한 설명
coverage 부동소수점 아니요 총 코드 커버리지
pipeline_id 정수 아니요 상태를 설정할 파이프라인의 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"
}

커밋과 관련된 Merge Request 디렉터리

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

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":"can_be_merged",
      "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"
}