rb-gateway post commit APIs

Review Request #6972 — Created Feb. 22, 2015 and submitted — Latest diff uploaded

Information

rb-gateway
master
db50a09...

Reviewers

This is to add support for the post commit UI that Review Board currently has. In order for Review Board Gateway hosted repositories to support this UI, rb-gateway must provide APIs for getting branches, getting commits, and getting an individual commit.

The URL for get branches is located at /branches and it requires a repository as the parameter. The returned JSON looks as follows:
[
{
"name": master,
"id": "1b6f00c0fe975dd12251431ed2ea561e0acc6d44"
}
]

The URL for get commits is located at /commits and it requries a repository as the parameter, as well as the branch id. An optional start commit parameter can be provided to retrieve the commits beginning at the start commit. The returned JSON looks as follows:
[
{
"author": "John Doe",
"id": "1b6f00c0fe975dd12251431ed2ea561e0acc6d44",
"date": "2015-06-27T05:51:39-07:00",
"message": "Add README.md",
"parent_id": "bfdde95432b3af879af969bd2377dc3e55ee46e6"
}
]

The URL for get commit is located at /commit and it requries a repository as the parameter, as well as the commit id. The returned JSON looks as follows:
{
"author": "John Doe",
"id": "1b6f00c0fe975dd12251431ed2ea561e0acc6d44",
"date": "2015-06-27T05:51:39-07:00",
"message": "Add README.md",
"parent_id": "bfdde95432b3af879af969bd2377dc3e55ee46e6",
"diff": "diff --git a/test b/test
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..044f599c9a720fe1a7d02e694a8dab492cbda8f0 100644
--- a/test
+++ b/test
@@ -1 +1,3 @@
test
+
+test"
}

The following are URLs ran through my browser and self rb-gateway, git repository test environment. I've listed the JSON that is returned.

http://localhost:8002/branches?repo=testrepo
[{"name":"im_a_branch","id":"83904e6acb60e7ec0dcaae6c09a579ab44d0cf38"},{"name":"master","id":"bfdde95432b3af879af969bd2377dc3e55ee46e6"}]

http://localhost:8002/commits?repo=testrepo&branch=bfdde95432b3af879af969bd2377dc3e55ee46e6
[{"author":"Jessica Yuen","id":"bfdde95432b3af879af969bd2377dc3e55ee46e6","date":"2015-02-13 22:34:01 -0700 -0700","message":"Modified test\n","parent_id":"304c53c163aedfd0c0e0933776f09c24b87f5944"}, ... ]

http://localhost:8002/commits?repo=testrepo&branch=bfdde95432b3af879af969bd2377dc3e55ee46e6&start=fa1330719893098ae397356e8125c2aa45b49221
[{"author":"Jessica Yuen","id":"fa1330719893098ae397356e8125c2aa45b49221","date":"2015-02-12 16:01:48 -0700 -0700","message":"Removing all files in preparation for demo\n","parent_id":"9a3e0527e8decfabc12bbd9b75d0a683ef8320e2"}]

For comparison, git log returns the following, notice that the start commit is omitted in the above request:
commit bfdde95432b3af879af969bd2377dc3e55ee46e6
Author: Jessica Yuen jyuen@ualberta.ca
Date: Fri Feb 13 22:34:01 2015 -0700

Modified test

commit 304c53c163aedfd0c0e0933776f09c24b87f5944
Author: Jessica Yuen jyuen@ualberta.ca
Date: Fri Feb 13 22:32:42 2015 -0700

Added .reviewboardrc

commit fa1330719893098ae397356e8125c2aa45b49221
Author: Jessica Yuen jyuen@ualberta.ca
Date: Thu Feb 12 16:01:48 2015 -0700

Removing all files in preparation for demo

http://localhost:8002/commit?repo=testrepo&commit=304c53c163aedfd0c0e0933776f09c24b87f5944
{"author":"Jessica Yuen","id":"304c53c163aedfd0c0e0933776f09c24b87f5944","date":"2015-02-13 22:32:42 -0700 -0700","message":"Added .reviewboardrc\n","parent_id":"fa1330719893098ae397356e8125c2aa45b49221","diff":"diff --git a/.reviewboardrc b/.reviewboardrc\nindex e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..044f599c9a720fe1a7d02e694a8dab492cbda8f0 100644\n--- a/.reviewboardrc\n+++ b/.reviewboardrc\n@@ -0,0 +1,2 @@\n+REVIEWBOARD_URL = 'http://localhost:8080/'\n+REPOSITORY = 'test-repo1'\n"}

    Loading...