Obtaining Commit Differences
Function
This API is used to obtain commit differences.
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
| 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. |
| ignore_whitespace_change | No | Boolean | Definition Whether to ignore the change of blank quantity. Range Default value: false |
| not_statistic | No | Boolean | Definition Whether to return the statistics quantity. Range Default value: false |
| offset | No | Integer | Definition Offset, which starts from 0. Value range: 0~2147483647 Default value: 0 |
| limit | No | Integer | Definition Number of returned records. Value range: 1~100 Default value: 20 |
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 DiffNoLineDto 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. Range N/A. |
| removed_lines | Integer | Definition Number of deleted lines. Range N/A. |
| change_file_count | Integer | Definition Number of changed files. Range N/A. |
| change_line_count | Integer | Definition Number of changed lines. Range N/A. |
| 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 |
| 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
None
Example Responses
Status code: 200
ok
{
"added_lines" : 0,
"removed_lines" : 0,
"diffs" : null,
"change_file_count" : 0,
"change_line_count" : 0,
"too_large" : false,
"diff_refs" : {
"base_sha" : "360fc59f6ed8e90b8fa52dd4d31e65d966dc763d",
"head_sha" : "d315e5f6dc66cdc7377dc65b14a835f153b6406c",
"start_sha" : "360fc59f6ed8e90b8fa52dd4d31e65d966dc763d"
}
} 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.