Set commit ID in result of the /changes/*/revisions/*/commit endpoint

Setting the commit ID is important when a revision ID other than a
commit ID is used, e.g. a legacy numeric patch set number, or the
literal 'current'.

Also explain in the documentation in which case the commit ID is not
set.

Change-Id: Iadcff2c7cbe98be8c826a0ea6d0aa8bd8ff2a6be
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2015-07-15 18:27:55 +02:00
parent 253c60a4a7
commit c823740d87
2 changed files with 6 additions and 1 deletions

View File

@@ -2235,6 +2235,7 @@ describes the revision.
)]}'
{
"commit": "674ac754f91e64a0efb8087e59a176484bd534d1",
"parents": [
{
"commit": "1eee2c9d8f352483781e772f35dc586a69ff5646",
@@ -3947,7 +3948,10 @@ The `CommitInfo` entity contains information about a commit.
[options="header",cols="1,^1,5"]
|===========================
|Field Name ||Description
|`commit` ||The commit ID.
|`commit` |Optional|
The commit ID. Not set if included in a link:#revision-info[
RevisionInfo] entity that is contained in a map which has the commit ID
as key.
|`parents` ||
The parent commits of this commit as a list of
link:#commit-info[CommitInfo] entities. In each parent

View File

@@ -54,6 +54,7 @@ public class GetCommit implements RestReadView<RevisionResource> {
rw.parseBody(commit);
CommitInfo info = json.create(ChangeJson.NO_OPTIONS)
.toCommit(rsrc.getControl(), rw, commit, addLinks);
info.commit = commit.name();
Response<CommitInfo> r = Response.ok(info);
if (rsrc.isCacheable()) {
r.caching(CacheControl.PRIVATE(7, TimeUnit.DAYS));