Draft Diff List 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_diffs |
URI | /api/review-requests/{review_request_id}/draft/diffs/ |
Token Policy ID | draft_diff |
HTTP Methods | |
Parent Resource | |
Child Resources |
Links¶
Name |
Method |
Resource |
---|---|---|
create | POST |
|
self | GET |
HTTP GET¶
Returns the list of draft diffs on the review request.
Each diff has the target revision and list of per-file diffs associated with it.
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 POST¶
Creates a new diff by parsing an uploaded diff file.
This will implicitly create the new Review Request draft, which can be updated separately and then published.
This accepts a unified diff file, validates it, and stores it along with the draft of a review request. The new diff will have a revision of 0.
A parent diff can be uploaded along with the main diff. A parent diff is a diff based on an existing commit in the repository, which will be applied before the main diff. The parent diff will not be included in the diff viewer. It’s useful when developing a change based on a branch that is not yet committed. In this case, a parent diff of the parent branch would be provided along with the diff of the new commit, and only the new commit will be shown.
It is expected that the client will send the data as part of a
multipart/form-data mimetype. The main diff’s name and
content would be stored in the path
field. If a parent diff is
provided, its name and content would be stored in the
parent_diff_path
field.
An example of this would be:
-- SoMe BoUnDaRy
Content-Disposition: form-data; name=path; filename="foo.diff"
<Unified Diff Content Here>
-- SoMe BoUnDaRy --
Extra data can be stored later lookup. See Storing/Accessing Extra Data for more information.
Request Parameters¶
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. |
parent_diff_pathUploaded file | The optional parent diff to upload. |
pathUploaded file | The main diff to upload. |
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. |
207 - Repository File Not FoundHTTP 400 - Bad Request | The file was not found in the repository. |
219 - Diff EmptyHTTP 400 - Bad Request | The specified diff file is empty. |
220 - Diff Too BigHTTP 400 - Bad Request | The specified diff file is too large. |
Examples¶
application/vnd.reviewboard.org.diffs+json¶
$ curl https://reviews.example.com/api/review-requests/10/draft/diffs/ -H "Accept: application/json"
HTTP 200 OK
Content-Length: 1035
Content-Type: application/vnd.reviewboard.org.diffs+json
ETag: 2b6464a6ff8a77fd1800dc67d136d515a57eb667
Item-Content-Type: application/vnd.reviewboard.org.diff+json
Vary: Accept, Cookie
X-Content-Type-Options: nosniff
{
"diffs": [
{
"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"
}
],
"links": {
"create": {
"href": "https://reviews.example.com/api/review-requests/10/draft/diffs/",
"method": "POST"
},
"self": {
"href": "https://reviews.example.com/api/review-requests/10/draft/diffs/",
"method": "GET"
}
},
"stat": "ok",
"total_results": 1
}