Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.StoredConfig


    final String SOURCE_FILE_CONTENTS = "Source change";
    final String NEW_FILE_CONTENTS = "New file from target";

    // make sure the config for target says we should pull with merge
    // we will override this later with the setRebase method
    StoredConfig targetConfig = dbTarget.getConfig();
    targetConfig.setBoolean("branch", "master", "rebase", false);
    targetConfig.save();

    // create commit in source
    writeToFile(sourceFile, SOURCE_FILE_CONTENTS);
    source.add().addFilepattern(sourceFile.getName()).call();
    source.commit().setMessage(SOURCE_COMMIT_MESSAGE).call();

    // create commit in target, not conflicting with the new commit in source
    File newFile = new File(dbTarget.getWorkTree().getPath() + "/newFile.txt");
    writeToFile(newFile, NEW_FILE_CONTENTS);
    target.add().addFilepattern(newFile.getName()).call();
    target.commit().setMessage(TARGET_COMMIT_MESSAGE).call();

    // verify that rebase is set to false in the config
    assertFalse(targetConfig.getBoolean("branch", "master", "rebase", true));

    // pull with rebase - local commit in target should be on top
    PullResult pullResult = target.pull().setRebase(true).call();

    // make sure pull is considered successful
View Full Code Here


    // 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()
            .getAbsolutePath()));
    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();
    target.checkout().setStartPoint("refs/remotes/origin/master").setName(
        "master").call();

    targetConfig
        .setString("branch", "master", "merge", "refs/heads/master");
    targetConfig.setBoolean("branch", "master", "rebase", true);
    targetConfig.save();

    assertFileContentsEqual(targetFile, "Hello world");
  }
View Full Code Here

  @Test
  /** global rebase config should be respected */
  public void testPullWithRebasePreserve1Config() throws Exception {
    Callable<PullResult> setup = new Callable<PullResult>() {
      public PullResult call() throws Exception {
        StoredConfig config = dbTarget.getConfig();
        config.setString("pull", null, "rebase", "preserve");
        config.save();
        return target.pull().call();
      }
    };
    doTestPullWithRebase(setup, TestPullMode.REBASE_PREASERVE);
  }
View Full Code Here

  @Test
  /** the branch-local config should win over the global config */
  public void testPullWithRebasePreserveConfig2() throws Exception {
    Callable<PullResult> setup = new Callable<PullResult>() {
      public PullResult call() throws Exception {
        StoredConfig config = dbTarget.getConfig();
        config.setString("pull", null, "rebase", "false");
        config.setString("branch", "master", "rebase", "preserve");
        config.save();
        return target.pull().call();
      }
    };
    doTestPullWithRebase(setup, TestPullMode.REBASE_PREASERVE);
  }
View Full Code Here

  @Test
  /** the branch-local config should be respected */
  public void testPullWithRebasePreserveConfig3() throws Exception {
    Callable<PullResult> setup = new Callable<PullResult>() {
      public PullResult call() throws Exception {
        StoredConfig config = dbTarget.getConfig();
        config.setString("branch", "master", "rebase", "preserve");
        config.save();
        return target.pull().call();
      }
    };
    doTestPullWithRebase(setup, TestPullMode.REBASE_PREASERVE);
  }
View Full Code Here

  @Test
  /** global rebase config should be respected */
  public void testPullWithRebaseConfig1() throws Exception {
    Callable<PullResult> setup = new Callable<PullResult>() {
      public PullResult call() throws Exception {
        StoredConfig config = dbTarget.getConfig();
        config.setString("pull", null, "rebase", "true");
        config.save();
        return target.pull().call();
      }
    };
    doTestPullWithRebase(setup, TestPullMode.REBASE);
  }
View Full Code Here

  @Test
  /** the branch-local config should win over the global config */
  public void testPullWithRebaseConfig2() throws Exception {
    Callable<PullResult> setup = new Callable<PullResult>() {
      public PullResult call() throws Exception {
        StoredConfig config = dbTarget.getConfig();
        config.setString("pull", null, "rebase", "preserve");
        config.setString("branch", "master", "rebase", "true");
        config.save();
        return target.pull().call();
      }
    };
    doTestPullWithRebase(setup, TestPullMode.REBASE);
  }
View Full Code Here

  @Test
  /** the branch-local config should be respected */
  public void testPullWithRebaseConfig3() throws Exception {
    Callable<PullResult> setup = new Callable<PullResult>() {
      public PullResult call() throws Exception {
        StoredConfig config = dbTarget.getConfig();
        config.setString("branch", "master", "rebase", "true");
        config.save();
        return target.pull().call();
      }
    };
    doTestPullWithRebase(setup, TestPullMode.REBASE);
  }
View Full Code Here

  @Test
  /** the branch local config should win over the global config */
  public void testPullWithMergeConfig() throws Exception {
    Callable<PullResult> setup = new Callable<PullResult>() {
      public PullResult call() throws Exception {
        StoredConfig config = dbTarget.getConfig();
        config.setString("pull", null, "rebase", "true");
        config.setString("branch", "master", "rebase", "false");
        config.save();
        return target.pull().call();
      }
    };
    doTestPullWithRebase(setup, TestPullMode.MERGE);
  }
View Full Code Here

  @Test
  /** the branch local config should win over the global config */
  public void testPullWithMergeConfig2() throws Exception {
    Callable<PullResult> setup = new Callable<PullResult>() {
      public PullResult call() throws Exception {
        StoredConfig config = dbTarget.getConfig();
        config.setString("pull", null, "rebase", "false");
        config.save();
        return target.pull().call();
      }
    };
    doTestPullWithRebase(setup, TestPullMode.MERGE);
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.lib.StoredConfig

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.