Obtaining the File Change Metadata Introduced by Commit
Function
This API is used to obtain the file change metadata 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.
URI
GET https://{hostURL}/v4/repositories/{repository_id}/repository/commits/diff-metadata
| 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. Value range: 1~2147483647 |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| sha | Yes | String | Definition Branch name, tag name, or commit ID. |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| X-Auth-Token | Yes | String | Definition User token. Obtain a token by calling the IAM API for obtaining a user token. The value of X-Subject-Token in the response header is the user token. Constraints Mandatory. Range 1–100,000 characters. Default Value N/A. |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| diffs | Array of DiffDto objects | Definition Difference information. Range N/A. |
| diff_refs | DiffRefsDto object | Definition Difference ref information. Range N/A. |
| added_lines | Integer | Definition Number of added lines. Value range: 0~2147483647 |
| removed_lines | Integer | Definition Number of deleted lines. Value range: 0~2147483647 |
| change_file_count | Integer | Definition Number of modified files. Value range: 0~2147483647 |
| change_line_count | Integer | Definition Number of changed lines. Value range: 0~2147483647 |
| too_large | Boolean | Definition Large file or not. Range |
| Parameter | Type | Description |
|---|---|---|
| old_path | String | Old file |
| new_path | String | New file |
| a_mode | String | Old file type. |
| b_mode | String | New file type |
| file_path | String | File path |
| new_file | Boolean | New or not |
| file_type | String | File type |
| renamed_file | Boolean | Rename or not |
| deleted_file | Boolean | Whether to delete a file |
| diff | String | Comparison result |
| binary | Boolean | Binary or not |
| too_large | Boolean | Whether the file is too large |
| collapsed | Boolean | Collapsed or not |
| line_count | Array of integers | Value range: 1~2147483647 |
| added_lines | Integer | Number of added lines Value range: 1~2147483647 |
| removed_lines | Integer | Number of deleted lines Value range: 1~2147483647 |
| Parameter | Type | Description |
|---|---|---|
| base_sha | String | Definition Base commit hash of the target branch. Range N/A. |
| head_sha | String | Definition Latest commit hash of the source branch. Range N/A. |
| start_sha | String | Definition Commit hash at the start of an MR, which is usually the same as base_sha. Range N/A. |
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/diff-metadata?sha=master Example Responses
Status code: 200
ok
{
"diffs" : [ {
"old_path" : "date2",
"new_path" : "date2",
"a_mode" : "100644",
"b_mode" : "0",
"file_path" : "test",
"new_file" : true,
"file_type" : null,
"renamed_file" : false,
"deleted_file" : false,
"diff" : null,
"binary" : null,
"too_large" : null,
"collapsed" : null,
"line_count" : null,
"added_lines" : 0,
"removed_lines" : 1
} ],
"diff_refs" : null,
"added_lines" : 0,
"removed_lines" : 1,
"change_file_count" : 1,
"change_line_count" : 1,
"too_large" : false
} 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.