Examples of DirCacheEditor


Examples of org.eclipse.jgit.dircache.DirCacheEditor

    FileRepositoryBuilder builder = new FileRepositoryBuilder();
    builder.setWorkTree(new File(db.getWorkTree(), path));
    builder.build().create();

    DirCache cache = db.lockDirCache();
    DirCacheEditor editor = cache.editor();
    editor.add(new PathEdit(path) {

      public void apply(DirCacheEntry ent) {
        ent.setFileMode(FileMode.GITLINK);
        ent.setObjectId(id);
      }
    });
    editor.commit();

    SubmoduleWalk gen = SubmoduleWalk.forIndex(db);
    assertTrue(gen.next());
    assertEquals(path, gen.getPath());
    assertEquals(id, gen.getObjectId());
View Full Code Here

Examples of org.eclipse.jgit.dircache.DirCacheEditor

    FileRepositoryBuilder builder = new FileRepositoryBuilder();
    builder.setWorkTree(new File(db.getWorkTree(), path));
    builder.build().create();

    DirCache cache = db.lockDirCache();
    DirCacheEditor editor = cache.editor();
    editor.add(new PathEdit(path) {

      public void apply(DirCacheEntry ent) {
        ent.setFileMode(FileMode.GITLINK);
        ent.setObjectId(id);
      }
    });
    editor.commit();

    SubmoduleWalk gen = SubmoduleWalk.forIndex(db);
    assertTrue(gen.next());
    assertEquals(path, gen.getPath());
    assertEquals(id, gen.getObjectId());
View Full Code Here

Examples of org.eclipse.jgit.dircache.DirCacheEditor

      ConfigInvalidException {
    final ObjectId id = ObjectId
        .fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
    final String path = "sub/dir/final";
    DirCache cache = db.lockDirCache();
    DirCacheEditor editor = cache.editor();
    editor.add(new PathEdit(path) {

      public void apply(DirCacheEntry ent) {
        ent.setFileMode(FileMode.GITLINK);
        ent.setObjectId(id);
      }
    });
    editor.commit();

    SubmoduleWalk gen = SubmoduleWalk.forIndex(db);
    assertTrue(gen.next());
    assertEquals(path, gen.getPath());
    assertEquals(id, gen.getObjectId());
View Full Code Here

Examples of org.eclipse.jgit.dircache.DirCacheEditor

    final String path1 = "sub1";
    final ObjectId id2 = ObjectId
        .fromString("abcd1234abcd1234abcd1234abcd1234abcd1235");
    final String path2 = "sub2";
    DirCache cache = db.lockDirCache();
    DirCacheEditor editor = cache.editor();
    editor.add(new PathEdit(path1) {

      public void apply(DirCacheEntry ent) {
        ent.setFileMode(FileMode.GITLINK);
        ent.setObjectId(id1);
      }
    });
    editor.add(new PathEdit(path2) {

      public void apply(DirCacheEntry ent) {
        ent.setFileMode(FileMode.GITLINK);
        ent.setObjectId(id2);
      }
    });
    editor.commit();

    SubmoduleWalk gen = SubmoduleWalk.forIndex(db);
    gen.setFilter(PathFilter.create(path1));
    assertTrue(gen.next());
    assertEquals(path1, gen.getPath());
View Full Code Here

Examples of org.eclipse.jgit.dircache.DirCacheEditor

    gitmodules.setString(CONFIG_SUBMODULE_SECTION, path, CONFIG_KEY_URL,
        "git://example.com/sub");
    writeTrashFile(DOT_GIT_MODULES, gitmodules.toText());

    DirCache cache = db.lockDirCache();
    DirCacheEditor editor = cache.editor();
    editor.add(new PathEdit(path) {

      public void apply(DirCacheEntry ent) {
        ent.setFileMode(FileMode.GITLINK);
        ent.setObjectId(subId);
      }
    });
    editor.add(new PathEdit(DOT_GIT_MODULES) {

      public void apply(DirCacheEntry ent) {
        ent.setFileMode(FileMode.REGULAR_FILE);
        ent.setObjectId(gitmodulesBlob);
      }
    });
    editor.commit();

    SubmoduleWalk gen = SubmoduleWalk.forIndex(db);
    assertTrue(gen.next());
    assertEquals(path, gen.getPath());
    assertEquals(subId, gen.getObjectId());
View Full Code Here

Examples of org.eclipse.jgit.dircache.DirCacheEditor

    writeTrashFile("a.txt", "content");
    Git git = new Git(db);
    git.add().addFilepattern("a.txt").call();
    RevCommit c1 = git.commit().setMessage("initial commit").call();
    DirCache cache = db.lockDirCache();
    DirCacheEditor editor = cache.editor();
    final TreeWalk walk = new TreeWalk(db);
    walk.addTree(c1.getTree());
    walk.setRecursive(true);
    assertTrue(walk.next());

    editor.add(new PathEdit("a.txt") {

      public void apply(DirCacheEntry ent) {
        ent.setFileMode(FileMode.EXECUTABLE_FILE);
        ent.setObjectId(walk.getObjectId(0));
      }
    });
    assertTrue(editor.commit());
    RevCommit c2 = git.commit().setMessage("second commit").call();
    walk.reset();
    walk.addTree(c1.getTree());
    walk.addTree(c2.getTree());
    List<DiffEntry> diffs = DiffEntry.scan(walk, false);
View Full Code Here

Examples of org.eclipse.jgit.dircache.DirCacheEditor

  private String addSubmoduleToIndex() throws IOException {
    final ObjectId id = ObjectId
        .fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
    final String path = "sub";
    DirCache cache = db.lockDirCache();
    DirCacheEditor editor = cache.editor();
    editor.add(new PathEdit(path) {

      public void apply(DirCacheEntry ent) {
        ent.setFileMode(FileMode.GITLINK);
        ent.setObjectId(id);
      }
    });
    editor.commit();
    return path;
  }
View Full Code Here

Examples of org.eclipse.jgit.dircache.DirCacheEditor

    git.add().addFilepattern("file.txt").call();
    final RevCommit commit = git.commit().setMessage("create file").call();

    final String path = "sub";
    DirCache cache = db.lockDirCache();
    DirCacheEditor editor = cache.editor();
    editor.add(new PathEdit(path) {

      public void apply(DirCacheEntry ent) {
        ent.setFileMode(FileMode.GITLINK);
        ent.setObjectId(commit);
      }
    });
    editor.commit();

    StoredConfig config = db.getConfig();
    config.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
        ConfigConstants.CONFIG_KEY_URL, db.getDirectory().toURI()
            .toString());
View Full Code Here

Examples of org.eclipse.jgit.dircache.DirCacheEditor

      GitAPIException {
    final ObjectId id = ObjectId
        .fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
    final String path = "sub";
    DirCache cache = db.lockDirCache();
    DirCacheEditor editor = cache.editor();
    editor.add(new PathEdit(path) {

      public void apply(DirCacheEntry ent) {
        ent.setFileMode(FileMode.GITLINK);
        ent.setObjectId(id);
      }
    });
    editor.commit();

    FileBasedConfig modulesConfig = new FileBasedConfig(new File(
        db.getWorkTree(), Constants.DOT_GIT_MODULES), db.getFS());
    modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
        ConfigConstants.CONFIG_KEY_PATH, path);
View Full Code Here

Examples of org.eclipse.jgit.dircache.DirCacheEditor

      GitAPIException {
    final ObjectId id = ObjectId
        .fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
    final String path = "sub";
    DirCache cache = db.lockDirCache();
    DirCacheEditor editor = cache.editor();
    editor.add(new PathEdit(path) {

      public void apply(DirCacheEntry ent) {
        ent.setFileMode(FileMode.GITLINK);
        ent.setObjectId(id);
      }
    });
    editor.commit();

    Repository subRepo = Git.init().setBare(false)
        .setDirectory(new File(db.getWorkTree(), path)).call()
        .getRepository();
    assertNotNull(subRepo);
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.