View Javadoc
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  
11  package org.eclipse.jgit.internal.storage.file;
12  
13  import static org.junit.Assert.assertTrue;
14  
15  import java.util.Collections;
16  
17  import org.eclipse.jgit.lib.ObjectId;
18  import org.eclipse.jgit.revwalk.RevBlob;
19  import org.eclipse.jgit.revwalk.RevTag;
20  import org.junit.Test;
21  
22  public class GcTagTest extends GcTestCase {
23  	@Test
24  	public void lightweightTag_objectNotPruned() throws Exception {
25  		RevBlob a = tr.blob("a");
26  		tr.lightweightTag("t", a);
27  		gc.setExpireAgeMillis(0);
28  		fsTick();
29  		gc.prune(Collections.<ObjectId> emptySet());
30  		assertTrue(repo.getObjectDatabase().has(a));
31  	}
32  
33  	@Test
34  	public void annotatedTag_objectNotPruned() throws Exception {
35  		RevBlob a = tr.blob("a");
36  		RevTag t = tr.tag("t", a); // this doesn't create the refs/tags/t ref
37  		tr.lightweightTag("t", t);
38  
39  		gc.setExpireAgeMillis(0);
40  		fsTick();
41  		gc.prune(Collections.<ObjectId> emptySet());
42  		assertTrue(repo.getObjectDatabase().has(t));
43  		assertTrue(repo.getObjectDatabase().has(a));
44  	}
45  }