Creating a Commit
Function
Multiple files in different directories can be submitted 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 submitted.
URI
POST /v2/projects/{repo_id}/repository/commits
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
repo_id |
Yes |
Integer |
Warehouse Short ID |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
Specifies the user token. It can be obtained by calling an IAM API. 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 |
Details |
start_branch |
No |
String |
New branch name when a branch is created. |
actions |
Yes |
Array of CommitAction objects |
Submission Processing List |
author_email |
No |
String |
Submit the author's e-mail address |
author_name |
No |
String |
Name of the author who submits the application. |
stats |
No |
Boolean |
Indicates whether to include submission statistics. The default value is true. |
force |
No |
Boolean |
Indicates whether to overwrite the target branch. When 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 |
Full path of a 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 submission ID. This parameter is valid only when the update, move, or delete operation is performed. |
execute_filemode |
No |
Boolean |
Enables or disables the execution mode of a file. This parameter is valid only when the chmod command is executed. |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
error |
Error object |
Response error. |
result |
CreateCommitResponseBody object |
Difference List |
status |
String |
Status code in a response |
Parameter |
Type |
Description |
---|---|---|
id |
String |
Submit the corresponding SHA ID. |
short_id |
String |
Submit the corresponding short SHA ID. |
title |
String |
Submit Title |
author_name |
String |
Author |
author_email |
String |
Author Email |
committer_name |
String |
Requester |
committer_email |
String |
Submit Author Email |
created_at |
String |
Created |
message |
String |
Details |
parent_ids |
Array of strings |
Parent Submission ID |
committed_date |
String |
Submitted |
authored_date |
String |
Author Submission Time |
stats |
stats object |
Statistics |
Example Requests
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" } ] }
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 } }, "status" : "success" }
Status Codes
Status Code |
Description |
---|---|
200 |
OK |
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.