| Dave Borowitz | d0b7e18 | 2013-01-11 15:55:09 -0800 | [diff] [blame] | 1 | // Copyright 2012 Google Inc. All Rights Reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package com.google.gitiles; |
| 16 | |
| Dave Borowitz | 1d94e65 | 2014-07-30 12:45:09 -0700 | [diff] [blame] | 17 | import static com.google.gitiles.TestGitilesUrls.URLS; |
| Dave Borowitz | d40bdf1 | 2014-04-19 19:33:56 -0700 | [diff] [blame] | 18 | import static org.junit.Assert.assertEquals; |
| Dave Borowitz | 32ec5b9 | 2014-07-30 07:43:28 -0700 | [diff] [blame] | 19 | import static org.junit.Assert.assertNull; |
| Dave Borowitz | d40bdf1 | 2014-04-19 19:33:56 -0700 | [diff] [blame] | 20 | import static org.junit.Assert.assertTrue; |
| Dave Borowitz | d0b7e18 | 2013-01-11 15:55:09 -0800 | [diff] [blame] | 21 | |
| Dave Borowitz | 32ec5b9 | 2014-07-30 07:43:28 -0700 | [diff] [blame] | 22 | import com.google.common.collect.ImmutableList; |
| Dave Borowitz | 1d94e65 | 2014-07-30 12:45:09 -0700 | [diff] [blame] | 23 | import com.google.common.collect.ImmutableMap; |
| Dave Borowitz | 32ec5b9 | 2014-07-30 07:43:28 -0700 | [diff] [blame] | 24 | import com.google.common.net.HttpHeaders; |
| 25 | import com.google.gitiles.RefServlet.RefJsonData; |
| 26 | import com.google.gson.Gson; |
| 27 | import com.google.gson.reflect.TypeToken; |
| 28 | |
| Shawn Pearce | b43b2d5 | 2013-03-18 10:55:15 -0700 | [diff] [blame] | 29 | import org.eclipse.jgit.internal.storage.dfs.DfsRepository; |
| 30 | import org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription; |
| 31 | import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository; |
| Dave Borowitz | d0b7e18 | 2013-01-11 15:55:09 -0800 | [diff] [blame] | 32 | import org.eclipse.jgit.junit.TestRepository; |
| 33 | import org.eclipse.jgit.lib.ObjectId; |
| 34 | import org.eclipse.jgit.lib.Repository; |
| 35 | import org.eclipse.jgit.revwalk.RevCommit; |
| 36 | import org.eclipse.jgit.revwalk.RevTag; |
| Dave Borowitz | 1d94e65 | 2014-07-30 12:45:09 -0700 | [diff] [blame] | 37 | import org.eclipse.jgit.revwalk.RevWalk; |
| Dave Borowitz | d40bdf1 | 2014-04-19 19:33:56 -0700 | [diff] [blame] | 38 | import org.junit.Before; |
| 39 | import org.junit.Test; |
| 40 | |
| 41 | import java.io.IOException; |
| Dave Borowitz | 32ec5b9 | 2014-07-30 07:43:28 -0700 | [diff] [blame] | 42 | import java.util.List; |
| 43 | import java.util.Map; |
| Dave Borowitz | d0b7e18 | 2013-01-11 15:55:09 -0800 | [diff] [blame] | 44 | |
| Dave Borowitz | 1d94e65 | 2014-07-30 12:45:09 -0700 | [diff] [blame] | 45 | import javax.servlet.http.HttpServletRequest; |
| 46 | |
| Dave Borowitz | d0b7e18 | 2013-01-11 15:55:09 -0800 | [diff] [blame] | 47 | /** Tests for {@link Linkifier}. */ |
| Dave Borowitz | d40bdf1 | 2014-04-19 19:33:56 -0700 | [diff] [blame] | 48 | public class RefServletTest { |
| Dave Borowitz | 33d4fda | 2013-10-22 16:40:20 -0700 | [diff] [blame] | 49 | private TestRepository<DfsRepository> repo; |
| Dave Borowitz | d0b7e18 | 2013-01-11 15:55:09 -0800 | [diff] [blame] | 50 | private GitilesServlet servlet; |
| 51 | |
| Dave Borowitz | d40bdf1 | 2014-04-19 19:33:56 -0700 | [diff] [blame] | 52 | @Before |
| 53 | public void setUp() throws Exception { |
| Dave Borowitz | d0b7e18 | 2013-01-11 15:55:09 -0800 | [diff] [blame] | 54 | DfsRepository r = new InMemoryRepository(new DfsRepositoryDescription("test")); |
| 55 | repo = new TestRepository<DfsRepository>(r); |
| Dave Borowitz | 1d94e65 | 2014-07-30 12:45:09 -0700 | [diff] [blame] | 56 | servlet = TestGitilesServlet.create(repo); |
| 57 | } |
| Dave Borowitz | d0b7e18 | 2013-01-11 15:55:09 -0800 | [diff] [blame] | 58 | |
| Dave Borowitz | 1d94e65 | 2014-07-30 12:45:09 -0700 | [diff] [blame] | 59 | private void setUpSimpleRefs() throws Exception { |
| Dave Borowitz | d0b7e18 | 2013-01-11 15:55:09 -0800 | [diff] [blame] | 60 | RevCommit commit = repo.branch("refs/heads/master").commit().create(); |
| 61 | repo.update("refs/heads/branch", commit); |
| 62 | repo.update("refs/tags/ctag", commit); |
| 63 | RevTag tag = repo.tag("atag", commit); |
| 64 | repo.update("refs/tags/atag", tag); |
| Dave Borowitz | 1d94e65 | 2014-07-30 12:45:09 -0700 | [diff] [blame] | 65 | repo.getRepository().updateRef("HEAD").link("refs/heads/master"); |
| Dave Borowitz | d0b7e18 | 2013-01-11 15:55:09 -0800 | [diff] [blame] | 66 | } |
| 67 | |
| Dave Borowitz | d40bdf1 | 2014-04-19 19:33:56 -0700 | [diff] [blame] | 68 | @Test |
| 69 | public void evilRefName() throws Exception { |
| Dave Borowitz | 1d94e65 | 2014-07-30 12:45:09 -0700 | [diff] [blame] | 70 | setUpSimpleRefs(); |
| Dave Borowitz | d0b7e18 | 2013-01-11 15:55:09 -0800 | [diff] [blame] | 71 | String evilRefName = "refs/evil/<script>window.close();</script>/&foo"; |
| 72 | assertTrue(Repository.isValidRefName(evilRefName)); |
| 73 | repo.branch(evilRefName).commit().create(); |
| 74 | |
| 75 | FakeHttpServletRequest req = FakeHttpServletRequest.newRequest(); |
| 76 | req.setPathInfo("/test/+refs/evil"); |
| 77 | req.setQueryString("format=TEXT"); |
| 78 | FakeHttpServletResponse res = new FakeHttpServletResponse(); |
| 79 | servlet.service(req, res); |
| 80 | |
| 81 | assertEquals( |
| 82 | id(evilRefName) + " refs/evil/<script>window.close();</script>/&foo\n", |
| 83 | res.getActualBodyString()); |
| 84 | } |
| 85 | |
| Dave Borowitz | d40bdf1 | 2014-04-19 19:33:56 -0700 | [diff] [blame] | 86 | @Test |
| 87 | public void getRefsTextAll() throws Exception { |
| Dave Borowitz | 1d94e65 | 2014-07-30 12:45:09 -0700 | [diff] [blame] | 88 | setUpSimpleRefs(); |
| Dave Borowitz | d0b7e18 | 2013-01-11 15:55:09 -0800 | [diff] [blame] | 89 | FakeHttpServletRequest req = FakeHttpServletRequest.newRequest(); |
| 90 | req.setPathInfo("/test/+refs"); |
| 91 | req.setQueryString("format=TEXT"); |
| 92 | FakeHttpServletResponse res = new FakeHttpServletResponse(); |
| 93 | servlet.service(req, res); |
| 94 | |
| 95 | assertEquals(200, res.getStatus()); |
| 96 | assertEquals( |
| 97 | id("HEAD") + " HEAD\n" |
| 98 | + id("refs/heads/branch") + " refs/heads/branch\n" |
| 99 | + id("refs/heads/master") + " refs/heads/master\n" |
| 100 | + id("refs/tags/atag") + " refs/tags/atag\n" |
| 101 | + peeled("refs/tags/atag") + " refs/tags/atag^{}\n" |
| 102 | + id("refs/tags/ctag") + " refs/tags/ctag\n", |
| 103 | res.getActualBodyString()); |
| 104 | } |
| 105 | |
| Dave Borowitz | d40bdf1 | 2014-04-19 19:33:56 -0700 | [diff] [blame] | 106 | @Test |
| 107 | public void getRefsTextAllTrailingSlash() throws Exception { |
| Dave Borowitz | 1d94e65 | 2014-07-30 12:45:09 -0700 | [diff] [blame] | 108 | setUpSimpleRefs(); |
| Dave Borowitz | d0b7e18 | 2013-01-11 15:55:09 -0800 | [diff] [blame] | 109 | FakeHttpServletRequest req = FakeHttpServletRequest.newRequest(); |
| 110 | req.setPathInfo("/test/+refs"); |
| 111 | req.setQueryString("format=TEXT"); |
| 112 | FakeHttpServletResponse res = new FakeHttpServletResponse(); |
| 113 | servlet.service(req, res); |
| 114 | |
| 115 | assertEquals(200, res.getStatus()); |
| 116 | assertEquals( |
| 117 | id("HEAD") + " HEAD\n" |
| 118 | + id("refs/heads/branch") + " refs/heads/branch\n" |
| 119 | + id("refs/heads/master") + " refs/heads/master\n" |
| 120 | + id("refs/tags/atag") + " refs/tags/atag\n" |
| 121 | + peeled("refs/tags/atag") + " refs/tags/atag^{}\n" |
| 122 | + id("refs/tags/ctag") + " refs/tags/ctag\n", |
| 123 | res.getActualBodyString()); |
| 124 | } |
| 125 | |
| Dave Borowitz | d40bdf1 | 2014-04-19 19:33:56 -0700 | [diff] [blame] | 126 | @Test |
| 127 | public void getRefsHeadsText() throws Exception { |
| Dave Borowitz | 1d94e65 | 2014-07-30 12:45:09 -0700 | [diff] [blame] | 128 | setUpSimpleRefs(); |
| Dave Borowitz | d0b7e18 | 2013-01-11 15:55:09 -0800 | [diff] [blame] | 129 | FakeHttpServletRequest req = FakeHttpServletRequest.newRequest(); |
| 130 | req.setPathInfo("/test/+refs/heads"); |
| 131 | req.setQueryString("format=TEXT"); |
| 132 | FakeHttpServletResponse res = new FakeHttpServletResponse(); |
| 133 | servlet.service(req, res); |
| 134 | |
| 135 | assertEquals(200, res.getStatus()); |
| 136 | assertEquals( |
| 137 | id("refs/heads/branch") + " refs/heads/branch\n" |
| 138 | + id("refs/heads/master") + " refs/heads/master\n", |
| 139 | res.getActualBodyString()); |
| 140 | } |
| 141 | |
| Dave Borowitz | d40bdf1 | 2014-04-19 19:33:56 -0700 | [diff] [blame] | 142 | @Test |
| 143 | public void getRefsHeadsTextTrailingSlash() throws Exception { |
| Dave Borowitz | 1d94e65 | 2014-07-30 12:45:09 -0700 | [diff] [blame] | 144 | setUpSimpleRefs(); |
| Dave Borowitz | d0b7e18 | 2013-01-11 15:55:09 -0800 | [diff] [blame] | 145 | FakeHttpServletRequest req = FakeHttpServletRequest.newRequest(); |
| 146 | req.setPathInfo("/test/+refs/heads/"); |
| 147 | req.setQueryString("format=TEXT"); |
| 148 | FakeHttpServletResponse res = new FakeHttpServletResponse(); |
| 149 | servlet.service(req, res); |
| 150 | |
| 151 | assertEquals(200, res.getStatus()); |
| 152 | assertEquals( |
| 153 | id("refs/heads/branch") + " refs/heads/branch\n" |
| 154 | + id("refs/heads/master") + " refs/heads/master\n", |
| 155 | res.getActualBodyString()); |
| 156 | } |
| 157 | |
| Dave Borowitz | d40bdf1 | 2014-04-19 19:33:56 -0700 | [diff] [blame] | 158 | @Test |
| 159 | public void noHeadText() throws Exception { |
| Dave Borowitz | 1d94e65 | 2014-07-30 12:45:09 -0700 | [diff] [blame] | 160 | setUpSimpleRefs(); |
| Dave Borowitz | d0b7e18 | 2013-01-11 15:55:09 -0800 | [diff] [blame] | 161 | FakeHttpServletRequest req = FakeHttpServletRequest.newRequest(); |
| 162 | req.setPathInfo("/test/+refs/HEAD"); |
| 163 | req.setQueryString("format=TEXT"); |
| 164 | FakeHttpServletResponse res = new FakeHttpServletResponse(); |
| 165 | servlet.service(req, res); |
| 166 | |
| 167 | assertEquals(200, res.getStatus()); |
| 168 | // /+refs/foo means refs/foo(/*), so this is empty. |
| 169 | assertEquals("", res.getActualBodyString()); |
| 170 | } |
| 171 | |
| Dave Borowitz | d40bdf1 | 2014-04-19 19:33:56 -0700 | [diff] [blame] | 172 | @Test |
| 173 | public void singleHeadText() throws Exception { |
| Dave Borowitz | 1d94e65 | 2014-07-30 12:45:09 -0700 | [diff] [blame] | 174 | setUpSimpleRefs(); |
| Dave Borowitz | d0b7e18 | 2013-01-11 15:55:09 -0800 | [diff] [blame] | 175 | FakeHttpServletRequest req = FakeHttpServletRequest.newRequest(); |
| 176 | req.setPathInfo("/test/+refs/heads/master"); |
| 177 | req.setQueryString("format=TEXT"); |
| 178 | FakeHttpServletResponse res = new FakeHttpServletResponse(); |
| 179 | servlet.service(req, res); |
| 180 | |
| 181 | assertEquals(200, res.getStatus()); |
| 182 | assertEquals( |
| 183 | id("refs/heads/master") + " refs/heads/master\n", |
| 184 | res.getActualBodyString()); |
| 185 | } |
| 186 | |
| Dave Borowitz | d40bdf1 | 2014-04-19 19:33:56 -0700 | [diff] [blame] | 187 | @Test |
| 188 | public void singlePeeledTagText() throws Exception { |
| Dave Borowitz | 1d94e65 | 2014-07-30 12:45:09 -0700 | [diff] [blame] | 189 | setUpSimpleRefs(); |
| Dave Borowitz | d0b7e18 | 2013-01-11 15:55:09 -0800 | [diff] [blame] | 190 | FakeHttpServletRequest req = FakeHttpServletRequest.newRequest(); |
| 191 | req.setPathInfo("/test/+refs/tags/atag"); |
| 192 | req.setQueryString("format=TEXT"); |
| 193 | FakeHttpServletResponse res = new FakeHttpServletResponse(); |
| 194 | servlet.service(req, res); |
| 195 | |
| 196 | assertEquals(200, res.getStatus()); |
| 197 | assertEquals( |
| 198 | id("refs/tags/atag") + " refs/tags/atag\n" |
| 199 | + peeled("refs/tags/atag") + " refs/tags/atag^{}\n", |
| 200 | res.getActualBodyString()); |
| 201 | } |
| Dave Borowitz | 32ec5b9 | 2014-07-30 07:43:28 -0700 | [diff] [blame] | 202 | |
| 203 | @Test |
| 204 | public void getRefsJsonAll() throws Exception { |
| Dave Borowitz | 1d94e65 | 2014-07-30 12:45:09 -0700 | [diff] [blame] | 205 | setUpSimpleRefs(); |
| Dave Borowitz | 32ec5b9 | 2014-07-30 07:43:28 -0700 | [diff] [blame] | 206 | Map<String, RefJsonData> result = buildJson("/test/+refs"); |
| 207 | List<String> keys = ImmutableList.copyOf(result.keySet()); |
| 208 | assertEquals(ImmutableList.of( |
| 209 | "HEAD", |
| 210 | "refs/heads/branch", |
| 211 | "refs/heads/master", |
| 212 | "refs/tags/atag", |
| 213 | "refs/tags/ctag"), |
| 214 | keys); |
| 215 | |
| 216 | RefJsonData head = result.get(keys.get(0)); |
| 217 | assertEquals(id("HEAD"), head.value); |
| 218 | assertNull(head.peeled); |
| 219 | assertEquals("refs/heads/master", head.target); |
| 220 | |
| 221 | RefJsonData branch = result.get(keys.get(1)); |
| 222 | assertEquals(id("refs/heads/branch"), branch.value); |
| 223 | assertNull(branch.peeled); |
| 224 | assertNull(branch.target); |
| 225 | |
| 226 | RefJsonData master = result.get(keys.get(2)); |
| 227 | assertEquals(id("refs/heads/master"), master.value); |
| 228 | assertNull(master.peeled); |
| 229 | assertNull(master.target); |
| 230 | |
| 231 | RefJsonData atag = result.get(keys.get(3)); |
| 232 | assertEquals(id("refs/tags/atag"), atag.value); |
| 233 | assertEquals(peeled("refs/tags/atag"), atag.peeled); |
| 234 | assertNull(atag.target); |
| 235 | |
| 236 | RefJsonData ctag = result.get(keys.get(4)); |
| 237 | assertEquals(id("refs/tags/ctag"), ctag.value); |
| 238 | assertNull(ctag.peeled); |
| 239 | assertNull(ctag.target); |
| 240 | } |
| 241 | |
| 242 | @Test |
| 243 | public void getRefsHeadsJson() throws Exception { |
| Dave Borowitz | 1d94e65 | 2014-07-30 12:45:09 -0700 | [diff] [blame] | 244 | setUpSimpleRefs(); |
| Dave Borowitz | 32ec5b9 | 2014-07-30 07:43:28 -0700 | [diff] [blame] | 245 | Map<String, RefJsonData> result = buildJson("/test/+refs/heads"); |
| 246 | List<String> keys = ImmutableList.copyOf(result.keySet()); |
| 247 | assertEquals(ImmutableList.of( |
| 248 | "branch", |
| 249 | "master"), |
| 250 | keys); |
| 251 | |
| 252 | RefJsonData branch = result.get(keys.get(0)); |
| 253 | assertEquals(id("refs/heads/branch"), branch.value); |
| 254 | assertNull(branch.peeled); |
| 255 | assertNull(branch.target); |
| 256 | |
| 257 | RefJsonData master = result.get(keys.get(1)); |
| 258 | assertEquals(id("refs/heads/master"), master.value); |
| 259 | assertNull(master.peeled); |
| 260 | assertNull(master.target); |
| 261 | } |
| 262 | |
| 263 | private Map<String, RefJsonData> buildJson(String path) throws Exception { |
| 264 | FakeHttpServletRequest req = FakeHttpServletRequest.newRequest(); |
| 265 | req.setPathInfo(path); |
| 266 | req.setQueryString("format=JSON"); |
| 267 | FakeHttpServletResponse res = new FakeHttpServletResponse(); |
| 268 | servlet.service(req, res); |
| 269 | |
| 270 | assertEquals(200, res.getStatus()); |
| 271 | assertEquals("application/json", res.getHeader(HttpHeaders.CONTENT_TYPE)); |
| 272 | String body = res.getActualBodyString(); |
| 273 | String magic = ")]}'\n"; |
| 274 | assertEquals(magic, body.substring(0, magic.length())); |
| 275 | return new Gson().fromJson(body.substring(magic.length()), new TypeToken<Map<String, RefJsonData>>() {}.getType()); |
| 276 | } |
| Dave Borowitz | 1d94e65 | 2014-07-30 12:45:09 -0700 | [diff] [blame] | 277 | |
| 278 | @Test |
| 279 | public void emptySoy() throws Exception { |
| 280 | assertEquals(ImmutableList.of(), buildBranchesSoyData()); |
| 281 | assertEquals(ImmutableList.of(), buildTagsSoyData()); |
| 282 | } |
| 283 | |
| 284 | @Test |
| 285 | public void branchesAndTagsSoy() throws Exception { |
| 286 | repo.branch("refs/heads/foo").commit().create(); |
| 287 | repo.branch("refs/heads/bar").commit().create(); |
| 288 | repo.branch("refs/tags/baz").commit().create(); |
| 289 | repo.branch("refs/nope/quux").commit().create(); |
| 290 | |
| 291 | assertEquals( |
| 292 | ImmutableList.of( |
| 293 | ref("/b/test/+/bar", "bar"), |
| 294 | ref("/b/test/+/foo", "foo")), |
| 295 | buildBranchesSoyData()); |
| 296 | assertEquals( |
| 297 | ImmutableList.of( |
| 298 | ref("/b/test/+/baz", "baz")), |
| 299 | buildTagsSoyData()); |
| 300 | } |
| 301 | |
| 302 | @Test |
| 303 | public void ambiguousBranchSoy() throws Exception { |
| 304 | repo.branch("refs/heads/foo").commit().create(); |
| 305 | repo.branch("refs/heads/bar").commit().create(); |
| 306 | repo.branch("refs/tags/foo").commit().create(); |
| 307 | |
| 308 | assertEquals( |
| 309 | ImmutableList.of( |
| 310 | ref("/b/test/+/bar", "bar"), |
| 311 | ref("/b/test/+/refs/heads/foo", "foo")), |
| 312 | buildBranchesSoyData()); |
| 313 | assertEquals( |
| 314 | ImmutableList.of( |
| 315 | // refs/tags/ is searched before refs/heads/, so this does not |
| 316 | // appear ambiguous. |
| 317 | ref("/b/test/+/foo", "foo")), |
| 318 | buildTagsSoyData()); |
| 319 | } |
| 320 | |
| 321 | @Test |
| 322 | public void ambiguousRelativeToNonBranchOrTagSoy() throws Exception { |
| 323 | repo.branch("refs/foo").commit().create(); |
| 324 | repo.branch("refs/heads/foo").commit().create(); |
| 325 | repo.branch("refs/tags/foo").commit().create(); |
| 326 | |
| 327 | assertEquals( |
| 328 | ImmutableList.of( |
| 329 | ref("/b/test/+/refs/heads/foo", "foo")), |
| 330 | buildBranchesSoyData()); |
| 331 | assertEquals( |
| 332 | ImmutableList.of( |
| 333 | ref("/b/test/+/refs/tags/foo", "foo")), |
| 334 | buildTagsSoyData()); |
| 335 | } |
| 336 | |
| 337 | @Test |
| 338 | public void refsHeadsSoy() throws Exception { |
| 339 | repo.branch("refs/heads/foo").commit().create(); |
| 340 | repo.branch("refs/heads/refs/heads/foo").commit().create(); |
| 341 | |
| 342 | assertEquals( |
| 343 | ImmutableList.of( |
| 344 | ref("/b/test/+/foo", "foo"), |
| 345 | ref("/b/test/+/refs/heads/refs/heads/foo", "refs/heads/foo")), |
| 346 | buildBranchesSoyData()); |
| 347 | } |
| 348 | |
| 349 | private HttpServletRequest buildSoyRequest() { |
| 350 | HttpServletRequest req = FakeHttpServletRequest.newRequest(repo.getRepository()); |
| 351 | ViewFilter.setView(req, GitilesView.repositoryIndex() |
| 352 | .setHostName(URLS.getHostName(req)) |
| 353 | .setServletPath(req.getServletPath()) |
| 354 | .setRepositoryName("test") |
| 355 | .build()); |
| 356 | return req; |
| 357 | } |
| 358 | |
| 359 | private List<?> buildBranchesSoyData() throws Exception { |
| 360 | return RefServlet.getBranchesSoyData(buildSoyRequest(), Integer.MAX_VALUE); |
| 361 | } |
| 362 | |
| 363 | private List<?> buildTagsSoyData() throws Exception { |
| 364 | RevWalk rw = new RevWalk(repo.getRepository()); |
| 365 | try { |
| 366 | return RefServlet.getTagsSoyData(buildSoyRequest(), |
| 367 | new TimeCache(TimeCache.defaultBuilder()), rw, Integer.MAX_VALUE); |
| 368 | } finally { |
| 369 | rw.release(); |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | private String id(String refName) throws IOException { |
| 374 | return ObjectId.toString(repo.getRepository().getRef(refName).getObjectId()); |
| 375 | } |
| 376 | |
| 377 | private String peeled(String refName) throws IOException { |
| 378 | return ObjectId.toString(repo.getRepository().peel( |
| 379 | repo.getRepository().getRef(refName)).getPeeledObjectId()); |
| 380 | } |
| 381 | |
| 382 | private Map<String, String> ref(String url, String name) { |
| 383 | return ImmutableMap.of("url", url, "name", name); |
| 384 | } |
| Dave Borowitz | d0b7e18 | 2013-01-11 15:55:09 -0800 | [diff] [blame] | 385 | } |