Using CURL to imitate a GUI-Frontend Workflow (posting a review draft including the diff)

115 views
Skip to first unread message

Daniel

unread,
Jun 6, 2018, 11:00:43 AM6/6/18
to Review Board Development
Hello dear developing people,

first of all please advice me - if needed - to re-post this question in the community-group. As i am asking about  rather internal-ish things i thought i'd better target the dev-channel. Please excuse my bluntness, i will happily repost the question in the other group if necessary!

I just installed reviewboard and found out that it really is a fine tool to give me and my colleagues an easy and focused POV for doing our reviews! Kudos for the nice work and to everyone doing something to further the cause! You are doing a great work! Thank you! (i'd sprinkle some more !!s but i wanted to keep it casual ;-)

With that said: now on to the real question!

How can i use curl to create a new review request draft which includes a diff? (as if opening http://[REVIEWBOARD-URL/r/new in Browser and selecting a revision)
  • I know the range of revisions i would like to create a "New Review Request" for. 
  • I am able to create that Review Request via the web-frontend easily. 
  • I succeeded in authenticating and using the WEB-API in general
  • I was able to create an empty review request
  • I found out that said review request was totally empty
  • When i created the review request via web frontend, it was filled with input from the commit-message and the accompanying diff
How do i (via curl) recreate this? Could someone point me in the right direction or humbly create an example?

I tried it with the following command which created the empty review request i talked about ... i did not find a API-Endpoint which i could POST to to add a fitting DIFF to the empty review request. 

curl -X POST -d repository=1 -d commit_id=54385:54394  http://[REVIEWBOARD-URL/api/review-requests/ -H "Authorization: token a8513111................"

Thank you in advance!

cheers
Daniel

Barret Rennie

unread,
Sep 18, 2018, 7:11:00 PM9/18/18
to reviewb...@googlegroups.com
Hi Daniel,

We have a tool that simplifies this workflow called RBTools. RBTools is a python command + API library for interacting with Review Board. For example, you can post a review request to RB from your repository by doing `rbt post`, which will post anything in `master..HEAD` (assuming a Git repository).

It also provides a API for interacting with the Review Board webAPI. A script to create a post commit review request might look something like:

```
from rbtools.api.client import RBClient

client = RBClient('http://reviewboard-url/api')

# If you dont provide the API token, it will prompt you for a username + password
api_root = client.get_root(api_token='abc123')

review_requests = api_root.get_review_requests()

review_request = review_requests.create(
    commit_id='abc123',
    create_from_commit_id=True)

print('Posted at: ', review_request.url)
```

As for creating post-commit review requests, you will need to send `-d create_from_commit_id=1` with your request to make Review Board fill everything in. By default, the `commit_id` field is just for storing the commit ID that was uploaded. When combined with `create_from_commit_id`, it will retrieve the change + description from your SCM.

Hope this helps!

Regards,
Barret

--

---
You received this message because you are subscribed to the Google Groups "Review Board Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to reviewboard-d...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel

unread,
Aug 20, 2019, 10:25:16 AM8/20/19
to Review Board Development
Hi Barret,

thank you for your description, it is well appreciated! (even if i am rather lagging behind with my answer)

I must admit, i am rather unexperienced with python and as such i might need to get up to speed first (setting up python to create/run the script, learning more about the language, etc) but nevertheless your description is a good pointer to get to something!

I am wondering: would it maybe be possible to change some loglevel flags, so that the resulting call of

>>> review_request = review_requests.create(
>>>     commit_id='abc123',
>>>     create_from_commit_id=True) 

might get logged somewhere so that i get a glimpse of what is sent to the server? (to recreate it via curl ;-) )

Even more interesting would be the possibility to add more diffs to the request, would that be possible too? 

(btw, in my setting it is a bunch of svn workspaces so i - sadly - do not have a central svn-workspace-root directory ... so i - sadly - cannot create a request with all diffs of all changed files as there are n svn-workspace roots)

ty and cheers
Daniel
Reply all
Reply to author
Forward
0 new messages