Package org.eclipse.jgit.junit.TestRepository

Examples of org.eclipse.jgit.junit.TestRepository.BranchBuilder


  }

  @Test
  public void testRecursiveMergeWithConflict() throws Exception {
    TestRepository<Repository> db_t = new TestRepository<Repository>(db);
    BranchBuilder master = db_t.branch("master");
    RevCommit m0 = master.commit().add("f", "1\n2\n3\n4\n5\n6\n7\n8\n9\n")
        .message("m0").create();
    RevCommit m1 = master.commit()
        .add("f", "1-master\n2\n3\n4\n5\n6\n7\n8\n9\n").message("m1")
        .create();
    db_t.getRevWalk().parseCommit(m1);

    BranchBuilder side = db_t.branch("side");
    RevCommit s1 = side.commit().parent(m0)
        .add("f", "1\n2\n3\n4\n5\n6\n7\n8\n9-side\n").message("s1")
        .create();
    RevCommit s2 = side.commit().parent(m1)
        .add("f", "1-master\n2\n3\n4\n5\n6\n7-res(side)\n8\n9-side\n")
        .message("s2(merge)").create();
    master.commit().parent(s1)
        .add("f", "1-master\n2\n3\n4\n5\n6\n7-conflict\n8\n9-side\n")
        .message("m2(merge)").create();
View Full Code Here


import org.junit.Test;

public class GcKeepFilesTest extends GcTestCase {
  @Test
  public void testKeepFiles() throws Exception {
    BranchBuilder bb = tr.branch("refs/heads/master");
    bb.commit().add("A", "A").add("B", "B").create();
    stats = gc.getStatistics();
    assertEquals(4, stats.numberOfLooseObjects);
    assertEquals(0, stats.numberOfPackedObjects);
    assertEquals(0, stats.numberOfPackFiles);
    gc.gc();
    stats = gc.getStatistics();
    assertEquals(0, stats.numberOfLooseObjects);
    assertEquals(4, stats.numberOfPackedObjects);
    assertEquals(1, stats.numberOfPackFiles);

    Iterator<PackFile> packIt = repo.getObjectDatabase().getPacks()
        .iterator();
    PackFile singlePack = packIt.next();
    assertFalse(packIt.hasNext());
    File keepFile = new File(singlePack.getPackFile().getPath() + ".keep");
    assertFalse(keepFile.exists());
    assertTrue(keepFile.createNewFile());
    bb.commit().add("A", "A2").add("B", "B2").create();
    stats = gc.getStatistics();
    assertEquals(4, stats.numberOfLooseObjects);
    assertEquals(4, stats.numberOfPackedObjects);
    assertEquals(1, stats.numberOfPackFiles);
    gc.gc();
View Full Code Here

import org.junit.Test;

public class GcDirCacheSavesObjectsTest extends GcTestCase {
  @Test
  public void testDirCacheSavesObjects() throws Exception {
    BranchBuilder bb = tr.branch("refs/heads/master");
    bb.commit().add("A", "A").add("B", "B").create();
    bb.commit().add("A", "A2").add("B", "B2").create();
    bb.commit().add("A", "A3"); // this new content in index should survive
    stats = gc.getStatistics();
    assertEquals(9, stats.numberOfLooseObjects);
    assertEquals(0, stats.numberOfPackedObjects);
    gc.gc();
    stats = gc.getStatistics();
View Full Code Here

    assertEquals(1, stats.numberOfPackFiles);
  }

  @Test
  public void testDirCacheSavesObjectsWithPruneNow() throws Exception {
    BranchBuilder bb = tr.branch("refs/heads/master");
    bb.commit().add("A", "A").add("B", "B").create();
    bb.commit().add("A", "A2").add("B", "B2").create();
    bb.commit().add("A", "A3"); // this new content in index should survive
    stats = gc.getStatistics();
    assertEquals(9, stats.numberOfLooseObjects);
    assertEquals(0, stats.numberOfPackedObjects);
    gc.setExpireAgeMillis(0);
    fsTick();
View Full Code Here

    assertEquals(repo.getRef("refs/tags/t").getObjectId(), b);
  }

  @Test
  public void dontPackHEAD_nonBare() throws Exception {
    BranchBuilder bb = tr.branch("refs/heads/side");
    RevCommit first = bb.commit().add("A", "A").add("B", "B").create();
    bb.commit().add("A", "A2").add("B", "B2").create();
    Git git = Git.wrap(repo);

    // check for the unborn branch master. HEAD should point to master and
    // master doesn't exist.
    assertEquals(repo.getRef("HEAD").getTarget().getName(),
View Full Code Here

    assertSame(repo.getRef("HEAD").getStorage(), Storage.LOOSE);
  }

  @Test
  public void dontPackHEAD_bare() throws Exception {
    BranchBuilder bb = tr.branch("refs/heads/side");
    bb.commit().add("A", "A").add("B", "B").create();
    RevCommit second = bb.commit().add("A", "A2").add("B", "B2").create();

    // Convert the repo to be bare
    FileBasedConfig cfg = repo.getConfig();
    cfg.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
        ConfigConstants.CONFIG_KEY_BARE, true);
View Full Code Here

import org.junit.Test;

public class GcReflogTest extends GcTestCase {
  @Test
  public void testPruneNone() throws Exception {
    BranchBuilder bb = tr.branch("refs/heads/master");
    bb.commit().add("A", "A").add("B", "B").create();
    bb.commit().add("A", "A2").add("B", "B2").create();
    new File(repo.getDirectory(), Constants.LOGS + "/refs/heads/master")
        .delete();
    stats = gc.getStatistics();
    assertEquals(8, stats.numberOfLooseObjects);
    gc.setExpireAgeMillis(0);
View Full Code Here

    gc.gc();
  }

  @Test
  public void testPackCommitsAndLooseOneNoReflog() throws Exception {
    BranchBuilder bb = tr.branch("refs/heads/master");
    RevCommit first = bb.commit().add("A", "A").add("B", "B").create();
    bb.commit().add("A", "A2").add("B", "B2").create();
    tr.update("refs/heads/master", first);

    stats = gc.getStatistics();
    assertEquals(8, stats.numberOfLooseObjects);
    assertEquals(0, stats.numberOfPackedObjects);
View Full Code Here

  }

  @Test
  public void testPackCommitsAndLooseOneWithPruneNowNoReflog()
      throws Exception {
    BranchBuilder bb = tr.branch("refs/heads/master");
    RevCommit first = bb.commit().add("A", "A").add("B", "B").create();
    bb.commit().add("A", "A2").add("B", "B2").create();
    tr.update("refs/heads/master", first);

    stats = gc.getStatistics();
    assertEquals(8, stats.numberOfLooseObjects);
    assertEquals(0, stats.numberOfPackedObjects);
View Full Code Here

  @Test
  public void testInitialCheckout() throws Exception {
    Git git = new Git(db);

    TestRepository<Repository> db_t = new TestRepository<Repository>(db);
    BranchBuilder master = db_t.branch("master");
    master.commit().add("f", "1").message("m0").create();
    assertFalse(new File(db.getWorkTree(), "f").exists());
    git.checkout().setName("master").call();
    assertTrue(new File(db.getWorkTree(), "f").exists());
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.junit.TestRepository.BranchBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.