Package org.eclipse.jgit.submodule

Examples of org.eclipse.jgit.submodule.SubmoduleWalk


      for (String file : indexDiff.getRemoved())
        nodes.add(new StagingEntry(repository, REMOVED, file));
    }

    try {
    SubmoduleWalk walk = SubmoduleWalk.forIndex(repository);
    while(walk.next())
      for (StagingEntry entry : nodes)
        entry.setSubmodule(entry.getPath().equals(walk.getPath()));
    } catch(IOException e) {
      Activator.error(UIText.StagingViewContentProvider_SubmoduleError, e);
    }

    content = nodes.toArray(new StagingEntry[nodes.size()]);
View Full Code Here


    }

    case SUBMODULES:
      List<RepositoryNode> children = new ArrayList<RepositoryNode>();
      try {
        SubmoduleWalk walk = SubmoduleWalk.forIndex(node
            .getRepository());
        while (walk.next()) {
          Repository subRepo = walk.getRepository();
          if (subRepo != null) {
            Repository cachedRepo = null;
            try {
              cachedRepo = repositoryCache
                .lookupRepository(subRepo.getDirectory());
View Full Code Here

    }
  }

  private static void closeSubmoduleRepositories(Repository repo)
      throws IOException {
    SubmoduleWalk walk = SubmoduleWalk.forIndex(repo);
    try {
      while (walk.next()) {
        Repository subRepo = walk.getRepository();
        if (subRepo != null) {
          RepositoryCache cache = null;
          try {
            cache = org.eclipse.egit.core.Activator.getDefault()
                .getRepositoryCache();
          } finally {
            if (cache != null)
              cache.lookupRepository(subRepo.getDirectory())
                  .close();
            subRepo.close();
          }
        }
      }
    } finally {
      walk.release();
    }
  }
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

    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();
        }

        try {
          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();
          }
        } finally {
          submoduleRepo.close();
        }
        updated.add(generator.getPath());
      }
      return updated;
    } catch (IOException e) {
      throw new JGitInternalException(e.getMessage(), e);
    } catch (ConfigInvalidException e) {
View Full Code Here

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

    try {
      SubmoduleWalk generator = SubmoduleWalk.forIndex(repo);
      if (!paths.isEmpty())
        generator.setFilter(PathFilterGroup.createFromStrings(paths));
      StoredConfig config = repo.getConfig();
      List<String> initialized = new ArrayList<String>();
      while (generator.next()) {
        // Ignore entry if URL is already present in config file
        if (generator.getConfigUrl() != null)
          continue;

        String path = generator.getPath();
        // Copy 'url' and 'update' fields from .gitmodules to config
        // file
        String url = generator.getRemoteUrl();
        String update = generator.getModulesUpdate();
        if (url != null)
          config.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION,
              path, ConfigConstants.CONFIG_KEY_URL, url);
        if (update != null)
          config.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION,
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

  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

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.