org.netbeans.libs.git.GitClient.commit() - java examples

Here are the examples of the java api org.netbeans.libs.git.GitClient.commit() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

126 Examples 7

19 View Complete Implementation : LogTest.java
Copyright Apache License 2.0
Author : apache
public void testLogShowMerges() throws Exception {
    File f = new File(workDir, "f");
    write(f, "a\nb\nc");
    File[] files = new File[] { f };
    add(files);
    commit(files);
    GitClient client = getClient(workDir);
    client.createBranch("b", "master", NULL_PROGRESS_MONITOR);
    client.checkoutRevision("b", true, NULL_PROGRESS_MONITOR);
    write(f, "modification on branch\nb\nc");
    add(files);
    GitRevisionInfo revisionBranch = client.commit(files, "modification on branch", null, null, NULL_PROGRESS_MONITOR);
    Thread.sleep(1100);
    client.checkoutRevision("master", true, NULL_PROGRESS_MONITOR);
    write(f, "a\nb\nmodification on master");
    add(files);
    GitRevisionInfo revisionMaster = client.commit(files, "modification on master", null, null, NULL_PROGRESS_MONITOR);
    GitRevisionInfo revisionMerge = client.log(client.merge("b", NULL_PROGRESS_MONITOR).getNewHead(), NULL_PROGRESS_MONITOR);
    SearchCriteria crit = new SearchCriteria();
    crit.setRevisionTo("master");
    GitRevisionInfo[] revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(4, revisions.length);
    replacedertRevisions(revisionMerge, revisions[0]);
    crit = new SearchCriteria();
    crit.setIncludeMerges(true);
    revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(4, revisions.length);
    replacedertRevisions(revisionMerge, revisions[0]);
    crit = new SearchCriteria();
    crit.setIncludeMerges(false);
    revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(3, revisions.length);
    replacedertRevisions(revisionMaster, revisions[0]);
    replacedertRevisions(revisionBranch, revisions[1]);
}

19 View Complete Implementation : MergeTest.java
Copyright Apache License 2.0
Author : apache
public void testMergeFastForward() throws Exception {
    File f = new File(workDir, "file");
    write(f, "init");
    add(f);
    commit(f);
    GitClient client = getClient(workDir);
    client.createBranch(BRANCH_NAME, Constants.MASTER, NULL_PROGRESS_MONITOR);
    client.checkoutRevision(BRANCH_NAME, true, NULL_PROGRESS_MONITOR);
    write(f, BRANCH_NAME);
    add(f);
    GitRevisionInfo info = client.commit(new File[] { f }, "change on branch", null, null, NULL_PROGRESS_MONITOR);
    client.checkoutRevision(Constants.MASTER, true, NULL_PROGRESS_MONITOR);
    replacedertEquals("init", read(f));
    GitMergeResult result = client.merge(BRANCH_NAME, NULL_PROGRESS_MONITOR);
    replacedertEquals(MergeStatus.FAST_FORWARD, result.getMergeStatus());
    replacedertEquals(BRANCH_NAME, read(f));
    SearchCriteria crit = new SearchCriteria();
    crit.setRevisionTo(Constants.MASTER);
    GitRevisionInfo[] logs = client.log(crit, NULL_PROGRESS_MONITOR);
    replacedertEquals(2, logs.length);
    replacedertEquals(logs[0].getRevision(), info.getRevision());
    // continue working on branch
    client.checkoutRevision(BRANCH_NAME, true, NULL_PROGRESS_MONITOR);
    remove(false, f);
    info = client.commit(new File[] { f }, "delete on branch", null, null, NULL_PROGRESS_MONITOR);
    client.checkoutRevision(Constants.MASTER, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(BRANCH_NAME, read(f));
    result = client.merge(BRANCH_NAME, NULL_PROGRESS_MONITOR);
    replacedertEquals(MergeStatus.FAST_FORWARD, result.getMergeStatus());
    replacedertFalse(f.exists());
    crit = new SearchCriteria();
    crit.setRevisionTo(Constants.MASTER);
    logs = client.log(crit, NULL_PROGRESS_MONITOR);
    replacedertEquals(3, logs.length);
    replacedertEquals(logs[0].getRevision(), info.getRevision());
}

19 View Complete Implementation : LogTest.java
Copyright Apache License 2.0
Author : apache
public void testLimit() throws Exception {
    File f1 = new File(workDir, "f1");
    write(f1, "init");
    File f2 = new File(workDir, "f2");
    write(f2, "init");
    File[] files = new File[] { f1, f2 };
    add(files);
    commit(files);
    write(f1, "modif1");
    add(f1);
    GitClient client = getClient(workDir);
    GitRevisionInfo c1 = client.commit(files, "m1", new GitUser("another", "netbeans.org"), new GitUser("another", "netbeans.org"), NULL_PROGRESS_MONITOR);
    write(f2, "modif2");
    add(f2);
    GitRevisionInfo c2 = client.commit(files, "m2", new GitUser("user", "netbeans.org"), new GitUser("user", "netbeans.org"), NULL_PROGRESS_MONITOR);
    SearchCriteria crit = new SearchCriteria();
    crit.setLimit(1);
    crit.setUsername("another");
    GitRevisionInfo[] log = client.log(crit, NULL_PROGRESS_MONITOR);
    replacedertEquals(c1.getRevision(), log[0].getRevision());
}

19 View Complete Implementation : TagTest.java
Copyright Apache License 2.0
Author : apache
public void testTagInvalidName() throws Exception {
    File f = new File(workDir, "f");
    File[] files = new File[] { f };
    GitClient client = getClient(workDir);
    write(f, "init");
    GitRevisionInfo commit = client.commit(files, "init commit", null, null, NULL_PROGRESS_MONITOR);
    String name = "tag with spaces";
    try {
        client.createTag(name, commit.getRevision(), null, false, false, NULL_PROGRESS_MONITOR);
        fail("Should fail");
    } catch (GitException ex) {
        replacedertTrue(ex.getCause() != null);
        replacedertTrue(ex.getCause().toString(), ex.getCause() instanceof InvalidTagNameException);
    }
}

19 View Complete Implementation : RebaseTest.java
Copyright Apache License 2.0
Author : apache
public void testRebaseAbort() throws Exception {
    File f = new File(workDir, "file");
    write(f, "init");
    add(f);
    commit(f);
    GitClient client = getClient(workDir);
    client.createBranch(BRANCH_NAME, Constants.MASTER, NULL_PROGRESS_MONITOR);
    write(f, Constants.MASTER);
    add(f);
    GitRevisionInfo masterInfo = client.commit(new File[] { f }, "change on master", null, null, NULL_PROGRESS_MONITOR);
    client.checkoutRevision(BRANCH_NAME, true, NULL_PROGRESS_MONITOR);
    write(f, BRANCH_NAME);
    add(f);
    GitRevisionInfo branchInfo = client.commit(new File[] { f }, "change on branch", null, null, NULL_PROGRESS_MONITOR);
    GitRebaseResult result = client.rebase(RebaseOperationType.BEGIN, Constants.MASTER, NULL_PROGRESS_MONITOR);
    replacedertEquals(RebaseStatus.STOPPED, result.getRebaseStatus());
    replacedertEquals(Arrays.asList(f), result.getConflicts());
    replacedertEquals(branchInfo.getRevision(), result.getCurrentCommit());
    replacedertEquals(masterInfo.getRevision(), result.getCurrentHead());
    result = client.rebase(RebaseOperationType.ABORT, null, NULL_PROGRESS_MONITOR);
    replacedertEquals(RebaseStatus.ABORTED, result.getRebaseStatus());
    replacedertTrue(result.getConflicts().isEmpty());
    // resets to original state
    replacedertEquals(branchInfo.getRevision(), result.getCurrentHead());
    replacedertEquals(branchInfo.getRevision(), getRepository(client).resolve(BRANCH_NAME).name());
    replacedertEquals(masterInfo.getRevision(), getRepository(client).resolve(Constants.MASTER).name());
}

19 View Complete Implementation : BlameTest.java
Copyright Apache License 2.0
Author : apache
public void testBlameRename() throws Exception {
    File f = new File(workDir, "f");
    File f2 = new File(workDir, "f2");
    write(f, "aaa\nbbb\nccc\n");
    File[] files = { f, f2 };
    add(files);
    GitClient client = getClient(workDir);
    String revision1 = client.commit(files, "initial commit", USER1, USER1, NULL_PROGRESS_MONITOR).getRevision();
    client.rename(f, f2, false, NULL_PROGRESS_MONITOR);
    write(f2, "aaa\nbbb\nddd\n");
    add(f2);
    String revision2 = client.commit(files, "rename", USER1, USER1, NULL_PROGRESS_MONITOR).getRevision();
    GitBlameResult result = client.blame(f, revision2, NULL_PROGRESS_MONITOR);
    replacedertNull(result);
    result = client.blame(f, revision1, NULL_PROGRESS_MONITOR);
    replacedertEquals(f, result.getBlamedFile());
    replacedertLineDetails(f, 0, revision1, USER1, USER1, result.getLineDetails(0));
    replacedertLineDetails(f, 1, revision1, USER1, USER1, result.getLineDetails(1));
    replacedertLineDetails(f, 2, revision1, USER1, USER1, result.getLineDetails(2));
    result = client.blame(f2, null, NULL_PROGRESS_MONITOR);
    replacedertEquals(f2, result.getBlamedFile());
    replacedertLineDetails(f, 0, revision1, USER1, USER1, result.getLineDetails(0));
    replacedertLineDetails(f, 1, revision1, USER1, USER1, result.getLineDetails(1));
    replacedertLineDetails(f2, 2, revision2, USER1, USER1, result.getLineDetails(2));
}

19 View Complete Implementation : MergeTest.java
Copyright Apache License 2.0
Author : apache
public void testMergeRevision() throws Exception {
    File f = new File(workDir, "file");
    write(f, "init");
    add(f);
    commit(f);
    GitClient client = getClient(workDir);
    client.createBranch(BRANCH_NAME, Constants.MASTER, NULL_PROGRESS_MONITOR);
    client.checkoutRevision(BRANCH_NAME, true, NULL_PROGRESS_MONITOR);
    write(f, BRANCH_NAME);
    add(f);
    GitRevisionInfo info = client.commit(new File[] { f }, "change on branch", null, null, NULL_PROGRESS_MONITOR);
    write(f, "another change");
    add(f);
    GitRevisionInfo info2 = client.commit(new File[] { f }, "change on branch", null, null, NULL_PROGRESS_MONITOR);
    client.checkoutRevision(Constants.MASTER, true, NULL_PROGRESS_MONITOR);
    replacedertEquals("init", read(f));
    GitMergeResult result = client.merge(info.getRevision(), NULL_PROGRESS_MONITOR);
    replacedertEquals(MergeStatus.FAST_FORWARD, result.getMergeStatus());
    replacedertEquals(BRANCH_NAME, read(f));
    SearchCriteria crit = new SearchCriteria();
    crit.setRevisionTo(Constants.MASTER);
    GitRevisionInfo[] logs = client.log(crit, NULL_PROGRESS_MONITOR);
    replacedertEquals(2, logs.length);
    replacedertEquals(logs[0].getRevision(), info.getRevision());
    // merge the rest
    result = client.merge(BRANCH_NAME, NULL_PROGRESS_MONITOR);
    replacedertEquals(MergeStatus.FAST_FORWARD, result.getMergeStatus());
    replacedertEquals("another change", read(f));
    crit = new SearchCriteria();
    crit.setRevisionTo(Constants.MASTER);
    logs = client.log(crit, NULL_PROGRESS_MONITOR);
    replacedertEquals(3, logs.length);
    replacedertEquals(logs[0].getRevision(), info2.getRevision());
}

19 View Complete Implementation : BlameTest.java
Copyright Apache License 2.0
Author : apache
public void testBlameRemoveLine() throws Exception {
    File f = new File(workDir, "f");
    write(f, "aaa\nbbb\nccc");
    File[] files = { f };
    add(files);
    GitClient client = getClient(workDir);
    String revision1 = client.commit(files, "initial commit", USER1, USER1, NULL_PROGRESS_MONITOR).getRevision();
    write(f, "aaa\nccc");
    add(f);
    String revision2 = client.commit(files, "remove line", USER1, USER1, NULL_PROGRESS_MONITOR).getRevision();
    GitBlameResult result = client.blame(f, revision2, NULL_PROGRESS_MONITOR);
    replacedertEquals(f, result.getBlamedFile());
    replacedertEquals(2, result.getLineCount());
    replacedertLineDetails(f, 0, revision1, USER1, USER1, result.getLineDetails(0));
    replacedertLineDetails(f, 2, revision1, USER1, USER1, result.getLineDetails(1));
}

19 View Complete Implementation : MergeTest.java
Copyright Apache License 2.0
Author : apache
public void testMergeFFOnly() throws Exception {
    File f1 = new File(workDir, "file1");
    File f2 = new File(workDir, "file2");
    write(f1, "init");
    write(f2, "init");
    add(f1, f2);
    commit(f1, f2);
    GitClient client = getClient(workDir);
    client.createBranch(BRANCH_NAME, Constants.MASTER, NULL_PROGRESS_MONITOR);
    client.checkoutRevision(BRANCH_NAME, true, NULL_PROGRESS_MONITOR);
    write(f1, BRANCH_NAME);
    add(f1);
    client.commit(new File[] { f1 }, "change on branch", null, null, NULL_PROGRESS_MONITOR);
    client.checkoutRevision(Constants.MASTER, true, NULL_PROGRESS_MONITOR);
    write(f2, "another change");
    add(f2);
    client.commit(new File[] { f2 }, "change on master", null, null, NULL_PROGRESS_MONITOR);
    GitMergeResult result = client.merge(BRANCH_NAME, GitRepository.FastForwardOption.FAST_FORWARD_ONLY, NULL_PROGRESS_MONITOR);
    // no merge commits allowed => FAIL
    replacedertEquals(MergeStatus.ABORTED, result.getMergeStatus());
    // test also config files
    replacedertEquals(GitRepository.FastForwardOption.FAST_FORWARD, GitRepository.getInstance(workDir).getDefaultFastForwardOption());
    StoredConfig cfg = repo.getConfig();
    cfg.setEnum(ConfigConstants.CONFIG_KEY_MERGE, null, ConfigConstants.CONFIG_KEY_FF, org.eclipse.jgit.api.MergeCommand.FastForwardMode.Merge.ONLY);
    cfg.save();
    replacedertEquals(GitRepository.FastForwardOption.FAST_FORWARD_ONLY, GitRepository.getInstance(workDir).getDefaultFastForwardOption());
    result = client.merge(BRANCH_NAME, NULL_PROGRESS_MONITOR);
    // no merge commits allowed => FAIL
    replacedertEquals(MergeStatus.ABORTED, result.getMergeStatus());
    result = client.merge(BRANCH_NAME, GitRepository.FastForwardOption.FAST_FORWARD, NULL_PROGRESS_MONITOR);
    // merge commits allowed => OK
    replacedertEquals(MergeStatus.MERGED, result.getMergeStatus());
}

19 View Complete Implementation : LogTest.java
Copyright Apache License 2.0
Author : apache
// commit in the middle of a named branch
public void testLogWithBranchInfoMiddleCommit() throws Exception {
    File f = new File(workDir, "f");
    File f2 = new File(workDir, "f2");
    write(f, "init");
    write(f2, "init");
    File[] files = new File[] { f, f2 };
    add(files);
    GitClient client = getClient(workDir);
    GitRevisionInfo firstCommit = client.commit(files, "initial commit", null, null, NULL_PROGRESS_MONITOR);
    client.createBranch("newbranch", "master", NULL_PROGRESS_MONITOR);
    write(f, "modification");
    add(files);
    commit(files);
    write(f2, "modification");
    add(files);
    commit(files);
    SearchCriteria crit = new SearchCriteria();
    crit.setRevisionFrom(firstCommit.getRevision());
    crit.setRevisionTo(firstCommit.getRevision());
    crit.setFiles(new File[] { f });
    GitRevisionInfo info = client.log(crit, true, NULL_PROGRESS_MONITOR)[0];
    // the initial commit is from master and head of newbranch
    replacedertNotNull(info.getBranches().get("newbranch"));
    replacedertEquals(2, info.getBranches().size());
}

19 View Complete Implementation : SetUpstreamBranchTest.java
Copyright Apache License 2.0
Author : apache
public void testLocalTracking() throws GitException {
    GitClient client = getClient(workDir);
    File f = new File(workDir, "f");
    add(f);
    client.commit(new File[] { f }, "init commit", null, null, NULL_PROGRESS_MONITOR);
    // prepare twp branches
    GitBranch b = client.createBranch(BRANCH, Constants.MASTER, NULL_PROGRESS_MONITOR);
    replacedertNull(b.getTrackedBranch());
    // set tracking
    b = client.setUpstreamBranch(BRANCH, Constants.MASTER, NULL_PROGRESS_MONITOR);
    replacedertEquals(Constants.MASTER, b.getTrackedBranch().getName());
}

19 View Complete Implementation : RebaseTest.java
Copyright Apache License 2.0
Author : apache
public void testRebaseSkip() throws Exception {
    File f = new File(workDir, "file");
    write(f, "init");
    add(f);
    commit(f);
    GitClient client = getClient(workDir);
    client.createBranch(BRANCH_NAME, Constants.MASTER, NULL_PROGRESS_MONITOR);
    write(f, Constants.MASTER);
    add(f);
    GitRevisionInfo masterInfo = client.commit(new File[] { f }, "change on master", null, null, NULL_PROGRESS_MONITOR);
    client.checkoutRevision(BRANCH_NAME, true, NULL_PROGRESS_MONITOR);
    write(f, BRANCH_NAME);
    add(f);
    GitRevisionInfo branchInfo = client.commit(new File[] { f }, "change on branch", null, null, NULL_PROGRESS_MONITOR);
    GitRebaseResult result = client.rebase(RebaseOperationType.BEGIN, Constants.MASTER, NULL_PROGRESS_MONITOR);
    replacedertEquals(RebaseStatus.STOPPED, result.getRebaseStatus());
    replacedertEquals(Arrays.asList(f), result.getConflicts());
    replacedertEquals(branchInfo.getRevision(), result.getCurrentCommit());
    replacedertEquals(masterInfo.getRevision(), result.getCurrentHead());
    result = client.rebase(RebaseOperationType.SKIP, null, NULL_PROGRESS_MONITOR);
    replacedertEquals(RebaseStatus.OK, result.getRebaseStatus());
    replacedertTrue(result.getConflicts().isEmpty());
    replacedertEquals(masterInfo.getRevision(), result.getCurrentHead());
    replacedertEquals(masterInfo.getRevision(), getRepository(client).resolve(BRANCH_NAME).name());
    replacedertEquals(masterInfo.getRevision(), getRepository(client).resolve(Constants.MASTER).name());
}

19 View Complete Implementation : LogTest.java
Copyright Apache License 2.0
Author : apache
public void testLogUsername() throws Exception {
    File f = new File(workDir, "f");
    write(f, "initial content");
    File[] files = new File[] { f };
    add(files);
    commit(files);
    write(f, "modification1");
    add(files);
    GitClient client = getClient(workDir);
    GitUser user1 = ApiUtils.getClreplacedFactory().createUser(new PersonIdent("git-test-user", "[email protected]"));
    GitRevisionInfo revision1 = client.commit(files, "modification1", user1, null, NULL_PROGRESS_MONITOR);
    write(f, "modification2");
    add(files);
    GitRevisionInfo revision2 = client.commit(files, "modification2", null, user1, NULL_PROGRESS_MONITOR);
    SearchCriteria crit = new SearchCriteria();
    GitRevisionInfo[] revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(3, revisions.length);
    crit = new SearchCriteria();
    crit.setUsername("git-test-user");
    revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(2, revisions.length);
    replacedertRevisions(revision2, revisions[0]);
    replacedertRevisions(revision1, revisions[1]);
    crit = new SearchCriteria();
    crit.setUsername("[email protected]");
    revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(2, revisions.length);
    replacedertRevisions(revision2, revisions[0]);
    replacedertRevisions(revision1, revisions[1]);
    crit = new SearchCriteria();
    crit.setUsername("test-user");
    revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(2, revisions.length);
    replacedertRevisions(revision2, revisions[0]);
    replacedertRevisions(revision1, revisions[1]);
    crit = new SearchCriteria();
    crit.setUsername("[email protected]");
    revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(0, revisions.length);
    crit = new SearchCriteria();
    crit.setUsername("git-test-user <[email protected]>");
    revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(2, revisions.length);
    replacedertRevisions(revision2, revisions[0]);
    replacedertRevisions(revision1, revisions[1]);
}

19 View Complete Implementation : TagTest.java
Copyright Apache License 2.0
Author : apache
public void testOverwriteTag() throws Exception {
    File f = new File(workDir, "f");
    File[] files = new File[] { f };
    GitClient client = getClient(workDir);
    write(f, "init");
    GitRevisionInfo commit = client.commit(files, "init commit", null, null, NULL_PROGRESS_MONITOR);
    GitTag tag = client.createTag("tag-name", commit.getRevision(), "tag message\nfor tag-name", false, false, NULL_PROGRESS_MONITOR);
    replacedertTag(tag, commit.getRevision(), "tag-name", "tag message\nfor tag-name", client.getUser(), GitObjectType.COMMIT, false);
    write(f, "modif");
    commit = client.commit(files, "change", null, null, NULL_PROGRESS_MONITOR);
    try {
        tag = client.createTag("tag-name", commit.getRevision(), "second tag message\nfor tag-name", false, false, NULL_PROGRESS_MONITOR);
        fail("Tag already exists, should fail");
    } catch (GitException ex) {
    }
    tag = client.createTag("tag-name", commit.getRevision(), "second tag message\nfor tag-name", false, true, NULL_PROGRESS_MONITOR);
    replacedertTag(tag, commit.getRevision(), "tag-name", "second tag message\nfor tag-name", client.getUser(), GitObjectType.COMMIT, false);
}

19 View Complete Implementation : BlameTest.java
Copyright Apache License 2.0
Author : apache
public void testBlameSimple() throws Exception {
    File f = new File(workDir, "f");
    write(f, "aaa\nbbb\nccc\n");
    File[] files = { f };
    add(files);
    GitClient client = getClient(workDir);
    String revision1 = client.commit(files, "initial commit", USER1, USER1, NULL_PROGRESS_MONITOR).getRevision();
    GitBlameResult result = client.blame(f, revision1, NULL_PROGRESS_MONITOR);
    replacedertEquals(f, result.getBlamedFile());
    replacedertLineDetails(f, 0, revision1, USER1, USER1, result.getLineDetails(0));
    // the same authors should be the same one instance
    replacedertSame(result.getLineDetails(0).getAuthor(), result.getLineDetails(1).getAuthor());
    replacedertSame(result.getLineDetails(1).getAuthor(), result.getLineDetails(2).getAuthor());
    replacedertSame(result.getLineDetails(0).getAuthor(), result.getLineDetails(0).getCommitter());
    replacedertSame(result.getLineDetails(0).getCommitter(), result.getLineDetails(1).getCommitter());
    replacedertSame(result.getLineDetails(1).getCommitter(), result.getLineDetails(2).getCommitter());
    // the same commits should be the same one instance
    replacedertSame(result.getLineDetails(0).getRevisionInfo(), result.getLineDetails(1).getRevisionInfo());
    replacedertSame(result.getLineDetails(1).getRevisionInfo(), result.getLineDetails(2).getRevisionInfo());
    write(f, "aaa\nzzz\nccc\n");
    add(files);
    String revision2 = client.commit(files, "change 1", USER2, USER1, NULL_PROGRESS_MONITOR).getRevision();
    result = client.blame(f, revision2, NULL_PROGRESS_MONITOR);
    replacedertEquals(f, result.getBlamedFile());
    replacedertLineDetails(f, 0, revision1, USER1, USER1, result.getLineDetails(0));
    replacedertLineDetails(f, 1, revision2, USER2, USER1, result.getLineDetails(1));
    replacedertLineDetails(f, 2, revision1, USER1, USER1, result.getLineDetails(2));
    write(f, "aaa\nzzz\nyyy\n");
    add(files);
    String revision3 = client.commit(files, "change 2", USER1, USER2, NULL_PROGRESS_MONITOR).getRevision();
    result = client.blame(f, revision3, NULL_PROGRESS_MONITOR);
    replacedertEquals(f, result.getBlamedFile());
    replacedertLineDetails(f, 0, revision1, USER1, USER1, result.getLineDetails(0));
    replacedertLineDetails(f, 1, revision2, USER2, USER1, result.getLineDetails(1));
    replacedertLineDetails(f, 2, revision3, USER1, USER2, result.getLineDetails(2));
}

19 View Complete Implementation : MergeTest.java
Copyright Apache License 2.0
Author : apache
public void testMergeCommitFails250370() throws Exception {
    File f1 = new File(workDir, "file1");
    File f2 = new File(workDir, "file2");
    write(f1, "init");
    write(f2, "init");
    add(f1, f2);
    commit(f1, f2);
    new File(workDir, ".git/rebase-apply").mkdirs();
    GitClient client = getClient(workDir);
    client.createBranch(BRANCH_NAME, Constants.MASTER, NULL_PROGRESS_MONITOR);
    client.checkoutRevision(BRANCH_NAME, true, NULL_PROGRESS_MONITOR);
    write(f1, BRANCH_NAME);
    add(f1);
    client.commit(new File[] { f1 }, "change on branch", null, null, NULL_PROGRESS_MONITOR);
    client.checkoutRevision(Constants.MASTER, true, NULL_PROGRESS_MONITOR);
    write(f2, "master");
    add(f2);
    client.commit(new File[] { f2 }, "change on master", null, null, NULL_PROGRESS_MONITOR);
    try {
        client.merge(BRANCH_NAME, NULL_PROGRESS_MONITOR);
        fail();
    } catch (GitException ex) {
        // merge should return a meaningful message with a description
        replacedertEquals(Utils.getBundle(MergeCommand.clreplaced).getString("MSG_MergeCommand.commitErr.wrongRepoState"), ex.getLocalizedMessage());
    }
}

19 View Complete Implementation : LogTest.java
Copyright Apache License 2.0
Author : apache
public void testLogLimit() throws Exception {
    File f = new File(workDir, "testcat1");
    write(f, "initial content");
    File[] files = new File[] { f };
    add(files);
    commit(files);
    write(f, "modification1");
    add(files);
    GitClient client = getClient(workDir);
    GitRevisionInfo revision1 = client.commit(files, "modification1", null, null, NULL_PROGRESS_MONITOR);
    write(f, "modification2");
    add(files);
    GitRevisionInfo revision2 = client.commit(files, "modification2", null, null, NULL_PROGRESS_MONITOR);
    write(f, "modification3");
    add(files);
    GitRevisionInfo revision3 = client.commit(files, "modification3", null, null, NULL_PROGRESS_MONITOR);
    write(f, "modification4");
    add(files);
    GitRevisionInfo revision4 = client.commit(files, "modification4", null, null, NULL_PROGRESS_MONITOR);
    SearchCriteria crit = new SearchCriteria();
    crit.setRevisionFrom(revision2.getRevision());
    crit.setRevisionTo(revision4.getRevision());
    GitRevisionInfo[] revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(3, revisions.length);
    replacedertRevisions(revision4, revisions[0]);
    replacedertRevisions(revision3, revisions[1]);
    replacedertRevisions(revision2, revisions[2]);
    crit = new SearchCriteria();
    crit.setRevisionFrom(revision2.getRevision());
    crit.setRevisionTo(revision4.getRevision());
    crit.setLimit(2);
    revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(2, revisions.length);
    replacedertRevisions(revision4, revisions[0]);
    replacedertRevisions(revision3, revisions[1]);
}

19 View Complete Implementation : MergeTest.java
Copyright Apache License 2.0
Author : apache
public void testMergeFailOnLocalChanges() throws Exception {
    File f = new File(workDir, "file");
    write(f, "init");
    File f2 = new File(workDir, "file2");
    write(f2, "init");
    File[] files = { f, f2 };
    add(files);
    commit(files);
    GitClient client = getClient(workDir);
    client.createBranch(BRANCH_NAME, Constants.MASTER, NULL_PROGRESS_MONITOR);
    client.checkoutRevision(BRANCH_NAME, true, NULL_PROGRESS_MONITOR);
    write(f, BRANCH_NAME);
    add(f);
    write(f2, BRANCH_NAME);
    add(f2);
    GitRevisionInfo branchInfo = client.commit(files, "change on branch", null, null, NULL_PROGRESS_MONITOR);
    client.checkoutRevision(Constants.MASTER, true, NULL_PROGRESS_MONITOR);
    replacedertEquals("init", read(f));
    replacedertEquals("init", read(f2));
    write(f, Constants.MASTER);
    write(f2, Constants.MASTER);
    try {
        client.merge(branchInfo.getRevision(), NULL_PROGRESS_MONITOR);
        fail("Should fail");
    } catch (GitException.CheckoutConflictException ex) {
        // OK
        replacedertEquals(Arrays.asList(new String[] { f.getName(), f2.getName() }), Arrays.asList(ex.getConflicts()));
    }
}

19 View Complete Implementation : CheckoutTest.java
Copyright Apache License 2.0
Author : apache
public void testCheckoutAfterUnresolvedMerge() throws Exception {
    File file = new File(workDir, "file");
    write(file, "initial");
    File[] files = new File[] { file };
    add(files);
    GitClient client = getClient(workDir);
    GitRevisionInfo info = client.commit(files, "initial", null, null, NULL_PROGRESS_MONITOR);
    client.createBranch(BRANCH, info.getRevision(), NULL_PROGRESS_MONITOR);
    client.checkoutRevision(BRANCH, true, NULL_PROGRESS_MONITOR);
    write(file, BRANCH);
    add(file);
    client.commit(files, BRANCH, null, null, NULL_PROGRESS_MONITOR);
    client.checkoutRevision(Constants.MASTER, true, NULL_PROGRESS_MONITOR);
    write(file, "master change");
    add(file);
    client.commit(files, "master commit", null, null, NULL_PROGRESS_MONITOR);
    client.merge(BRANCH, NULL_PROGRESS_MONITOR);
    try {
        client.checkoutRevision(BRANCH, true, NULL_PROGRESS_MONITOR);
        fail("Should fail, there are conflicts");
    } catch (GitException.CheckoutConflictException ex) {
    // ok
    }
    try {
        client.checkoutRevision(BRANCH, false, NULL_PROGRESS_MONITOR);
        fail("Should fail, there are conflicts");
    } catch (GitException ex) {
        replacedertEquals(ex.getMessage(), MessageFormat.format(Utils.getBundle(GitCommand.clreplaced).getString("MSG_Error_CannotCheckoutHasConflicts"), workDir));
    }
}

19 View Complete Implementation : MergeTest.java
Copyright Apache License 2.0
Author : apache
public void testMergeNoFastForward() throws Exception {
    File f = new File(workDir, "file");
    write(f, "init");
    add(f);
    commit(f);
    GitClient client = getClient(workDir);
    client.createBranch(BRANCH_NAME, Constants.MASTER, NULL_PROGRESS_MONITOR);
    client.checkoutRevision(BRANCH_NAME, true, NULL_PROGRESS_MONITOR);
    write(f, BRANCH_NAME);
    add(f);
    GitRevisionInfo info = client.commit(new File[] { f }, "change on branch", null, null, NULL_PROGRESS_MONITOR);
    client.checkoutRevision(Constants.MASTER, true, NULL_PROGRESS_MONITOR);
    replacedertEquals("init", read(f));
    GitMergeResult result = client.merge(BRANCH_NAME, NULL_PROGRESS_MONITOR);
    replacedertEquals(MergeStatus.FAST_FORWARD, result.getMergeStatus());
    replacedertEquals(BRANCH_NAME, read(f));
    SearchCriteria crit = new SearchCriteria();
    crit.setRevisionTo(Constants.MASTER);
    GitRevisionInfo[] logs = client.log(crit, NULL_PROGRESS_MONITOR);
    replacedertEquals(2, logs.length);
    replacedertEquals(logs[0].getRevision(), info.getRevision());
    // continue working on branch
    client.checkoutRevision(BRANCH_NAME, true, NULL_PROGRESS_MONITOR);
    remove(false, f);
    client.commit(new File[] { f }, "delete on branch", null, null, NULL_PROGRESS_MONITOR);
    client.checkoutRevision(Constants.MASTER, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(BRANCH_NAME, read(f));
    result = client.merge(BRANCH_NAME, GitRepository.FastForwardOption.NO_FAST_FORWARD, NULL_PROGRESS_MONITOR);
    replacedertEquals(MergeStatus.MERGED, result.getMergeStatus());
    replacedertFalse(f.exists());
    crit = new SearchCriteria();
    crit.setRevisionTo(Constants.MASTER);
    logs = client.log(crit, NULL_PROGRESS_MONITOR);
    replacedertEquals(4, logs.length);
    replacedertEquals(2, logs[0].getParents().length);
}

19 View Complete Implementation : LogTest.java
Copyright Apache License 2.0
Author : apache
public void testLogRevisionTo() throws Exception {
    File f = new File(workDir, "testcat1");
    write(f, "initial content");
    File[] files = new File[] { f };
    add(files);
    GitClient client = getClient(workDir);
    GitRevisionInfo revision0 = client.commit(files, "initial commit", null, null, NULL_PROGRESS_MONITOR);
    write(f, "modification1");
    add(files);
    GitRevisionInfo revision1 = client.commit(files, "modification1", null, null, NULL_PROGRESS_MONITOR);
    write(f, "modification2");
    add(files);
    GitRevisionInfo revision2 = client.commit(files, "modification2", null, null, NULL_PROGRESS_MONITOR);
    write(f, "modification3");
    add(files);
    GitRevisionInfo revision3 = client.commit(files, "modification3", null, null, NULL_PROGRESS_MONITOR);
    write(f, "modification4");
    add(files);
    GitRevisionInfo revision4 = client.commit(files, "modification4", null, null, NULL_PROGRESS_MONITOR);
    SearchCriteria crit = new SearchCriteria();
    crit.setRevisionTo(revision4.getRevision());
    GitRevisionInfo[] revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(5, revisions.length);
    replacedertRevisions(revision4, revisions[0]);
    replacedertRevisions(revision3, revisions[1]);
    replacedertRevisions(revision2, revisions[2]);
    replacedertRevisions(revision1, revisions[3]);
    replacedertRevisions(revision0, revisions[4]);
}

19 View Complete Implementation : RebaseTest.java
Copyright Apache License 2.0
Author : apache
public void testResolveConflicts() throws Exception {
    File f = new File(workDir, "file");
    write(f, "init");
    add(f);
    commit(f);
    GitClient client = getClient(workDir);
    client.createBranch(BRANCH_NAME, Constants.MASTER, NULL_PROGRESS_MONITOR);
    write(f, Constants.MASTER);
    add(f);
    GitRevisionInfo masterInfo = client.commit(new File[] { f }, "change on master", null, null, NULL_PROGRESS_MONITOR);
    client.checkoutRevision(BRANCH_NAME, true, NULL_PROGRESS_MONITOR);
    write(f, BRANCH_NAME);
    add(f);
    GitRevisionInfo branchInfo = client.commit(new File[] { f }, "change on branch", null, null, NULL_PROGRESS_MONITOR);
    GitRebaseResult result = client.rebase(RebaseOperationType.BEGIN, Constants.MASTER, NULL_PROGRESS_MONITOR);
    replacedertEquals(RebaseStatus.STOPPED, result.getRebaseStatus());
    replacedertEquals(Arrays.asList(f), result.getConflicts());
    replacedertEquals(branchInfo.getRevision(), result.getCurrentCommit());
    replacedertEquals(masterInfo.getRevision(), result.getCurrentHead());
    write(f, "resolving conflict");
    add(f);
    result = client.rebase(RebaseOperationType.CONTINUE, null, NULL_PROGRESS_MONITOR);
    replacedertEquals(RebaseStatus.OK, result.getRebaseStatus());
    replacedertEquals(getRepository(client).resolve(Constants.HEAD).name(), result.getCurrentHead());
    replacedertEquals(getRepository(client).resolve(Constants.HEAD).name(), getRepository(client).resolve(BRANCH_NAME).name());
    replacedertEquals(masterInfo.getRevision(), getRepository(client).resolve(Constants.MASTER).name());
}

19 View Complete Implementation : BlameTest.java
Copyright Apache License 2.0
Author : apache
public void testBlameAddLine() throws Exception {
    File f = new File(workDir, "f");
    write(f, "aaa\nccc\n");
    File[] files = { f };
    add(files);
    GitClient client = getClient(workDir);
    String revision1 = client.commit(files, "initial commit", USER1, USER1, NULL_PROGRESS_MONITOR).getRevision();
    write(f, "aaa\nbbb\nccc\n");
    add(f);
    String revision2 = client.commit(files, "add line", USER1, USER1, NULL_PROGRESS_MONITOR).getRevision();
    GitBlameResult result = client.blame(f, revision2, NULL_PROGRESS_MONITOR);
    replacedertEquals(f, result.getBlamedFile());
    replacedertLineDetails(f, 0, revision1, USER1, USER1, result.getLineDetails(0));
    replacedertLineDetails(f, 1, revision2, USER1, USER1, result.getLineDetails(1));
    replacedertLineDetails(f, 1, revision1, USER1, USER1, result.getLineDetails(2));
}

19 View Complete Implementation : RebaseTest.java
Copyright Apache License 2.0
Author : apache
public void testRebaseFailCheckoutLocalChanges() throws Exception {
    File f = new File(workDir, "file");
    write(f, "init");
    add(f);
    commit(f);
    GitClient client = getClient(workDir);
    client.createBranch(BRANCH_NAME, Constants.MASTER, NULL_PROGRESS_MONITOR);
    write(f, Constants.MASTER);
    add(f);
    GitRevisionInfo masterInfo = client.commit(new File[] { f }, "change on master", null, null, NULL_PROGRESS_MONITOR);
    client.checkoutRevision(BRANCH_NAME, true, NULL_PROGRESS_MONITOR);
    write(f, BRANCH_NAME);
    add(f);
    GitRevisionInfo branchInfo = client.commit(new File[] { f }, "change on branch", null, null, NULL_PROGRESS_MONITOR);
    write(f, "local change");
    GitRebaseResult result = client.rebase(RebaseOperationType.BEGIN, Constants.MASTER, NULL_PROGRESS_MONITOR);
    replacedertEquals(RebaseStatus.FAILED, result.getRebaseStatus());
    replacedertEquals(Arrays.asList(f), result.getFailures());
    replacedertEquals(branchInfo.getRevision(), getRepository(client).resolve(BRANCH_NAME).name());
    replacedertEquals(masterInfo.getRevision(), getRepository(client).resolve(Constants.MASTER).name());
    // resets HEAD
    replacedertEquals(branchInfo.getRevision(), getRepository(client).resolve(Constants.HEAD).name());
}

19 View Complete Implementation : LogTest.java
Copyright Apache License 2.0
Author : apache
public void testLogFiles() throws Exception {
    File f1 = new File(workDir, "file1");
    write(f1, "initial content");
    File f2 = new File(workDir, "file2");
    write(f2, "initial content");
    File f3 = new File(workDir, "file3");
    File[] files = new File[] { f1, f2 };
    add(files);
    GitClient client = getClient(workDir);
    commit(files);
    write(f1, "modification1");
    add(files);
    GitRevisionInfo revision1 = client.commit(files, "modification1", null, null, NULL_PROGRESS_MONITOR);
    write(f2, "modification2");
    add(files);
    GitRevisionInfo revision2 = client.commit(files, "modification2", null, null, NULL_PROGRESS_MONITOR);
    write(f1, "modification3");
    write(f2, "modification3");
    add(files);
    GitRevisionInfo revision3 = client.commit(files, "modification3", null, null, NULL_PROGRESS_MONITOR);
    write(f3, "modification4");
    add(new File[] { f3 });
    GitRevisionInfo revision4 = client.commit(new File[] { f3 }, "modification4", null, null, NULL_PROGRESS_MONITOR);
    SearchCriteria crit = new SearchCriteria();
    crit.setFiles(new File[] { f1 });
    crit.setRevisionFrom(revision1.getRevision());
    GitRevisionInfo[] revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(2, revisions.length);
    replacedertRevisions(revision3, revisions[0]);
    replacedertRevisions(revision1, revisions[1]);
    crit = new SearchCriteria();
    crit.setFiles(new File[] { f2 });
    crit.setRevisionFrom(revision1.getRevision());
    revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(2, revisions.length);
    replacedertRevisions(revision3, revisions[0]);
    replacedertRevisions(revision2, revisions[1]);
    crit = new SearchCriteria();
    crit.setFiles(files);
    crit.setRevisionFrom(revision1.getRevision());
    revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(3, revisions.length);
    replacedertRevisions(revision3, revisions[0]);
    replacedertRevisions(revision2, revisions[1]);
    replacedertRevisions(revision1, revisions[2]);
    crit = new SearchCriteria();
    crit.setFiles(new File[] { f1, f2, f3 });
    crit.setRevisionFrom(revision1.getRevision());
    revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(4, revisions.length);
    replacedertRevisions(revision4, revisions[0]);
    replacedertRevisions(revision3, revisions[1]);
    replacedertRevisions(revision2, revisions[2]);
    replacedertRevisions(revision1, revisions[3]);
    crit = new SearchCriteria();
    crit.setFiles(new File[] { workDir });
    crit.setRevisionFrom(revision1.getRevision());
    revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(4, revisions.length);
    replacedertRevisions(revision4, revisions[0]);
    replacedertRevisions(revision3, revisions[1]);
    replacedertRevisions(revision2, revisions[2]);
    replacedertRevisions(revision1, revisions[3]);
}

19 View Complete Implementation : SetUpstreamBranchTest.java
Copyright Apache License 2.0
Author : apache
public void testRemoteTracking() throws Exception {
    GitClient client = getClient(workDir);
    File f = new File(workDir, "f");
    add(f);
    client.commit(new File[] { f }, "init commit", null, null, NULL_PROGRESS_MONITOR);
    // push to remote
    String remoteUri = getRemoteRepository().getWorkTree().toURI().toString();
    client.setRemote(new GitRemoteConfig("origin", Arrays.asList(remoteUri), Collections.<String>emptyList(), Arrays.asList("+refs/heads/*:refs/remotes/origin/*"), Collections.<String>emptyList()), NULL_PROGRESS_MONITOR);
    client.push("origin", Arrays.asList("refs/heads/master:refs/heads/master"), Arrays.asList("+refs/heads/master:refs/remotes/origin/master"), NULL_PROGRESS_MONITOR);
    Map<String, GitBranch> branches = client.getBranches(true, NULL_PROGRESS_MONITOR);
    replacedertTrue(branches.containsKey("origin/master"));
    replacedertNull(branches.get("master").getTrackedBranch());
    StoredConfig config = repository.getConfig();
    config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, null, ConfigConstants.CONFIG_KEY_AUTOSETUPREBASE, ConfigConstants.CONFIG_KEY_NEVER);
    config.save();
    // set tracking
    GitBranch b = client.setUpstreamBranch("master", "origin/master", NULL_PROGRESS_MONITOR);
    replacedertEquals("origin/master", b.getTrackedBranch().getName());
    config = repository.getConfig();
    replacedertEquals("origin", config.getString(ConfigConstants.CONFIG_BRANCH_SECTION, "master", ConfigConstants.CONFIG_KEY_REMOTE));
    replacedertEquals("refs/heads/master", config.getString(ConfigConstants.CONFIG_BRANCH_SECTION, "master", ConfigConstants.CONFIG_KEY_MERGE));
    replacedertFalse(config.getBoolean(ConfigConstants.CONFIG_BRANCH_SECTION, "master", ConfigConstants.CONFIG_KEY_REBASE, false));
    // change autosetuprebase
    config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, null, ConfigConstants.CONFIG_KEY_AUTOSETUPREBASE, ConfigConstants.CONFIG_KEY_REMOTE);
    config.save();
    // set tracking
    b = client.setUpstreamBranch("master", "origin/master", NULL_PROGRESS_MONITOR);
    replacedertEquals("origin/master", b.getTrackedBranch().getName());
    config = repository.getConfig();
    replacedertEquals("origin", config.getString(ConfigConstants.CONFIG_BRANCH_SECTION, "master", ConfigConstants.CONFIG_KEY_REMOTE));
    replacedertEquals("refs/heads/master", config.getString(ConfigConstants.CONFIG_BRANCH_SECTION, "master", ConfigConstants.CONFIG_KEY_MERGE));
    replacedertTrue(config.getBoolean(ConfigConstants.CONFIG_BRANCH_SECTION, "master", ConfigConstants.CONFIG_KEY_REBASE, false));
}

19 View Complete Implementation : RebaseTest.java
Copyright Apache License 2.0
Author : apache
public void testRebaseNoChange() throws Exception {
    File f = new File(workDir, "file");
    write(f, "init");
    add(f);
    commit(f);
    GitClient client = getClient(workDir);
    String head = getRepository(client).resolve(Constants.HEAD).getName();
    GitBranch branch = client.createBranch(BRANCH_NAME, Constants.MASTER, NULL_PROGRESS_MONITOR);
    client.checkoutRevision(BRANCH_NAME, true, NULL_PROGRESS_MONITOR);
    // rebase branch to master
    GitRebaseResult result = client.rebase(RebaseOperationType.BEGIN, Constants.MASTER, NULL_PROGRESS_MONITOR);
    replacedertEquals(RebaseStatus.UP_TO_DATE, result.getRebaseStatus());
    replacedertEquals(head, result.getCurrentHead());
    // do a commit and
    write(f, "change");
    add(f);
    GitRevisionInfo commit = client.commit(new File[] { f }, "change on branch", null, null, NULL_PROGRESS_MONITOR);
    // rebase branch to master, they are now different but still no rebase is needed
    result = client.rebase(RebaseOperationType.BEGIN, Constants.MASTER, NULL_PROGRESS_MONITOR);
    replacedertEquals(RebaseStatus.UP_TO_DATE, result.getRebaseStatus());
    replacedertEquals(commit.getRevision(), result.getCurrentHead());
}

19 View Complete Implementation : LogTest.java
Copyright Apache License 2.0
Author : apache
public void testShortMessages() throws Exception {
    File f = new File(workDir, "f");
    write(f, "init");
    File[] files = new File[] { f };
    add(files);
    GitClient client = getClient(workDir);
    client.commit(files, "short message", null, null, NULL_PROGRESS_MONITOR);
    replacedertEquals("short message", client.log("HEAD", NULL_PROGRESS_MONITOR).getShortMessage());
    write(f, "m1");
    add(f);
    client.commit(files, "short message\n\n\n", null, null, NULL_PROGRESS_MONITOR);
    replacedertEquals("short message", client.log("HEAD", NULL_PROGRESS_MONITOR).getShortMessage());
    write(f, "m1");
    add(f);
    client.commit(files, "short message\nbla\nbla\nbla", null, null, NULL_PROGRESS_MONITOR);
    replacedertEquals("short message", client.log("HEAD", NULL_PROGRESS_MONITOR).getShortMessage());
}

19 View Complete Implementation : SetUpstreamBranchTest.java
Copyright Apache License 2.0
Author : apache
public void testRemoteTrackingNoRemoteSet() throws GitException {
    GitClient client = getClient(workDir);
    File f = new File(workDir, "f");
    add(f);
    client.commit(new File[] { f }, "init commit", null, null, NULL_PROGRESS_MONITOR);
    // push to remote
    String remoteUri = getRemoteRepository().getWorkTree().toURI().toString();
    client.push(remoteUri, Arrays.asList("refs/heads/master:refs/heads/master"), Arrays.asList("+refs/heads/*:refs/remotes/origin/*"), NULL_PROGRESS_MONITOR);
    Map<String, GitBranch> branches = client.getBranches(true, NULL_PROGRESS_MONITOR);
    replacedertTrue(branches.containsKey("origin/master"));
    replacedertNull(branches.get("master").getTrackedBranch());
    // set tracking
    GitBranch b = client.setUpstreamBranch("master", "origin/master", NULL_PROGRESS_MONITOR);
    replacedertEquals("origin/master", b.getTrackedBranch().getName());
    Config cfg = repository.getConfig();
    replacedertEquals(".", cfg.getString(ConfigConstants.CONFIG_BRANCH_SECTION, "master", ConfigConstants.CONFIG_KEY_REMOTE));
    replacedertEquals("refs/remotes/origin/master", cfg.getString(ConfigConstants.CONFIG_BRANCH_SECTION, "master", ConfigConstants.CONFIG_KEY_MERGE));
}

19 View Complete Implementation : LogTest.java
Copyright Apache License 2.0
Author : apache
public void testLogSingleBranch() throws Exception {
    File f = new File(workDir, "file");
    write(f, "initial content");
    File[] files = new File[] { f };
    add(files);
    GitClient client = getClient(workDir);
    GitRevisionInfo revision0 = client.commit(files, "initial commit", null, null, NULL_PROGRESS_MONITOR);
    write(f, "modification1");
    add(files);
    GitRevisionInfo revision1 = client.commit(files, "modification1", null, null, NULL_PROGRESS_MONITOR);
    write(new File(workDir, ".git/refs/heads/A"), revision1.getRevision());
    write(new File(workDir, ".git/refs/heads/B"), revision1.getRevision());
    write(new File(workDir, ".git/HEAD"), "ref: refs/heads/A");
    Thread.sleep(1000);
    write(f, "modificationOnA-1");
    add(files);
    GitRevisionInfo revisionA1 = client.commit(files, "modificationOnA-1", null, null, NULL_PROGRESS_MONITOR);
    // to B
    write(new File(workDir, ".git/HEAD"), "ref: refs/heads/B");
    client.reset(revision1.getRevision(), GitClient.ResetType.SOFT, NULL_PROGRESS_MONITOR);
    Thread.sleep(1000);
    write(f, "modificationOnB-1");
    add(files);
    GitRevisionInfo revisionB1 = client.commit(files, "modificationOnB-1", null, null, NULL_PROGRESS_MONITOR);
    // to A
    write(new File(workDir, ".git/HEAD"), "ref: refs/heads/A");
    client.reset(revisionA1.getRevision(), GitClient.ResetType.SOFT, NULL_PROGRESS_MONITOR);
    Thread.sleep(1000);
    write(f, "modificationOnA-2");
    add(files);
    GitRevisionInfo revisionA2 = client.commit(files, "modificationOnA-2", null, null, NULL_PROGRESS_MONITOR);
    // to B
    write(new File(workDir, ".git/HEAD"), "ref: refs/heads/B");
    client.reset(revisionB1.getRevision(), GitClient.ResetType.SOFT, NULL_PROGRESS_MONITOR);
    Thread.sleep(1000);
    write(f, "modificationOnB-2");
    add(files);
    GitRevisionInfo revisionB2 = client.commit(files, "modificationOnB-2", null, null, NULL_PROGRESS_MONITOR);
    SearchCriteria crit = new SearchCriteria();
    crit.setRevisionTo("A");
    GitRevisionInfo[] revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(4, revisions.length);
    replacedertRevisions(revisionA2, revisions[0]);
    replacedertRevisions(revisionA1, revisions[1]);
    replacedertRevisions(revision1, revisions[2]);
    replacedertRevisions(revision0, revisions[3]);
    crit = new SearchCriteria();
    crit.setRevisionTo("B");
    revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(4, revisions.length);
    replacedertRevisions(revisionB2, revisions[0]);
    replacedertRevisions(revisionB1, revisions[1]);
    replacedertRevisions(revision1, revisions[2]);
    replacedertRevisions(revision0, revisions[3]);
    // try both branches, how are the revisions sorted?
    revisions = client.log(new SearchCriteria(), true, NULL_PROGRESS_MONITOR);
    replacedertEquals(6, revisions.length);
    replacedertRevisions(revisionB2, revisions[0]);
    replacedertRevisions(revisionA2, revisions[1]);
    replacedertRevisions(revisionB1, revisions[2]);
    replacedertRevisions(revisionA1, revisions[3]);
    replacedertRevisions(revision1, revisions[4]);
    replacedertRevisions(revision0, revisions[5]);
}

19 View Complete Implementation : TagTest.java
Copyright Apache License 2.0
Author : apache
public void testCreateTag() throws Exception {
    File f = new File(workDir, "f");
    File[] files = new File[] { f };
    GitClient client = getClient(workDir);
    write(f, "init");
    GitRevisionInfo commit = client.commit(files, "init commit", null, null, NULL_PROGRESS_MONITOR);
    GitTag tag = client.createTag("tag-name", commit.getRevision(), "tag message\nfor tag-name", false, false, NULL_PROGRESS_MONITOR);
    replacedertTag(tag, commit.getRevision(), "tag-name", "tag message\nfor tag-name", client.getUser(), GitObjectType.COMMIT, false);
}

19 View Complete Implementation : LogTest.java
Copyright Apache License 2.0
Author : apache
public void testLogMessage() throws Exception {
    File f = new File(workDir, "f");
    write(f, "initial content");
    File[] files = new File[] { f };
    add(files);
    commit(files);
    write(f, "modification1");
    add(files);
    GitClient client = getClient(workDir);
    GitRevisionInfo revision1 = client.commit(files, "modification1\non master", null, null, NULL_PROGRESS_MONITOR);
    SearchCriteria crit = new SearchCriteria();
    GitRevisionInfo[] revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(2, revisions.length);
    crit = new SearchCriteria();
    crit.setMessage("blablabla");
    revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(0, revisions.length);
    crit = new SearchCriteria();
    crit.setMessage("modification");
    revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(1, revisions.length);
    replacedertRevisions(revision1, revisions[0]);
    crit = new SearchCriteria();
    crit.setMessage("modification1\non master");
    revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(1, revisions.length);
    replacedertRevisions(revision1, revisions[0]);
    // see bug #228905
    crit = new SearchCriteria();
    crit.setMessage("on master");
    revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(1, revisions.length);
    replacedertRevisions(revision1, revisions[0]);
}

19 View Complete Implementation : LogTest.java
Copyright Apache License 2.0
Author : apache
public void testLogRevisionRange() throws Exception {
    File f = new File(workDir, "testcat1");
    write(f, "initial content");
    File[] files = new File[] { f };
    add(files);
    commit(files);
    write(f, "modification1");
    add(files);
    GitClient client = getClient(workDir);
    GitRevisionInfo revision1 = client.commit(files, "modification1", null, null, NULL_PROGRESS_MONITOR);
    write(f, "modification2");
    add(files);
    GitRevisionInfo revision2 = client.commit(files, "modification2", null, null, NULL_PROGRESS_MONITOR);
    write(f, "modification3");
    add(files);
    GitRevisionInfo revision3 = client.commit(files, "modification3", null, null, NULL_PROGRESS_MONITOR);
    SearchCriteria crit = new SearchCriteria();
    crit.setRevisionFrom(revision2.getRevision());
    crit.setRevisionTo(revision3.getRevision());
    GitRevisionInfo[] revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(2, revisions.length);
    replacedertRevisions(revision3, revisions[0]);
    replacedertRevisions(revision2, revisions[1]);
    write(f, "modification4");
    add(files);
    GitRevisionInfo revision4 = client.commit(files, "modification4", null, null, NULL_PROGRESS_MONITOR);
    crit = new SearchCriteria();
    crit.setRevisionFrom(revision2.getRevision());
    crit.setRevisionTo(revision4.getRevision());
    revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(3, revisions.length);
    replacedertRevisions(revision4, revisions[0]);
    replacedertRevisions(revision3, revisions[1]);
    replacedertRevisions(revision2, revisions[2]);
}

19 View Complete Implementation : BlameTest.java
Copyright Apache License 2.0
Author : apache
public void testBlameNullForModifiedLines() throws Exception {
    File f = new File(workDir, "f");
    write(f, "aaa\nbbb\n");
    File[] files = { f };
    add(files);
    GitClient client = getClient(workDir);
    String revision1 = client.commit(files, "initial commit", USER1, USER1, NULL_PROGRESS_MONITOR).getRevision();
    write(f, "aaa\nccc\n");
    GitBlameResult result = client.blame(f, null, NULL_PROGRESS_MONITOR);
    replacedertEquals(f, result.getBlamedFile());
    replacedertLineDetails(f, 0, revision1, USER1, USER1, result.getLineDetails(0));
    replacedertNull(result.getLineDetails(1));
    add(files);
    result = client.blame(f, null, NULL_PROGRESS_MONITOR);
    replacedertEquals(f, result.getBlamedFile());
    replacedertLineDetails(f, 0, revision1, USER1, USER1, result.getLineDetails(0));
    replacedertNull(result.getLineDetails(1));
    write(f, "aaa\nbbb\n");
    result = client.blame(f, null, NULL_PROGRESS_MONITOR);
    replacedertEquals(f, result.getBlamedFile());
    replacedertLineDetails(f, 0, revision1, USER1, USER1, result.getLineDetails(0));
    replacedertNull(result.getLineDetails(1));
}

19 View Complete Implementation : LogTest.java
Copyright Apache License 2.0
Author : apache
public void testLogRevision() throws Exception {
    File f = new File(workDir, "testcat1");
    write(f, "initial content");
    File[] files = new File[] { f };
    add(files);
    GitClient client = getClient(workDir);
    GitRevisionInfo revision1 = client.commit(files, "commit1", null, null, NULL_PROGRESS_MONITOR);
    GitRevisionInfo revision = client.log(revision1.getRevision(), NULL_PROGRESS_MONITOR);
    replacedertRevisions(revision1, revision);
    write(f, "modification");
    add(files);
    GitRevisionInfo revision2 = client.commit(files, "commit2", null, null, NULL_PROGRESS_MONITOR);
    revision = client.log(revision1.getRevision(), NULL_PROGRESS_MONITOR);
    replacedertRevisions(revision1, revision);
    revision = client.log(revision2.getRevision(), NULL_PROGRESS_MONITOR);
    replacedertRevisions(revision2, revision);
}

19 View Complete Implementation : LogTest.java
Copyright Apache License 2.0
Author : apache
public void testLogDateCriteria() throws Exception {
    File f = new File(workDir, "f");
    write(f, "initial content");
    File[] files = new File[] { f };
    add(files);
    commit(files);
    write(f, "modification1");
    add(files);
    GitClient client = getClient(workDir);
    GitRevisionInfo revision1 = client.commit(files, "modification1", null, null, NULL_PROGRESS_MONITOR);
    Thread.sleep(1100);
    write(f, "modification2");
    add(files);
    GitRevisionInfo revision2 = client.commit(files, "modification2", null, null, NULL_PROGRESS_MONITOR);
    Thread.sleep(1100);
    write(f, "modification3");
    add(files);
    GitRevisionInfo revision3 = client.commit(files, "modification3", null, null, NULL_PROGRESS_MONITOR);
    SearchCriteria crit = new SearchCriteria();
    crit.setFrom(new Date(revision2.getCommitTime()));
    crit.setTo(new Date(revision3.getCommitTime()));
    GitRevisionInfo[] revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(2, revisions.length);
    replacedertRevisions(revision3, revisions[0]);
    replacedertRevisions(revision2, revisions[1]);
    Thread.sleep(1100);
    write(f, "modification4");
    add(files);
    GitRevisionInfo revision4 = client.commit(files, "modification4", null, null, NULL_PROGRESS_MONITOR);
    crit = new SearchCriteria();
    crit.setFrom(new Date(revision2.getCommitTime()));
    crit.setTo(new Date(revision3.getCommitTime()));
    revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(2, revisions.length);
    replacedertRevisions(revision3, revisions[0]);
    replacedertRevisions(revision2, revisions[1]);
    crit = new SearchCriteria();
    crit.setFrom(new Date(revision2.getCommitTime()));
    crit.setTo(new Date(revision4.getCommitTime()));
    revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(3, revisions.length);
    replacedertRevisions(revision4, revisions[0]);
    replacedertRevisions(revision3, revisions[1]);
    replacedertRevisions(revision2, revisions[2]);
    crit = new SearchCriteria();
    crit.setFrom(new Date(revision2.getCommitTime()));
    revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
    replacedertEquals(3, revisions.length);
    replacedertRevisions(revision4, revisions[0]);
    replacedertRevisions(revision3, revisions[1]);
    replacedertRevisions(revision2, revisions[2]);
}

19 View Complete Implementation : RebaseTest.java
Copyright Apache License 2.0
Author : apache
public void testRebaseFailMergeLocalChanges() throws Exception {
    File f = new File(workDir, "file");
    File f2 = new File(workDir, "file2");
    write(f, "init");
    write(f2, "init");
    add(f, f2);
    commit(f, f2);
    GitClient client = getClient(workDir);
    client.createBranch(BRANCH_NAME, Constants.MASTER, NULL_PROGRESS_MONITOR);
    write(f, Constants.MASTER);
    add(f);
    GitRevisionInfo masterInfo = client.commit(new File[] { f, f2 }, "change on master", null, null, NULL_PROGRESS_MONITOR);
    client.checkoutRevision(BRANCH_NAME, true, NULL_PROGRESS_MONITOR);
    write(f, BRANCH_NAME);
    add(f);
    GitRevisionInfo branchInfo = client.commit(new File[] { f, f2 }, "change on branch", null, null, NULL_PROGRESS_MONITOR);
    write(f2, "local change");
    add(f2);
    GitRebaseResult result = client.rebase(RebaseOperationType.BEGIN, Constants.MASTER, NULL_PROGRESS_MONITOR);
    replacedertEquals(RebaseStatus.FAILED, result.getRebaseStatus());
    replacedertEquals(Arrays.asList(f2), result.getFailures());
    replacedertEquals(branchInfo.getRevision(), getRepository(client).resolve(BRANCH_NAME).name());
    replacedertEquals(masterInfo.getRevision(), getRepository(client).resolve(Constants.MASTER).name());
    // resets HEAD
    replacedertEquals(branchInfo.getRevision(), getRepository(client).resolve(Constants.HEAD).name());
}

18 View Complete Implementation : HistoryTest.java
Copyright Apache License 2.0
Author : apache
public void testHistoryProviderBranches() throws Exception {
    File f = new File(repositoryLocation, "file");
    write(f, "a\nb\nc\nd\n");
    File[] roots = new File[] { f };
    GitClient client = getClient(repositoryLocation);
    client.add(roots, GitUtils.NULL_PROGRESS_MONITOR);
    GitRevisionInfo revBase = client.commit(roots, "base commit", new GitUser("author", "[email protected]"), null, GitUtils.NULL_PROGRESS_MONITOR);
    Thread.sleep(1100);
    // new branch
    client.createBranch("branch", "master", GitUtils.NULL_PROGRESS_MONITOR);
    // change on master
    write(f, "x\nb\nc\nd\n");
    client.add(roots, GitUtils.NULL_PROGRESS_MONITOR);
    GitRevisionInfo revMaster = client.commit(roots, "master commit", new GitUser("author2", "[email protected]"), null, GitUtils.NULL_PROGRESS_MONITOR);
    Thread.sleep(1100);
    client.checkoutRevision("branch", true, GitUtils.NULL_PROGRESS_MONITOR);
    // change on branch
    write(f, "a\nb\nc\nz\n");
    client.add(roots, GitUtils.NULL_PROGRESS_MONITOR);
    GitRevisionInfo revBranch = client.commit(roots, "branch commit", new GitUser("author3", "[email protected]"), null, GitUtils.NULL_PROGRESS_MONITOR);
    Thread.sleep(1100);
    // back to master
    client.checkoutRevision("master", true, GitUtils.NULL_PROGRESS_MONITOR);
    // history displayed only for the current branch
    VCSHistoryProvider p = VersioningSupport.getOwner(f).getVCSHistoryProvider();
    replacedertTrue(p instanceof HistoryProvider);
    VCSHistoryProvider.HistoryEntry[] entries = p.getHistory(new File[] { f }, new Date(0));
    replacedertEquals(2, entries.length);
    replacedertEntry(revMaster, entries[0]);
    replacedertEntry(revBase, entries[1]);
    replacedertNull(entries[1].getParentEntry(f));
    replacedertEntry(entries[1], entries[0].getParentEntry(f));
    // let's merge and test the merge
    GitMergeResult mergeResult = client.merge("branch", GitUtils.NULL_PROGRESS_MONITOR);
    Thread.sleep(100);
    GitRevisionInfo revMerge = client.log(mergeResult.getNewHead(), GitUtils.NULL_PROGRESS_MONITOR);
    entries = p.getHistory(new File[] { f }, new Date(0));
    // merges are not displayed in history tab
    replacedertEquals(3, entries.length);
    replacedertEntry(revBranch, entries[0]);
    replacedertEntry(revMaster, entries[1]);
    replacedertEntry(revBase, entries[2]);
    replacedertNull(entries[2].getParentEntry(f));
    replacedertEntry(entries[2], entries[0].getParentEntry(f));
    replacedertEntry(entries[2], entries[1].getParentEntry(f));
}

18 View Complete Implementation : HistoryTest.java
Copyright Apache License 2.0
Author : apache
public void testHistoryProviderSimple() throws Exception {
    File f = new File(repositoryLocation, "file");
    write(f, "a\nb\nc\nd\n");
    File[] roots = new File[] { f };
    GitClient client = getClient(repositoryLocation);
    client.add(roots, GitUtils.NULL_PROGRESS_MONITOR);
    GitRevisionInfo rev1 = client.commit(roots, "first commit", new GitUser("author", "[email protected]"), null, GitUtils.NULL_PROGRESS_MONITOR);
    Thread.sleep(1100);
    write(f, "a\nb\nc\nd\ne\n");
    client.add(roots, GitUtils.NULL_PROGRESS_MONITOR);
    GitRevisionInfo rev2 = client.commit(roots, "second commit", new GitUser("author2", "[email protected]"), null, GitUtils.NULL_PROGRESS_MONITOR);
    Thread.sleep(1100);
    VCSHistoryProvider p = VersioningSupport.getOwner(f).getVCSHistoryProvider();
    replacedertTrue(p instanceof HistoryProvider);
    VCSHistoryProvider.HistoryEntry[] entries = p.getHistory(new File[] { f }, new Date(0));
    replacedertEquals(2, entries.length);
    replacedertEntry(rev2, entries[0]);
    replacedertEntry(rev1, entries[1]);
    replacedertNull(entries[1].getParentEntry(f));
    replacedertEntry(entries[1], entries[0].getParentEntry(f));
}

18 View Complete Implementation : RepositoryInfoTest.java
Copyright Apache License 2.0
Author : apache
public void testChangeHead() throws Exception {
    File f = new File(repositoryLocation, "file");
    File[] roots = new File[] { f };
    GitClient client = getClient(repositoryLocation);
    client.add(roots, GitUtils.NULL_PROGRESS_MONITOR);
    GitRevisionInfo revInfo = client.commit(roots, "bla", null, null, GitUtils.NULL_PROGRESS_MONITOR);
    RepositoryInfo info = RepositoryInfo.getInstance(repositoryLocation);
    info.refresh();
    replacedertEquals(revInfo.getRevision(), info.getActiveBranch().getId());
    // test property support
    GitBranch oldBranch = info.getActiveBranch();
    RepositoryInfoListener list = new RepositoryInfoListener();
    info.addPropertyChangeListener(list);
    write(f, "huhu 2");
    client.add(roots, GitUtils.NULL_PROGRESS_MONITOR);
    revInfo = client.commit(roots, "bla", null, null, GitUtils.NULL_PROGRESS_MONITOR);
    info.refresh();
    replacedertEquals(revInfo.getRevision(), info.getActiveBranch().getId());
    list.replacedertPropertyEvent(RepositoryInfo.PROPERTY_HEAD, oldBranch, info.getActiveBranch());
}

18 View Complete Implementation : RepositoryInfoTest.java
Copyright Apache License 2.0
Author : apache
public void testChangeBranch() throws Exception {
    File f = new File(repositoryLocation, "file");
    File[] roots = new File[] { f };
    GitClient client = getClient(repositoryLocation);
    RepositoryInfo info = RepositoryInfo.getInstance(repositoryLocation);
    info.refresh();
    replacedertEquals(GitBranch.NO_BRANCH, info.getActiveBranch().getName());
    replacedertEquals(AbstractGitTestCase.NULL_OBJECT_ID, info.getActiveBranch().getId());
    client.add(roots, GitUtils.NULL_PROGRESS_MONITOR);
    // test property support
    GitBranch oldBranch = info.getActiveBranch();
    RepositoryInfoListener list = new RepositoryInfoListener();
    info.addPropertyChangeListener(list);
    write(f, "huhu");
    client.add(roots, GitUtils.NULL_PROGRESS_MONITOR);
    client.commit(roots, "bla", null, null, GitUtils.NULL_PROGRESS_MONITOR);
    info.refresh();
    list.replacedertPropertyEvent(RepositoryInfo.PROPERTY_ACTIVE_BRANCH, oldBranch, info.getActiveBranch());
}

18 View Complete Implementation : RepositoryInfoTest.java
Copyright Apache License 2.0
Author : apache
public void testRefresh() throws Exception {
    File f = new File(repositoryLocation, "file");
    File[] roots = new File[] { f };
    GitClient client = getClient(repositoryLocation);
    client.add(roots, GitUtils.NULL_PROGRESS_MONITOR);
    GitRevisionInfo revInfo = client.commit(roots, "bla", null, null, GitUtils.NULL_PROGRESS_MONITOR);
    RepositoryInfo info = RepositoryInfo.getInstance(repositoryLocation);
    info.refresh();
    replacedertEquals(revInfo.getRevision(), info.getActiveBranch().getId());
    // test refresh
    write(f, "huhu 1");
    client.add(roots, GitUtils.NULL_PROGRESS_MONITOR);
    revInfo = client.commit(roots, "bla", null, null, GitUtils.NULL_PROGRESS_MONITOR);
    info.refresh();
    replacedertEquals(revInfo.getRevision(), info.getActiveBranch().getId());
}

18 View Complete Implementation : BlameTest.java
Copyright Apache License 2.0
Author : apache
public void testBlameMixedLineEndings() throws Exception {
    File f = new File(workDir, "f");
    String content = "";
    for (int i = 0; i < 10000; ++i) {
        content += i + "\r\n";
    }
    write(f, content);
    // lets turn autocrlf on
    StoredConfig cfg = repository.getConfig();
    cfg.setString(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_AUTOCRLF, "true");
    cfg.save();
    File[] files = new File[] { f };
    GitClient client = getClient(workDir);
    client.add(files, NULL_PROGRESS_MONITOR);
    GitRevisionInfo info = client.commit(files, "commit", null, null, NULL_PROGRESS_MONITOR);
    content = content.replaceFirst("0", "01");
    write(f, content);
    // it should be up to date again
    org.eclipse.jgit.api.BlameCommand cmd = new Git(repository).blame();
    cmd.setFilePath("f");
    BlameResult blameResult = cmd.call();
    replacedertEquals(info.getRevision(), blameResult.getSourceCommit(1).getName());
    GitBlameResult res = client.blame(f, null, NULL_PROGRESS_MONITOR);
    replacedertNull(res.getLineDetails(0));
    replacedertLineDetails(f, 1, info.getRevision(), info.getAuthor(), info.getCommitter(), res.getLineDetails(1));
    // without autocrlf it should all be modified
    cfg.setString(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_AUTOCRLF, "false");
    cfg.save();
    res = client.blame(f, null, NULL_PROGRESS_MONITOR);
    replacedertNull(res.getLineDetails(1));
}

18 View Complete Implementation : BranchTest.java
Copyright Apache License 2.0
Author : apache
public void testListBranches_Issue213538() throws Exception {
    GitClient client = getClient(workDir);
    File f = new File(workDir, "f");
    write(f, "init");
    client.add(new File[] { f }, NULL_PROGRESS_MONITOR);
    client.commit(new File[] { f }, "init commit", null, null, NULL_PROGRESS_MONITOR);
    // cannot end with a RuntimeException
    File configFile = new File(Utils.getMetadataFolder(workDir), Constants.CONFIG);
    String config = read(configFile);
    config += "\n\tbla:\n";
    write(configFile, config);
    Thread.sleep(1100);
    try {
        client.getBranches(false, NULL_PROGRESS_MONITOR);
    } catch (GitException ex) {
        replacedertEquals("It seems the config file for repository at [" + workDir + "] is corrupted.\nEnsure it's valid.", ex.getMessage());
    }
}

18 View Complete Implementation : BranchTest.java
Copyright Apache License 2.0
Author : apache
public void testBranchTracking() throws Exception {
    final File otherWT = new File(workDir.getParentFile(), "repo2");
    GitClient client = getClient(otherWT);
    client.init(NULL_PROGRESS_MONITOR);
    File f = new File(otherWT, "f");
    write(f, "init");
    client.add(new File[] { f }, NULL_PROGRESS_MONITOR);
    client.commit(new File[] { f }, "init commit", null, null, NULL_PROGRESS_MONITOR);
    client = getClient(workDir);
    client.setRemote(new GitRemoteConfig("origin", Arrays.asList(otherWT.getAbsolutePath()), Arrays.asList(otherWT.getAbsolutePath()), Arrays.asList("+refs/heads/*:refs/remotes/origin/*"), Collections.<String>emptyList()), NULL_PROGRESS_MONITOR);
    client.fetch("origin", NULL_PROGRESS_MONITOR);
    GitBranch b = client.createBranch(Constants.MASTER, "origin/master", NULL_PROGRESS_MONITOR);
    replacedertEquals("origin/master", b.getTrackedBranch().getName());
    replacedertTrue(b.getTrackedBranch().isRemote());
    client.checkoutRevision(Constants.MASTER, true, NULL_PROGRESS_MONITOR);
    b = client.createBranch("nova1", Constants.MASTER, NULL_PROGRESS_MONITOR);
    replacedertNull(b.getTrackedBranch());
    StoredConfig cfg = repository.getConfig();
    cfg.setString(ConfigConstants.CONFIG_BRANCH_SECTION, null, ConfigConstants.CONFIG_KEY_AUTOSETUPMERGE, "always");
    cfg.save();
    b = client.createBranch("nova2", Constants.MASTER, NULL_PROGRESS_MONITOR);
    replacedertEquals("master", b.getTrackedBranch().getName());
    replacedertFalse(b.getTrackedBranch().isRemote());
    // list branches
    Map<String, GitBranch> branches = client.getBranches(true, NULL_PROGRESS_MONITOR);
    b = branches.get(Constants.MASTER);
    replacedertEquals("origin/master", b.getTrackedBranch().getName());
    replacedertTrue(b.getTrackedBranch().isRemote());
    b = branches.get("origin/master");
    replacedertNull(b.getTrackedBranch());
}

18 View Complete Implementation : BranchTest.java
Copyright Apache License 2.0
Author : apache
public void testListBranches() throws Exception {
    GitClient client = getClient(workDir);
    Map<String, GitBranch> branches = client.getBranches(false, NULL_PROGRESS_MONITOR);
    replacedertEquals(0, branches.size());
    File f = new File(workDir, "file");
    write(f, "hello");
    File[] files = new File[] { f };
    client.add(files, NULL_PROGRESS_MONITOR);
    client.commit(files, "init", null, null, NULL_PROGRESS_MONITOR);
    write(f, "hello again");
    client.commit(files, "change", null, null, NULL_PROGRESS_MONITOR);
    Iterator<RevCommit> it = new Git(repository).log().call().iterator();
    RevCommit info = it.next();
    String commitId = info.getId().getName();
    branches = client.getBranches(true, NULL_PROGRESS_MONITOR);
    replacedertEquals(1, branches.size());
    replacedertEquals("master", branches.get("master").getName());
    replacedertEquals(commitId, branches.get("master").getId());
    replacedertFalse(branches.get("master").isRemote());
    replacedertTrue(branches.get("master").isActive());
    write(new File(workDir, ".git/refs/heads/nova"), commitId);
    branches = client.getBranches(true, NULL_PROGRESS_MONITOR);
    replacedertEquals(2, branches.size());
    replacedertEquals("master", branches.get("master").getName());
    replacedertFalse(branches.get("master").isRemote());
    replacedertTrue(branches.get("master").isActive());
    replacedertEquals(commitId, branches.get("master").getId());
    replacedertEquals("nova", branches.get("nova").getName());
    replacedertFalse(branches.get("nova").isRemote());
    replacedertFalse(branches.get("nova").isActive());
    replacedertEquals(commitId, branches.get("nova").getId());
    Thread.sleep(1100);
    write(new File(workDir, ".git/HEAD"), commitId);
    branches = client.getBranches(true, NULL_PROGRESS_MONITOR);
    replacedertEquals(3, branches.size());
    replacedertEquals(GitBranch.NO_BRANCH, branches.get(GitBranch.NO_BRANCH).getName());
    replacedertFalse(branches.get(GitBranch.NO_BRANCH).isRemote());
    replacedertTrue(branches.get(GitBranch.NO_BRANCH).isActive());
    replacedertEquals(commitId, branches.get(GitBranch.NO_BRANCH).getId());
    replacedertEquals("master", branches.get("master").getName());
    replacedertFalse(branches.get("master").isRemote());
    replacedertFalse(branches.get("master").isActive());
    replacedertEquals("nova", branches.get("nova").getName());
    replacedertFalse(branches.get("nova").isRemote());
    replacedertFalse(branches.get("nova").isActive());
}

18 View Complete Implementation : BranchTest.java
Copyright Apache License 2.0
Author : apache
public void testDeleteRemoteBranch() throws Exception {
    final File otherWT = new File(workDir.getParentFile(), "repo2");
    GitClient client = getClient(otherWT);
    client.init(NULL_PROGRESS_MONITOR);
    File f = new File(otherWT, "f");
    write(f, "init");
    client.add(new File[] { f }, NULL_PROGRESS_MONITOR);
    client.commit(new File[] { f }, "init commit", null, null, NULL_PROGRESS_MONITOR);
    client = getClient(workDir);
    client.fetch(otherWT.getAbsolutePath(), Arrays.asList(new String[] { "refs/heads/*:refs/remotes/origin/*" }), NULL_PROGRESS_MONITOR);
    Map<String, GitBranch> branches = client.getBranches(true, NULL_PROGRESS_MONITOR);
    replacedertEquals(1, branches.size());
    replacedertNotNull(branches.get("origin/master"));
    // delete remote branch
    client.deleteBranch("origin/master", false, NULL_PROGRESS_MONITOR);
    branches = client.getBranches(false, NULL_PROGRESS_MONITOR);
    replacedertEquals(0, branches.size());
}

18 View Complete Implementation : BranchTest.java
Copyright Apache License 2.0
Author : apache
public void testDeleteTrackedBranch() throws Exception {
    final File otherWT = new File(workDir.getParentFile(), "repo2");
    GitClient client = getClient(otherWT);
    client.init(NULL_PROGRESS_MONITOR);
    File f = new File(otherWT, "f");
    write(f, "init");
    client.add(new File[] { f }, NULL_PROGRESS_MONITOR);
    client.commit(new File[] { f }, "init commit", null, null, NULL_PROGRESS_MONITOR);
    client = getClient(workDir);
    client.setRemote(new GitRemoteConfig("origin", Arrays.asList(new String[] { otherWT.getAbsolutePath() }), Arrays.asList(new String[] { otherWT.getAbsolutePath() }), Arrays.asList(new String[] { "refs/heads/*:refs/remotes/origin/*" }), Arrays.asList(new String[] { "refs/remotes/origin/*:refs/heads/*" })), NULL_PROGRESS_MONITOR);
    client.fetch("origin", NULL_PROGRESS_MONITOR);
    client.checkoutRevision("origin/master", true, NULL_PROGRESS_MONITOR);
    GitBranch b = client.createBranch(BRANCH_NAME, "origin/master", NULL_PROGRESS_MONITOR);
    Map<String, GitBranch> branches = client.getBranches(false, NULL_PROGRESS_MONITOR);
    replacedertEquals(2, branches.size());
    replacedertNotNull(branches.get(BRANCH_NAME));
    replacedertEquals(1, repository.getConfig().getSubsections(ConfigConstants.CONFIG_BRANCH_SECTION).size());
    // delete tracked branch and test
    client.deleteBranch(BRANCH_NAME, false, NULL_PROGRESS_MONITOR);
    branches = client.getBranches(false, NULL_PROGRESS_MONITOR);
    replacedertEquals(1, branches.size());
    replacedertNull(branches.get(BRANCH_NAME));
    replacedertEquals(0, repository.getConfig().getSubsections(ConfigConstants.CONFIG_BRANCH_SECTION).size());
}

18 View Complete Implementation : BranchTest.java
Copyright Apache License 2.0
Author : apache
public void testCreateBranchWithRebase() throws Exception {
    final File otherWT = new File(workDir.getParentFile(), "repo2");
    GitClient client = getClient(otherWT);
    client.init(NULL_PROGRESS_MONITOR);
    File f = new File(otherWT, "f");
    write(f, "init");
    client.add(new File[] { f }, NULL_PROGRESS_MONITOR);
    client.commit(new File[] { f }, "init commit", null, null, NULL_PROGRESS_MONITOR);
    client = getClient(workDir);
    client.setRemote(new GitRemoteConfig("origin", Arrays.asList(new String[] { otherWT.getAbsolutePath() }), Arrays.asList(new String[] { otherWT.getAbsolutePath() }), Arrays.asList(new String[] { "refs/heads/*:refs/remotes/origin/*" }), Arrays.asList(new String[] { "refs/remotes/origin/*:refs/heads/*" })), NULL_PROGRESS_MONITOR);
    client.fetch("origin", NULL_PROGRESS_MONITOR);
    StoredConfig config = repository.getConfig();
    config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, null, ConfigConstants.CONFIG_KEY_AUTOSETUPREBASE, ConfigConstants.CONFIG_KEY_NEVER);
    config.save();
    GitBranch b = client.createBranch(BRANCH_NAME, "origin/master", NULL_PROGRESS_MONITOR);
    replacedertFalse(repository.getConfig().getBoolean(ConfigConstants.CONFIG_BRANCH_SECTION, BRANCH_NAME, ConfigConstants.CONFIG_KEY_REBASE, false));
    client.deleteBranch(BRANCH_NAME, true, NULL_PROGRESS_MONITOR);
    config = repository.getConfig();
    config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, null, ConfigConstants.CONFIG_KEY_AUTOSETUPREBASE, ConfigConstants.CONFIG_KEY_REMOTE);
    config.save();
    b = client.createBranch(BRANCH_NAME, "origin/master", NULL_PROGRESS_MONITOR);
    replacedertTrue(repository.getConfig().getBoolean(ConfigConstants.CONFIG_BRANCH_SECTION, BRANCH_NAME, ConfigConstants.CONFIG_KEY_REBASE, false));
}

18 View Complete Implementation : BranchTest.java
Copyright Apache License 2.0
Author : apache
public void testListRemoteBranches() throws Exception {
    File otherWT = new File(workDir.getParentFile(), "repo2");
    GitClient client = getClient(otherWT);
    client.init(NULL_PROGRESS_MONITOR);
    File f = new File(otherWT, "f");
    write(f, "init");
    client.add(new File[] { f }, NULL_PROGRESS_MONITOR);
    client.commit(new File[] { f }, "init commit", null, null, NULL_PROGRESS_MONITOR);
    GitBranch branch = client.createBranch(BRANCH_NAME, "master", NULL_PROGRESS_MONITOR);
    write(f, "change on master");
    client.add(new File[] { f }, NULL_PROGRESS_MONITOR);
    GitRevisionInfo master = client.commit(new File[] { f }, "change on master", null, null, NULL_PROGRESS_MONITOR);
    Map<String, GitBranch> remoteBranches = getClient(workDir).listRemoteBranches(otherWT.getAbsolutePath(), NULL_PROGRESS_MONITOR);
    replacedertEquals(2, remoteBranches.size());
    replacedertEquals(branch.getId(), remoteBranches.get(BRANCH_NAME).getId());
    replacedertEquals(master.getRevision(), remoteBranches.get("master").getId());
}