Package org.eclipse.egit.core.project

Examples of org.eclipse.egit.core.project.RepositoryMapping


      references[i] = asReference(projects[i]);
    return references;
  }

  private String asReference(IProject project) throws TeamException {
    RepositoryMapping mapping = RepositoryMapping.getMapping(project);
    String branch;
    try {
      branch = mapping.getRepository().getBranch();
    } catch (IOException e) {
      throw new TeamException(NLS.bind(
          CoreText.GitProjectSetCapability_ExportCouldNotGetBranch,
          project.getName()));
    }
    StoredConfig config = mapping.getRepository().getConfig();
    String remote = config.getString(ConfigConstants.CONFIG_BRANCH_SECTION,
        branch, ConfigConstants.CONFIG_KEY_REMOTE);
    String url = config.getString(ConfigConstants.CONFIG_REMOTE_SECTION,
        remote, ConfigConstants.CONFIG_KEY_URL);
    if (url == null)
      throw new TeamException(NLS.bind(
          CoreText.GitProjectSetCapability_ExportNoRemote,
          project.getName()));

    String projectPath = mapping.getRepoRelativePath(project);
    if (projectPath.equals("")) //$NON-NLS-1$
      projectPath = "."; //$NON-NLS-1$

    StringBuilder sb = new StringBuilder();
View Full Code Here


  private void assertProjectIsShared(String projectName,
      boolean shouldBeShared) {
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
        projectName);
    RepositoryMapping mapping = RepositoryMapping.getMapping(project);
    if (shouldBeShared) {
      assertNotNull(mapping);
      assertNotNull(mapping.getRepository());
    } else
      assertNull(mapping);
  }
View Full Code Here

  @Override
  public void saveState(IMemento memento) {
    super.saveState(memento);
    for (GitSynchronizeData gsd : gsds) {
      Repository repo = gsd.getRepository();
      RepositoryMapping mapping = RepositoryMapping.findRepositoryMapping(repo);
      if (mapping != null) {
        IMemento child = memento.createChild(DATA_NODE_KEY);
        child.putString(CONTAINER_PATH_KEY,
            getPathForResource(mapping.getContainer()));
        child.putString(SRC_REV_KEY, gsd.getSrcRev());
        child.putString(DST_REV_KEY, gsd.getDstRev());
        child.putBoolean(INCLUDE_LOCAL_KEY, gsd.shouldIncludeLocal());
        Set<IResource> includedResources = gsd.getIncludedResources();
        if (includedResources != null && !includedResources.isEmpty()) {
View Full Code Here

    IContainer mappedContainer = ResourcesPlugin.getWorkspace().getRoot()
        .getContainerForLocation(path);
    GitProjectData projectData = GitProjectData.get((IProject) mappedContainer);
    if (projectData == null)
      return null;
    RepositoryMapping mapping = projectData.getRepositoryMapping(mappedContainer);
    if (mapping != null)
      return mapping.getRepository();
    return null;
  }
View Full Code Here

                  Activator.getPluginId(),
                  UIText.LocalNonWorkspaceTypedElement_errorWritingContents,
                  e));
        } finally {
          fireContentChanged();
          RepositoryMapping mapping = RepositoryMapping.getMapping(path);
          if (mapping != null)
            mapping.getRepository().fireEvent(new IndexChangedEvent());
          if (out != null)
            try {
              out.close();
            } catch (IOException ex) {
              // ignore
View Full Code Here

  private IProject[] getProjectsForSelectedResources(
      IStructuredSelection selection) {
    Set<IProject> ret = new LinkedHashSet<IProject>();
    for (IResource resource : (IResource[]) getSelectedAdaptables(
        selection, IResource.class)) {
      RepositoryMapping mapping = RepositoryMapping.getMapping(resource);
      if (mapping != null && (mapping.getContainer() instanceof IProject))
        ret.add((IProject) mapping.getContainer());
      else
        return new IProject[0];
    }
    ret.addAll(extractProjectsFromMappings(selection));
View Full Code Here

   * @return the repositories that projects map to if all projects are mapped
   */
  protected Repository[] getRepositoriesFor(final IProject[] projects) {
    Set<Repository> ret = new LinkedHashSet<Repository>();
    for (IProject project : projects) {
      RepositoryMapping repositoryMapping = RepositoryMapping
          .getMapping(project);
      if (repositoryMapping == null)
        return new Repository[0];
      ret.add(repositoryMapping.getRepository());
    }
    return ret.toArray(new Repository[ret.size()]);
  }
View Full Code Here

    Set<IProject> ret = new LinkedHashSet<IProject>();
    Repository[] repositories = getRepositoriesFor(getProjectsForSelectedResources(selection));
    final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot()
        .getProjects();
    for (IProject project : projects) {
      RepositoryMapping mapping = RepositoryMapping.getMapping(project);
      for (Repository repository : repositories)
        if (mapping != null && mapping.getRepository() == repository) {
          ret.add(project);
          break;
        }
    }
    return ret.toArray(new IProject[ret.size()]);
View Full Code Here

    layout.marginWidth = 0;
    layout.marginHeight = 0;
    composite.setLayout(layout);

    for (IProject project : ROOT.getProjects()) {
      RepositoryMapping repositoryMapping = RepositoryMapping
          .getMapping(project);
      if (repositoryMapping == null)
        continue;
      Repository repo = repositoryMapping.getRepository();
      Set<IProject> projects = resources.get(repo);
      if (projects == null) {
        projects = new HashSet<IProject>();
        resources.put(repo, projects);
      }
View Full Code Here

      references[i] = asReference(projects[i]);
    return references;
  }

  private String asReference(IProject project) throws TeamException {
    RepositoryMapping mapping = RepositoryMapping.getMapping(project);
    String branch;
    try {
      branch = mapping.getRepository().getBranch();
    } catch (IOException e) {
      throw new TeamException(NLS.bind(
          CoreText.GitProjectSetCapability_ExportCouldNotGetBranch,
          project.getName()));
    }
    StoredConfig config = mapping.getRepository().getConfig();
    String remote = config.getString(ConfigConstants.CONFIG_BRANCH_SECTION,
        branch, ConfigConstants.CONFIG_KEY_REMOTE);
    String url = config.getString(ConfigConstants.CONFIG_REMOTE_SECTION,
        remote, ConfigConstants.CONFIG_KEY_URL);
    if (url == null)
      throw new TeamException(NLS.bind(
          CoreText.GitProjectSetCapability_ExportNoRemote,
          project.getName()));

    String projectPath = mapping.getRepoRelativePath(project);
    if (projectPath.equals("")) //$NON-NLS-1$
      projectPath = "."; //$NON-NLS-1$

    return asReference(url, branch, projectPath);
  }
View Full Code Here

TOP

Related Classes of org.eclipse.egit.core.project.RepositoryMapping

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.