Beispiel #1
0
  @Override
  @Before
  public void setUp() throws Exception {
    super.setUp();
    dbTarget = createWorkRepository();
    source = new Git(db);
    target = new Git(dbTarget);

    // put some file in the source repo
    sourceFile = new File(db.getWorkTree(), "SomeFile.txt");
    writeToFile(sourceFile, "Hello world");
    // and commit it
    source.add().addFilepattern("SomeFile.txt").call();
    source.commit().setMessage("Initial commit for source").call();

    // configure the target repo to connect to the source via "origin"
    StoredConfig targetConfig = dbTarget.getConfig();
    targetConfig.setString("branch", "master", "remote", "origin");
    targetConfig.setString("branch", "master", "merge", "refs/heads/master");
    RemoteConfig config = new RemoteConfig(targetConfig, "origin");

    config.addURI(new URIish(source.getRepository().getWorkTree().getPath()));
    config.addFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/origin/*"));
    config.update(targetConfig);
    targetConfig.save();

    targetFile = new File(dbTarget.getWorkTree(), "SomeFile.txt");
    // make sure we have the same content
    target.pull().call();
    assertFileContentsEqual(targetFile, "Hello world");
  }
Beispiel #2
0
  public void setUp() throws Exception {
    super.setUp();
    git = new Git(db);
    // commit something
    writeTrashFile("Test.txt", "Hello world");
    git.add().addFilepattern("Test.txt").call();
    git.commit().setMessage("Initial commit").call();

    // create a master branch and switch to it
    git.branchCreate().setName("test").call();
    RefUpdate rup = db.updateRef(Constants.HEAD);
    rup.link("refs/heads/test");

    // commit something on the test branch
    writeTrashFile("Test.txt", "Some change");
    git.add().addFilepattern("Test.txt").call();
    git.commit().setMessage("Second commit").call();
  }
Beispiel #3
0
 public void setUp() throws Exception {
   super.setUp();
   git = new Git(db);
 }