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 | Review Request Draft Resource |
Child Resources | |
Anonymous Access | No |
Links¶
Name | Method | Resource |
---|---|---|
create | POST | Draft Diff List Resource |
self | GET | Draft Diff List Resource |
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¶
pathUploaded File | Required The main diff to upload. |
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. |
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 http://reviews.example.com/api/review-requests/8/draft/diffs/ -H "Accept: application/json"
Vary: Accept, Cookie
Item-Content-Type: application/vnd.reviewboard.org.diff+json
Content-Type: application/vnd.reviewboard.org.diffs+json
X-Content-Type-Options: nosniff
{
"diffs": [
{
"base_commit_id": null,
"basedir": "",
"extra_data": {},
"id": 10,
"links": {
"draft_files": {
"href": "http://reviews.example.com/api/review-requests/8/draft/diffs/2/files/",
"method": "GET"
},
"repository": {
"href": "http://reviews.example.com/api/repositories/1/",
"method": "GET",
"title": "Review Board SVN"
},
"self": {
"href": "http://reviews.example.com/api/review-requests/8/draft/diffs/2/",
"method": "GET"
},
"update": {
"href": "http://reviews.example.com/api/review-requests/8/draft/diffs/2/",
"method": "PUT"
}
},
"name": "diff",
"revision": 2,
"timestamp": "2009-02-25T02:03:05Z"
}
],
"links": {
"create": {
"href": "http://reviews.example.com/api/review-requests/8/draft/diffs/",
"method": "POST"
},
"self": {
"href": "http://reviews.example.com/api/review-requests/8/draft/diffs/",
"method": "GET"
}
},
"stat": "ok",
"total_results": 1
}