Creating a Commit
Description
This API is used to commit multiple files in different directories at a time. If the directory does not exist, the system automatically creates a directory. The forcible overwrite option is supported. When the forcible overwrite flag is set to true, the conflict is ignored and the configuration is forcibly committed.
URI
POST /v2/projects/{repo_id}/repository/commits
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
repo_id |
Yes |
Integer |
Repository short ID |
Request 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. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
branch |
Yes |
String |
Target branch |
|
commit_message |
Yes |
String |
Commit message |
|
start_branch |
No |
String |
Name of the new branch |
|
actions |
Yes |
Array of CommitAction objects |
Commit processing list |
|
author_email |
No |
String |
Committer email address |
|
author_name |
No |
String |
Committer name |
|
stats |
No |
Boolean |
Whether to include commit statistics. The default value is true. |
|
force |
No |
Boolean |
Whether to overwrite the target branch. When the value is true, overwrite the target branch with a new commit based on start_branch. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
action |
Yes |
String |
Operations to be performed: create, delete, move, update, and chmod |
|
file_path |
Yes |
String |
Complete path of the file. For example, lib/class.rb. |
|
previous_path |
No |
String |
Original full path of the file to be moved. For example, lib/class1.rb. This parameter is valid only when the move operation is performed. |
|
content |
No |
String |
File content. This parameter is mandatory for the create and update operations. A move operation that does not specify content retains the existing file content, and any other value of the content overwrites the file content. |
|
encoding |
No |
String |
File encoding: text and base64. The default value is text. |
|
last_commit_id |
No |
String |
Last known commit ID. This parameter is valid only when the update, move, or delete operation is performed. |
|
execute_filemode |
No |
Boolean |
Enable or disable the execution mode of a file. This parameter is valid only when the chmod operation is executed. |
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
error |
Error object |
Response error |
|
result |
CreateCommitResponseBody object |
Difference list |
|
status |
String |
Response status |
|
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 |
Statistics |
Request Examples
POST https://{endpoint}/v2/projects/859341/repository/commits
{
"branch" : "master",
"commit_message" : "some commit message",
"actions" : [ {
"action" : "create",
"file_path" : "test001.txt",
"content" : "some content"
} ]
}
Response Examples
Status code: 200
Request succeeded
{
"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
}
},
"status" : "success"
}
Status Codes
|
Status Codes |
Description |
|---|---|
|
200 |
Request succeeded |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot