Exemplo n.º 1
0
 private void assertProjectInWorkingSet(String workingSetName, String projectName) {
   IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
   IWorkingSet workingSet = workingSetManager.getWorkingSet(workingSetName);
   IAdaptable[] elements = workingSet.getElements();
   assertEquals("Wrong number of projects in working set", 1, elements.length);
   IProject project = Utils.getAdapter(elements[0], IProject.class);
   assertEquals("Wrong project in working set", projectName, project.getName());
 }
Exemplo n.º 2
0
  private void map(final RepositoryMapping m) {
    final IResource r;
    final File git;
    final IResource dotGit;
    IContainer c = null;

    m.clear();
    r = getProject().findMember(m.getContainerPath());
    if (r instanceof IContainer) {
      c = (IContainer) r;
    } else if (r != null) {
      c = Utils.getAdapter(r, IContainer.class);
    }

    if (c == null) {
      logAndUnmapGoneMappedResource(m);
      return;
    }
    m.setContainer(c);

    IPath absolutePath = m.getGitDirAbsolutePath();
    if (absolutePath == null) {
      logAndUnmapGoneMappedResource(m);
      return;
    }
    git = absolutePath.toFile();
    if (!git.isDirectory() || !new File(git, "config").isFile()) { // $NON-NLS-1$
      logAndUnmapGoneMappedResource(m);
      return;
    }

    try {
      m.setRepository(Activator.getDefault().getRepositoryCache().lookupRepository(git));
    } catch (IOException ioe) {
      logAndUnmapGoneMappedResource(m);
      return;
    }

    m.fireRepositoryChanged();

    trace(
        "map " //$NON-NLS-1$
            + c
            + " -> " //$NON-NLS-1$
            + m.getRepository());
    try {
      c.setSessionProperty(MAPPING_KEY, m);
    } catch (CoreException err) {
      Activator.logError(CoreText.GitProjectData_failedToCacheRepoMapping, err);
    }

    dotGit = c.findMember(Constants.DOT_GIT);
    if (dotGit != null && dotGit.getLocation().toFile().equals(git)) {
      protect(dotGit);
    }
  }
 /**
  * Returns the commit message, converting platform-specific line endings to '\n' and hard-wrapping
  * lines if necessary.
  *
  * @return commit message
  */
 public String getCommitMessage() {
   String text = getText();
   text = Utils.normalizeLineEndings(text);
   if (shouldHardWrap()) text = hardWrap(text);
   return text;
 }