Package org.eclipse.jgit.api

Examples of org.eclipse.jgit.api.Git.rm()


  protected RevCommit mv(File repo, String from, String to, String message)
      throws Exception {
    File file = new File(repo.getParentFile(), from);
    file.renameTo(new File(repo.getParentFile(), to));
    Git git = Git.open(repo);
    git.rm().addFilepattern(from);
    git.add().addFilepattern(to).call();
    RevCommit commit = git.commit().setAll(true).setMessage(message)
        .setAuthor(author).setCommitter(committer).call();
    assertNotNull(commit);
    return commit;
View Full Code Here


   */
  protected RevCommit delete(String path) throws Exception {
    String message = MessageFormat.format("Committing {0} at {1}", path,
        new Date());
    Git git = Git.open(testRepo);
    git.rm().addFilepattern(path).call();
    RevCommit commit = git.commit().setOnly(path).setMessage(message)
        .setAuthor(author).setCommitter(committer).call();
    assertNotNull(commit);
    return commit;
  }
View Full Code Here

    // rename it
    writeTrashFile(FILENAME_2, join(content1));
    git.add().addFilepattern(FILENAME_2).call();
    deleteTrashFile(FILENAME_1);
    git.rm().addFilepattern(FILENAME_1).call();
    git.commit().setMessage("rename file1.txt to file2.txt").call();

    // and change the new file
    String[] content2 = new String[] { "third", "first", "second" };
    writeTrashFile(FILENAME_2, join(content2));
View Full Code Here

    writeTrashFile("x", "x");
    git.add().addFilepattern("x").call();
    RevCommit id1 = git.commit().setMessage("c1").call();

    writeTrashFile("f/g", "f/g");
    git.rm().addFilepattern("x").call();
    git.add().addFilepattern("f/g").call();
    git.commit().setMessage("c2").call();
    deleteTrashFile("f/g");
    deleteTrashFile("f");
View Full Code Here

    git.add().addFilepattern(fname).call();
    git.commit().setMessage("modify file").call();

    // Switch branches
    git.checkout().setName("side").call();
    git.rm().addFilepattern(fname).call();
    writeTrashFile(".gitignore", fname);
    git.add().addFilepattern(".gitignore").call();
    git.commit().setMessage("delete and ignore file").call();

    writeTrashFile(fname, "Something different");
View Full Code Here

    git.add().addFilepattern("a.txt").addFilepattern("b.txt").call();
    RevCommit first = git.commit().setMessage("added a.txt, b.txt").call();

    // modify and delete files on the master branch
    writeTrashFile("a.txt", "master");
    git.rm().addFilepattern("b.txt").call();
    RevCommit masterCommit = git.commit()
        .setMessage("modified a.txt, deleted b.txt").setAll(true)
        .call();

    // switch back to a side branch
View Full Code Here

    git.checkout().setCreateBranch(true).setStartPoint(first)
        .setName("side").call();
    writeTrashFile("d/1", "1\n2\n3side");
    git.commit().setAll(true).setMessage("modified d/1 on side").call();

    git.rm().addFilepattern("d/1").call();
    git.rm().addFilepattern("d").call();
    MergeResult mergeRes = git.merge().setStrategy(strategy)
        .include(masterCommit).call();
    assertEquals(MergeStatus.MERGED, mergeRes.getMergeStatus());
    assertEquals("[d/1, mode:100644, content:1master\n2\n3side\n]",
View Full Code Here

        .setName("side").call();
    writeTrashFile("d/1", "1\n2\n3side");
    git.commit().setAll(true).setMessage("modified d/1 on side").call();

    git.rm().addFilepattern("d/1").call();
    git.rm().addFilepattern("d").call();
    MergeResult mergeRes = git.merge().setStrategy(strategy)
        .include(masterCommit).call();
    assertEquals(MergeStatus.MERGED, mergeRes.getMergeStatus());
    assertEquals("[d/1, mode:100644, content:1master\n2\n3side\n]",
        indexState(CONTENT));
View Full Code Here

    RevCommit initialCommit = git.commit().setMessage("initial").call();

    // create side branch and delete "a"
    createBranch(initialCommit, "refs/heads/side");
    checkoutBranch("refs/heads/side");
    git.rm().addFilepattern("a").call();
    RevCommit secondCommit = git.commit().setMessage("side").call();

    // update a on master to generate conflict
    checkoutBranch("refs/heads/master");
    writeTrashFile("a", "1\na(main)\n3\n");
View Full Code Here

    git.checkout().setCreateBranch(true).setStartPoint(first)
        .setName("side").call();
    writeTrashFile("d/1", "modified");
    git.commit().setAll(true).setMessage("modified d/1 on side").call();

    git.rm().addFilepattern("d/1").call();
    git.rm().addFilepattern("d").call();
    MergeResult mergeRes = git.merge().setStrategy(strategy)
        .include(masterCommit).call();
    assertEquals(MergeStatus.MERGED, mergeRes.getMergeStatus());
    assertEquals("[d/1, mode:100644, content:modified]",
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.