Help Center/ CodeArts Repo/ API Reference/ APIs/ Commit/ Querying a Specific Commit of a Repository

Querying a Specific Commit of a Repository

Updated on 2025-05-15 GMT+08:00

Function

This API is used to obtain a specific commit by commit ID, branch name, or tag name.

URI

GET /v2/projects/{repo_id}/repository/commits/{sha}

Table 1 Path parameters

Parameter

Mandatory

Type

Description

repo_id

Yes

Integer

Repository short ID.

sha

Yes

String

Commit ID, which is the branch or tag name of the repository.

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

stats

No

Boolean

It includes commit statistics. The default value is true.

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

error

Error object

Response error.

result

SpecificCommitInfo object

Response result.

status

String

Response status.

Table 5 Error

Parameter

Type

Description

code

String

Error code.

message

String

Error message.

Table 6 SpecificCommitInfo

Parameter

Type

Description

id

String

SHA ID of a commit.

short_id

String

Short SHA ID of a commit.

title

String

Commit title.

author_name

String

Author.

author_email

String

Author email.

committer_name

String

Committer.

committer_email

String

Committer email.

created_at

String

Creation time.

message

String

Commit message.

parent_ids

Array of strings

Parent commit ID.

committed_date

String

Commit time.

authored_date

String

Author commit time.

stats

stats object

Number of changed lines.

last_pipeline

last_pipeline object

Pipeline information.

Table 7 stats

Parameter

Type

Description

additions

Integer

Number of lines added in changes.

deletions

Integer

Number of lines deleted in changes.

total

Integer

Total number of changed lines.

Table 8 last_pipeline

Parameter

Type

Description

id

Integer

Pipeline ID.

sha

String

SHA ID of a commit.

ref

String

Branch name.

status

String

Pipeline status.

web_url

String

Pipeline URL.

Example Requests

GET https://{endpoint}/v2/projects/859341/repository/commits/master

Example Responses

Status code: 200

OK

{
  "result" : {
    "id" : "85a0a9d5c6e43bc9c3e443ac01f789e24eeef02b",
    "title" : "some commit message",
    "message" : "some commit message",
    "short_id" : "85a0a9d5",
    "author_name" : "repo",
    "author_email" : null,
    "committer_name" : "repo",
    "committer_email" : null,
    "created_at" : "2021-09-26T03:44:51.000Z",
    "parent_ids" : [ "5c114bb316dff4d4a046e09a5c44c816f2433140" ],
    "committed_date" : "2021-09-26T03:44:51.000Z",
    "authored_date" : null,
    "stats" : {
      "additions" : 1,
      "deletions" : 0,
      "total" : 1
    },
    "last_pipeline" : {
      "id" : 292811,
      "sha" : "2202af08836f0afd762d1b151d15ac510b974bdf",
      "ref" : "master",
      "status" : "running",
      "web_url" : "https://test.com/Pipeline_Beta_sdcs00001/202107171926/pipelines/292811"
    }
  },
  "status" : "success"
}

Status Codes

Status Code

Description

200

OK

Error Codes

See Error Codes.

Feedback
咨询盘古Doer

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback