Draft Diff Resource¶
Added in 2.0
Provides information on pending draft diffs for a review request.
This list will only ever contain a maximum of one diff in current versions. This is to preserve compatibility with the public Diff Resource.
POSTing to this resource will create or update a review request draft with the provided diff. This also mirrors the public diff resource.
Details¶
Name | draft_diff |
URI | /api/review-requests/{review_request_id}/draft/diffs/{diff_revision}/ |
Token Policy ID | draft_diff |
HTTP Methods | |
Parent Resource | |
Child Resources |
Fields¶
base_commit_idString | The ID/revision this change is built upon. If using a parent diff, then this is the base for that diff. This may not be provided for all diffs or repository types, depending on how the diff was uploaded. Added in 1.7.13 |
basedirString | The base directory that will prepended to all paths in the diff. This is needed for some types of repositories. The directory must be between the root of the repository and the top directory referenced in the diff paths. Added in 1.7 |
commit_countInteger | The number of commits present in the case of review requests created with commit history. Added in 4.0 |
extra_dataDictionary | Extra data as part of the diff. This can be set by the API or extensions. Added in 2.0 |
idInteger | The numeric ID of the diff. |
nameString | The name of the diff, usually the filename. |
repositoryRepository Resource | The repository that the diff is applied against. |
revisionInteger | The revision of the diff. Starts at 1 for public diffs. Draft diffs may be at 0. |
timestamp | The date and time that the diff was uploaded. |
Links¶
Name |
Method |
Resource |
---|---|---|
draft_commits | GET |
|
draft_files | GET |
|
self | GET |
|
update | PUT |
HTTP GET¶
Returns the information or contents on a particular diff.
The output varies by mimetype.
If application/json or application/xml is used, then the fields for the diff are returned, like with any other resource.
If text/x-patch is used, then the actual diff file itself is returned. This diff should be as it was when uploaded originally, with potentially some extra SCM-specific headers stripped. The contents will contain that of all per-file diffs that make up this diff.
Errors¶
100 - Does Not ExistHTTP 404 - Not Found | Object does not exist |
101 - Permission DeniedHTTP 403 - Forbidden | You don’t have permission for this |
103 - Not Logged InHTTP 401 - Unauthorized | You are not logged in |
112 - OAuth2 Missing Scope ErrorHTTP 403 - Forbidden | Your OAuth2 token lacks the necessary scopes for this request. |
113 - OAuth2 Access Denied ErrorHTTP 403 - Forbidden | OAuth2 token access for this resource is prohibited. |
HTTP PUT¶
Update a diff.
This is used for two purposes:
For updating extra data on a draft diff.
Extra data can be stored later lookup. See Storing/Accessing Extra Data for more information.
For finalization of a draft diff on a review request created with commit history.
Request Parameters¶
cumulative_diffUploaded file | The cumulative diff of the entire commit series this resource represents. |
finalize_commit_seriesBoolean | Whether or not this is a request to finalize the commit series represented by this resource. If this is set to |
parent_diffUploaded file | The parent diff of the cumulative diff of the entire commit series this resource represents. |
validation_infoString | Validation information returned when validating the last commit in the series with the DiffCommit validation resource. |
Errors¶
100 - Does Not ExistHTTP 404 - Not Found | Object does not exist |
101 - Permission DeniedHTTP 403 - Forbidden | You don’t have permission for this |
102 - Invalid AttributeHTTP 400 - Bad Request | Invalid attribute |
103 - Not Logged InHTTP 401 - Unauthorized | You are not logged in |
105 - Invalid Form DataHTTP 400 - Bad Request | One or more fields had errors |
112 - OAuth2 Missing Scope ErrorHTTP 403 - Forbidden | Your OAuth2 token lacks the necessary scopes for this request. |
113 - OAuth2 Access Denied ErrorHTTP 403 - Forbidden | OAuth2 token access for this resource is prohibited. |
Examples¶
text/x-patch¶
$ curl https://reviews.example.com/api/review-requests/10/draft/diffs/3/ -H "Accept: text/x-patch"
HTTP 200 OK
Content-Disposition: inline; filename=bug.patch
Content-Length: 0
Content-Type: text/x-patch
ETag: da39a3ee5e6b4b0d3255bfef95601890afd80709
Last-Modified: Fri, 10 Aug 2018 22:16:56 GMT
Vary: Accept, Cookie
application/vnd.reviewboard.org.diff+json¶
$ curl https://reviews.example.com/api/review-requests/10/draft/diffs/3/ -H "Accept: application/json"
HTTP 200 OK
Content-Length: 794
Content-Type: application/vnd.reviewboard.org.diff+json
ETag: baf8db8656a87c4b4d522d94410b939ba69378aa
Last-Modified: Fri, 10 Aug 2018 22:16:56 GMT
Vary: Accept, Cookie
X-Content-Type-Options: nosniff
{
"diff": {
"base_commit_id": "e76c016e09c415d7afc4c004a8a290b3c51bff59",
"basedir": "",
"commit_count": 1,
"extra_data": {},
"id": 15,
"links": {
"draft_commits": {
"href": "https://reviews.example.com/api/review-requests/10/draft/diffs/3/draft-commits/",
"method": "GET"
},
"draft_files": {
"href": "https://reviews.example.com/api/review-requests/10/draft/diffs/3/files/",
"method": "GET"
},
"repository": {
"href": "https://reviews.example.com/api/repositories/3/",
"method": "GET",
"title": "Git Repo"
},
"self": {
"href": "https://reviews.example.com/api/review-requests/10/draft/diffs/3/",
"method": "GET"
},
"update": {
"href": "https://reviews.example.com/api/review-requests/10/draft/diffs/3/",
"method": "PUT"
}
},
"name": "diff",
"revision": 3,
"timestamp": "2018-08-10T22:16:56Z"
},
"stat": "ok"
}