查看提交列表
功能介绍
查看提交列表
调试
您可以在API Explorer中调试该接口,支持自动认证鉴权。API Explorer可以自动生成SDK代码示例,并提供SDK代码示例调试功能。
URI
GET /api/v4/repositories/{repository_id}/repository/commit-list
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
repository_id |
是 |
Integer |
参数解释: 仓库的ID,通过查询用户所有仓库接口查询项目列表获取。 约束限制: 不涉及。 取值范围: 1-2147483647 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
ref_name |
否 |
String |
分支/tag名 |
since |
否 |
String |
起始时间(不包含) |
until |
否 |
String |
结束时间(不包含) |
path |
否 |
String |
The file path |
message |
否 |
String |
提交信息或者commit id |
author |
否 |
String |
代码作者名称 |
order_by_date |
否 |
Boolean |
是否按照时间降序排序 |
offset |
否 |
Integer |
偏移量 取值范围: 0-2147483647 默认取值: 0 |
limit |
否 |
Integer |
返回数量 取值范围: 1-100 默认取值: 20 |
follow |
否 |
Boolean |
为true时可以追踪文件移动、改名前后的提交记录 |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
参数解释: 用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 约束限制: 必传。 取值范围: 字符串长度不少于1,不超过10万。 默认取值: 不涉及。 |
响应参数
状态码:200
参数 |
参数类型 |
描述 |
---|---|---|
commits |
Array of CommitDto objects |
提交列表 |
date_title |
Array of DateTitleDto objects |
按天统计信息 |
参数 |
参数类型 |
描述 |
---|---|---|
id |
String |
提交ID |
message |
String |
提交描述 |
parent_ids |
Array of strings |
父提交ID |
authored_date |
String |
创建时间 |
author_name |
String |
作者名字 |
author_email |
String |
作者邮箱 |
committed_date |
String |
提交时间 |
committer_name |
String |
提交人邮箱 |
committer_email |
String |
提交人邮箱 |
open_gpg_verified |
Boolean |
gpg验证 |
verification_status |
Integer |
gpg校验状态 取值范围: 0-10 |
gpg_primary_key_id |
String |
gpg验证key |
name |
String |
名称 |
gpg_nick_name |
String |
gpg昵称 |
gpg_tenant_name |
String |
gpg企业名称 |
gpg_user_name |
String |
gpg用户名 |
short_id |
String |
短提交id |
created_at |
String |
创建时间 |
title |
String |
提交标题 |
author_avatar_url |
String |
作者头像地址 |
committer_avatar_url |
String |
提交者头像地址 |
relate_url |
Array of RelatedCommitSimpleDto objects |
关联任务 |
nick_name |
String |
作者昵称 |
tenant_name |
String |
租户名称 |
user_name |
String |
用户名 |
状态码:401
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
参数解释: 错误码。 |
error_msg |
String |
参数解释: 错误信息。 |
状态码:403
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
参数解释: 错误码。 |
error_msg |
String |
参数解释: 错误信息。 |
请求示例
/api/v4/repositories/{repository_id}/repository/commit-list?ref_name=master&since=2025-01-01&until=2025-02-01&offset=0&limit=20
响应示例
状态码:200
获取提交列表成功
{ "commits" : [ { "id" : "97b70c9e6e****ba981d19feaad61135", "message" : "xx", "parent_ids" : [ "assdf" ], "authored_date" : "2025-06-27T01:52:33.000Z", "author_name" : "****", "author_email" : null, "committed_date" : "2025-06-27T01:52:33.000Z", "committer_name" : "****", "committer_email" : null, "open_gpg_verified" : true, "verification_status" : 1, "gpg_primary_key_id" : "****", "name" : "****", "gpg_nick_name" : null, "gpg_tenant_name" : null, "gpg_user_name" : null, "short_id" : "97b70c9e", "created_at" : "2025-06-27T01:52:33.000Z", "title" : "****", "author_avatar_url" : null, "committer_avatar_url" : null, "relate_url" : [ { "related_id" : "related_id_e8a2e829628e", "related_url" : "related_url_cadb457b1b14" } ], "nick_name" : null, "tenant_name" : null, "user_name" : null } ], "date_title" : [ { "day" : "2025-06-27", "commits_count" : 2 }, { "day" : "2025-06-25", "commits_count" : 1 }, { "day" : "2025-06-24", "commits_count" : 2 }, { "day" : "2025-06-23", "commits_count" : 4 }, { "day" : "2025-06-21", "commits_count" : 2 }, { "day" : "2025-06-09", "commits_count" : 2 } ] }
状态码:401
Unauthorized
{ "error_code" : "DEV.00000003", "error_msg" : "认证信息过期" }
状态码:403
Bad Request
{ "error_code" : "CH.004403", "error_msg" : "您没有操作权限,请升级权限后重试。" }
SDK代码示例
SDK代码示例如下。
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.codehub.v3.region.CodeHubRegion; import com.huaweicloud.sdk.codehub.v3.*; import com.huaweicloud.sdk.codehub.v3.model.*; public class ListCommitsSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); ICredential auth = new BasicCredentials() .withAk(ak) .withSk(sk); CodeHubClient client = CodeHubClient.newBuilder() .withCredential(auth) .withRegion(CodeHubRegion.valueOf("<YOUR REGION>")) .build(); ListCommitsRequest request = new ListCommitsRequest(); try { ListCommitsResponse response = client.listCommits(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkcodehub.v3.region.codehub_region import CodeHubRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkcodehub.v3 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] credentials = BasicCredentials(ak, sk) client = CodeHubClient.new_builder() \ .with_credentials(credentials) \ .with_region(CodeHubRegion.value_of("<YOUR REGION>")) \ .build() try: request = ListCommitsRequest() response = client.list_commits(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
Go
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" codehub "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codehub/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codehub/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codehub/v3/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). Build() client := codehub.NewCodeHubClient( codehub.CodeHubClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.ListCommitsRequest{} response, err := client.ListCommits(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
获取提交列表成功 |
401 |
Unauthorized |
403 |
Bad Request |
错误码
请参见错误码。