rb-gateway post commit APIs
Review Request #6972 — Created Feb. 22, 2015 and submitted
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 -0700Modified test
commit 304c53c163aedfd0c0e0933776f09c24b87f5944
Author: Jessica Yuen jyuen@ualberta.ca
Date: Fri Feb 13 22:32:42 2015 -0700Added .reviewboardrc
commit fa1330719893098ae397356e8125c2aa45b49221
Author: Jessica Yuen jyuen@ualberta.ca
Date: Thu Feb 12 16:01:48 2015 -0700Removing 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"}
Description | From | Last Updated |
---|---|---|
For get_commits, I don't think we'd want to include the diff, since it could end up being a huge amount … |
david | |
This isn't quite right. Because of the way the git frontend works, we want to use start if it's available, … |
david | |
We need to make sure that this includes full indexes. |
david | |
This should probably be in an else clause, right? |
david | |
This should probably be in an else clause, right? |
david | |
It would be nice to have better error codes here. If the commit isn't found, then this should return 404. … |
david | |
This should probably be in an else clause, right? |
david | |
Can we reformat this to put one item per line? gitCommit := GitCommit{ commit.Author().Name, commit.Id().String(), commit.Author().When.String(), commit.Message(), parent } |
david | |
Can we reformat this to put one item per line? gitCommit := GitCommit{ commit.Author().Name, commit.Id().String(), commit.Author().When.String(), commit.Message(), parent, diff } |
david | |
sorry again by why 10 branches? |
brennie | |
Is there any particular reason the maximum size is 20? Should this be a constant somewhere? |
brennie | |
Again, this probably should be a constant. |
brennie |
Change Summary:
Added API for getting all commits for a branch, I still need to support the option to specify a starting commit.
Testing Done: |
|
|||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Commit: |
|
|||||||||||||||
Diff: |
Revision 2 (+219 -6) |
-
Tool: PEP8 Style Checker Ignored Files: repository.go git_repository.go routes.go Tool: Pyflakes Ignored Files: repository.go git_repository.go routes.go
Change Summary:
Added API for getting change, getting branches with a start commit. Think this is it for post commit APIs.
Summary: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Testing Done: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Commit: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Diff: |
Revision 3 (+376 -5) |
-
Tool: PEP8 Style Checker Ignored Files: repository.go git_repository.go routes.go Tool: Pyflakes Ignored Files: repository.go git_repository.go routes.go
-
-
git_repository.go (Diff revision 3) For get_commits, I don't think we'd want to include the diff, since it could end up being a huge amount of data to transmit every time /r/new/ is opened up.
-
git_repository.go (Diff revision 3) This isn't quite right. Because of the way the git frontend works, we want to use
start
if it's available, andbranch
if it's not. This should basically be the result ofgit log start
. Of note is thatstart
is the latest commit to log, and we go back in history from there. Subsequent calls will use theI think what we want to do is something like this:
if len(start) != 0 { revWalk.PushHead(start) } else { revWalk.PushHead(branch) }
We'd then list out one "page" of commits (probably 30?) and return that.
-
Change Summary:
Fixing some issues, still need to address one but submitting for weekly status report.
Description: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Testing Done: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Commit: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Diff: |
Revision 4 (+367 -5) |
-
Tool: PEP8 Style Checker Ignored Files: repository.go git_repository.go routes.go Tool: Pyflakes Ignored Files: repository.go git_repository.go routes.go
Change Summary:
Addressing remaining issues above.
Description: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Testing Done: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Commit: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Diff: |
Revision 5 (+381 -5) |
-
Tool: PEP8 Style Checker Ignored Files: repository.go git_repository.go routes.go Tool: Pyflakes Ignored Files: repository.go git_repository.go routes.go
-
-
-
-
routes.go (Diff revision 5) It would be nice to have better error codes here. If the commit isn't found, then this should return 404. If it was but there was some other error, then
http.StatusInternalServerError
is probably more appropriate thanStatusBadRequest
. -
Change Summary:
Addressing issues and renamed getChange to getCommit.
Description: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Testing Done: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Commit: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Diff: |
Revision 6 (+391 -5) |
-
Tool: PEP8 Style Checker Ignored Files: repository.go git_repository.go routes.go Tool: Pyflakes Ignored Files: repository.go git_repository.go routes.go
-
-
git_repository.go (Diff revision 6) Can we reformat this to put one item per line?
gitCommit := GitCommit{ commit.Author().Name, commit.Id().String(), commit.Author().When.String(), commit.Message(), parent }
-
git_repository.go (Diff revision 6) Can we reformat this to put one item per line?
gitCommit := GitCommit{ commit.Author().Name, commit.Id().String(), commit.Author().When.String(), commit.Message(), parent, diff }
Change Summary:
Adding support for getting commits by branch name (since RB uses branch name instead of branch sha for look up) + fixing David's suggestion.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 7 (+408 -5) |
-
Tool: PEP8 Style Checker Ignored Files: repository.go git_repository.go routes.go Tool: Pyflakes Ignored Files: repository.go git_repository.go routes.go
-
-
git_repository.go (Diff revision 7) Is there any particular reason the maximum size is 20? Should this be a constant somewhere?
-
Change Summary:
Constants for page size, initial allocation, patch index length
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 8 (+414 -5) |