Package org.eclipse.jgit.submodule

Examples of org.eclipse.jgit.submodule.SubmoduleWalk


    command.setURI(uri);
    Repository repo = command.call();
    assertNotNull(repo);
    addRepoToClose(repo);

    SubmoduleWalk generator = SubmoduleWalk.forIndex(db);
    assertTrue(generator.next());
    assertEquals(path, generator.getPath());
    assertEquals(commit, generator.getObjectId());
    assertEquals(uri, generator.getModulesUrl());
    assertEquals(path, generator.getModulesPath());
    assertEquals(uri, generator.getConfigUrl());
    Repository subModRepo = generator.getRepository();
    addRepoToClose(subModRepo);
    assertNotNull(subModRepo);
    assertEquals(commit, repo.resolve(Constants.HEAD));

    RevCommit submoduleCommit = git.commit().setMessage("submodule add")
View Full Code Here


    command.setURI(uri);
    Repository repo = command.call();
    assertNotNull(repo);
    addRepoToClose(repo);

    SubmoduleWalk generator = SubmoduleWalk.forIndex(db);
    assertTrue(generator.next());
    assertEquals(path, generator.getPath());
    assertEquals(commit2, generator.getObjectId());
    assertEquals(uri, generator.getModulesUrl());
    assertEquals(path, generator.getModulesPath());
    assertEquals(uri, generator.getConfigUrl());
    Repository subModRepo = generator.getRepository();
    addRepoToClose(subModRepo);
    assertNotNull(subModRepo);
    assertEquals(commit2, repo.resolve(Constants.HEAD));

    RevCommit submoduleAddCommit = git.commit().setMessage("submodule add")
View Full Code Here

  public Map<String, String> call() throws GitAPIException {
    checkCallable();

    try {
      SubmoduleWalk generator = SubmoduleWalk.forIndex(repo);
      if (!paths.isEmpty())
        generator.setFilter(PathFilterGroup.createFromStrings(paths));
      Map<String, String> synced = new HashMap<String, String>();
      StoredConfig config = repo.getConfig();
      while (generator.next()) {
        String remoteUrl = generator.getRemoteUrl();
        if (remoteUrl == null)
          continue;

        String path = generator.getPath();
        config.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION,
            path, ConfigConstants.CONFIG_KEY_URL, remoteUrl);
        synced.put(path, remoteUrl);

        Repository subRepo = generator.getRepository();
        if (subRepo == null)
          continue;

        StoredConfig subConfig;
        String branch;
View Full Code Here

    SubmoduleUpdateCommand update = new SubmoduleUpdateCommand(clonedRepo);
    configure(update);
    update.setProgressMonitor(monitor);
    if (!update.call().isEmpty()) {
      SubmoduleWalk walk = SubmoduleWalk.forIndex(clonedRepo);
      while (walk.next()) {
        Repository subRepo = walk.getRepository();
        if (subRepo != null) {
          try {
            cloneSubmodules(subRepo);
          } finally {
            subRepo.close();
View Full Code Here

    return this;
  }

  @Override
  protected void cloneSubmodules(Repository repository) throws IOException, GitAPIException {
    SubmoduleWalk generator;
    if (isInMemory()) {
      generator = new InMemorySubmoduleWalk(repository, submodulesConfig);
      try {
        DirCache index = repository.readDirCache();
        generator.setTree(new DirCacheIterator(index));
      } catch (IOException e) {
        generator.release();
        throw e;
      }
    } else {
      generator = SubmoduleWalk.forIndex(repository);
    }

    try {
      while (generator.next()) {
        if (generator.getConfigUrl() != null) {
          continue;
        }

        String path = generator.getPath();
        String url = generator.getRemoteUrl();

        CloneAndProcessCommand command =
            new CloneAndProcessCommand(path, config).setProcessor(processor);
        command.setURI(url).setCloneSubmodules(true);
        command.call();
View Full Code Here

    SubmoduleUpdateCommand update = new SubmoduleUpdateCommand(clonedRepo);
    configure(update);
    update.setProgressMonitor(monitor);
    if (!update.call().isEmpty()) {
      SubmoduleWalk walk = SubmoduleWalk.forIndex(clonedRepo);
      while (walk.next()) {
        Repository subRepo = walk.getRepository();
        if (subRepo != null) {
          try {
            cloneSubmodules(subRepo);
          } finally {
            subRepo.close();
View Full Code Here

      WrongRepositoryStateException, NoMessageException, NoHeadException,
      RefNotFoundException, GitAPIException {
    checkCallable();

    try {
      SubmoduleWalk generator = SubmoduleWalk.forIndex(repo);
      if (!paths.isEmpty())
        generator.setFilter(PathFilterGroup.createFromStrings(paths));
      List<String> updated = new ArrayList<String>();
      while (generator.next()) {
        // Skip submodules not registered in .gitmodules file
        if (generator.getModulesPath() == null)
          continue;
        // Skip submodules not registered in parent repository's config
        String url = generator.getConfigUrl();
        if (url == null)
          continue;

        Repository submoduleRepo = generator.getRepository();
        // Clone repository is not present
        if (submoduleRepo == null) {
          CloneCommand clone = Git.cloneRepository();
          configure(clone);
          clone.setURI(url);
          clone.setDirectory(generator.getDirectory());
          if (monitor != null)
            clone.setProgressMonitor(monitor);
          submoduleRepo = clone.call().getRepository();
        }

        RevWalk walk = new RevWalk(submoduleRepo);
        RevCommit commit = walk.parseCommit(generator.getObjectId());

        String update = generator.getConfigUpdate();
        if (ConfigConstants.CONFIG_KEY_MERGE.equals(update)) {
          MergeCommand merge = new MergeCommand(submoduleRepo);
          merge.include(commit);
          merge.call();
        } else if (ConfigConstants.CONFIG_KEY_REBASE.equals(update)) {
          RebaseCommand rebase = new RebaseCommand(submoduleRepo);
          rebase.setUpstream(commit);
          rebase.call();
        } else {
          // Checkout commit referenced in parent repository's index
          // as a detached HEAD
          DirCacheCheckout co = new DirCacheCheckout(submoduleRepo,
              submoduleRepo.lockDirCache(), commit.getTree());
          co.setFailOnConflict(true);
          co.checkout();
          RefUpdate refUpdate = submoduleRepo.updateRef(
              Constants.HEAD, true);
          refUpdate.setNewObjectId(commit);
          refUpdate.forceUpdate();
        }
        updated.add(generator.getPath());
      }
      return updated;
    } catch (IOException e) {
      throw new JGitInternalException(e.getMessage(), e);
    } catch (ConfigInvalidException e) {
View Full Code Here

  public Map<String, SubmoduleStatus> call() throws GitAPIException {
    checkCallable();

    try {
      SubmoduleWalk generator = SubmoduleWalk.forIndex(repo);
      if (!paths.isEmpty())
        generator.setFilter(PathFilterGroup.createFromStrings(paths));
      Map<String, SubmoduleStatus> statuses = new HashMap<String, SubmoduleStatus>();
      while (generator.next()) {
        SubmoduleStatus status = getStatus(generator);
        statuses.put(status.getPath(), status);
      }
      return statuses;
    } catch (IOException e) {
View Full Code Here

    SubmoduleUpdateCommand update = new SubmoduleUpdateCommand(clonedRepo);
    configure(update);
    update.setProgressMonitor(monitor);
    if (!update.call().isEmpty()) {
      SubmoduleWalk walk = SubmoduleWalk.forIndex(clonedRepo);
      while (walk.next()) {
        Repository subRepo = walk.getRepository();
        if (subRepo != null)
          cloneSubmodules(subRepo);
      }
    }
  }
View Full Code Here

  public Map<String, String> call() throws GitAPIException {
    checkCallable();

    try {
      SubmoduleWalk generator = SubmoduleWalk.forIndex(repo);
      if (!paths.isEmpty())
        generator.setFilter(PathFilterGroup.createFromStrings(paths));
      Map<String, String> synced = new HashMap<String, String>();
      StoredConfig config = repo.getConfig();
      while (generator.next()) {
        String remoteUrl = generator.getRemoteUrl();
        if (remoteUrl == null)
          continue;

        String path = generator.getPath();
        config.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION,
            path, ConfigConstants.CONFIG_KEY_URL, remoteUrl);
        synced.put(path, remoteUrl);

        Repository subRepo = generator.getRepository();
        if (subRepo == null)
          continue;

        StoredConfig subConfig = subRepo.getConfig();
        // Get name of remote associated with current branch and
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.submodule.SubmoduleWalk

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.