GetMergeList: Also allow caching of responses for non-merges
Change-Id: I66527dd14f0ce53015b6548c86eb8634cf3942ac Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
		@@ -77,7 +77,7 @@ public class GetMergeList implements RestReadView<RevisionResource> {
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (commit.getParentCount() < 2) {
 | 
			
		||||
        return Response.<List<CommitInfo>> ok(ImmutableList.<CommitInfo> of());
 | 
			
		||||
        return createResponse(rsrc, ImmutableList.<CommitInfo> of());
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      List<RevCommit> commits =
 | 
			
		||||
@@ -87,12 +87,16 @@ public class GetMergeList implements RestReadView<RevisionResource> {
 | 
			
		||||
      for (RevCommit c : commits) {
 | 
			
		||||
        result.add(changeJson.toCommit(rsrc.getControl(), rw, c, addLinks, true));
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      Response<List<CommitInfo>> r = Response.ok(result);
 | 
			
		||||
      if (rsrc.isCacheable()) {
 | 
			
		||||
        r.caching(CacheControl.PRIVATE(7, TimeUnit.DAYS));
 | 
			
		||||
      }
 | 
			
		||||
      return r;
 | 
			
		||||
      return createResponse(rsrc, result);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private static Response<List<CommitInfo>> createResponse(
 | 
			
		||||
      RevisionResource rsrc, List<CommitInfo> result) {
 | 
			
		||||
    Response<List<CommitInfo>> r = Response.ok(result);
 | 
			
		||||
    if (rsrc.isCacheable()) {
 | 
			
		||||
      r.caching(CacheControl.PRIVATE(7, TimeUnit.DAYS));
 | 
			
		||||
    }
 | 
			
		||||
    return r;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user