You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GcTagTest.java 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright (C) 2012, Christian Halstrick <christian.halstrick@sap.com> and others
  3. *
  4. * This program and the accompanying materials are made available under the
  5. * terms of the Eclipse Distribution License v. 1.0 which is available at
  6. * https://www.eclipse.org/org/documents/edl-v10.php.
  7. *
  8. * SPDX-License-Identifier: BSD-3-Clause
  9. */
  10. package org.eclipse.jgit.internal.storage.file;
  11. import static org.junit.Assert.assertTrue;
  12. import java.util.Collections;
  13. import org.eclipse.jgit.lib.ObjectId;
  14. import org.eclipse.jgit.revwalk.RevBlob;
  15. import org.eclipse.jgit.revwalk.RevTag;
  16. import org.junit.Test;
  17. public class GcTagTest extends GcTestCase {
  18. @Test
  19. public void lightweightTag_objectNotPruned() throws Exception {
  20. RevBlob a = tr.blob("a");
  21. tr.lightweightTag("t", a);
  22. gc.setExpireAgeMillis(0);
  23. fsTick();
  24. gc.prune(Collections.<ObjectId> emptySet());
  25. assertTrue(repo.getObjectDatabase().has(a));
  26. }
  27. @Test
  28. public void annotatedTag_objectNotPruned() throws Exception {
  29. RevBlob a = tr.blob("a");
  30. RevTag t = tr.tag("t", a); // this doesn't create the refs/tags/t ref
  31. tr.lightweightTag("t", t);
  32. gc.setExpireAgeMillis(0);
  33. fsTick();
  34. gc.prune(Collections.<ObjectId> emptySet());
  35. assertTrue(repo.getObjectDatabase().has(t));
  36. assertTrue(repo.getObjectDatabase().has(a));
  37. }
  38. }