Obtaining the Change Content of a Specified File Introduced by a Commit
Function
This API is used to obtain the change content of a specified file introduced by a commit.
Debugging
You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.
Authorization Information
Each account root user has all the permissions required to call all APIs, but IAM users must be assigned the following required identity policy-based permissions. For details about the required permissions, see Permissions Policies and Supported Actions.
|
Action |
Access Level |
Resource Type (*: required) |
Condition Key |
Alias |
Dependencies |
|---|---|---|---|---|---|
|
codeartsrepo:repository:getRepository |
Read |
- |
- |
- |
- |
URI
GET https://{hostURL}/v4/repositories/{repository_id}/repository/commits/file-diff
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
repository_id |
Yes |
Integer |
Definition You can query the project list to obtain the repository ID by calling the API used to query user's all repositories. Constraints N/A Default Value N/A Value range: 1~2147483647 |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
sha |
Yes |
String |
Definition Branch name, tag name, or commit ID. |
|
path |
No |
String |
Definition File path. Range 1–100,000 characters. |
|
old_path |
No |
String |
Definition Path of the file before renaming. Range 1–100,000 characters. |
|
ignore_whitespace_change |
No |
Boolean |
Definition Whether to ignore the change of blank quantity. Range
Default value: false |
Request Parameters
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
X-Auth-Token |
Yes |
String |
Definition User token. Obtain one by calling the IAM API Obtaining a User Token. The value of X-Subject-Token in the response header is a token. Constraints N/A Range 1–100,000 characters. Default Value N/A |
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
[items] |
Array of FileDiffDto objects |
File difference list |
|
Parameter |
Type |
Description |
|---|---|---|
|
old_path |
String |
Definition Old file name. Range 1–10,000 characters. |
|
new_path |
AnyType |
Definition New file name. Range 1–10,000 characters. |
|
a_mode |
String |
Definition Old file permissions. |
|
b_mode |
String |
Definition New file permissions. |
|
new_file |
Boolean |
Definition New file or not. Range
|
|
renamed_file |
Boolean |
Definition Renamed file or not. Range
|
|
deleted_file |
Boolean |
Definition Deleted file or not. Range
|
|
diff |
String |
Definition Difference information. |
|
too_large |
Boolean |
Definition Large file or not. Range
|
|
added_lines |
Integer |
Definition Number of added lines. Value range: 0~2147483647 |
|
removed_lines |
Integer |
Definition Number of deleted lines. Value range: 0~2147483647 |
Status code: 401
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Definition Error code. |
|
error_msg |
String |
Definition Error message. |
Example Requests
GET https://{endpoint}/v4/repositories/2111915566/repository/commits/file-diff?sha=master&path=date2&old_path=date
Example Responses
Status code: 200
ok
{
"old_path" : "date2",
"new_path" : "date2",
"a_mode" : "100644",
"b_mode" : "0",
"new_file" : false,
"renamed_file" : false,
"deleted_file" : true,
"diff" : "@@ -1 +0,0 @@\\n-11\\n\\\\ No newline at end of file",
"too_large" : false,
"added_lines" : 0,
"removed_lines" : 1
}
Status code: 401
Unauthorized
{
"error_code" : "DEV.00000003",
"error_msg" : "Authentication information expired."
}
Status Codes
|
Status Code |
Description |
|---|---|
|
200 |
ok |
|
401 |
Unauthorized |
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