示例#1
0
  /**
   * Checkout a particular version of the specified project.
   *
   * @param versionName
   * @throws IOException
   * @throws GitAPIException
   * @throws CoreException
   * @throws InterruptedException
   */
  public static void checkoutProjectVersion(final IJavaProject project, final String versionName)
      throws IOException, GitAPIException, CoreException, InterruptedException {
    Process process;
    Git gitRepository;

    gitRepository = GitUtil.getGitRepository(project);
    if (gitRepository != null) {
      process =
          Runtime.getRuntime()
              .exec(
                  "git checkout " + versionName,
                  null,
                  gitRepository.getRepository().getDirectory().getParentFile());
      process.waitFor();
      project.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
    }
  }
示例#2
0
  /**
   * Get all the different versions of the specified project, represented by the existing
   * <em>Tags</em> and <em>Branches</em> in the associated Git repository.
   *
   * @param project
   * @throws IOException
   * @throws GitAPIException
   */
  public static List<Ref> getProjectVersions(final IJavaProject project)
      throws IOException, GitAPIException {
    Git gitRepository;
    List<Ref> returnValue;

    // Try to get a reference to the Git repository associated to the
    // specified project
    returnValue = new ArrayList<Ref>();
    gitRepository = GitUtil.getGitRepository(project);

    // Consider each tag/branch as a different project version
    if (gitRepository != null) {
      returnValue.addAll(gitRepository.branchList().call());
      returnValue.addAll(gitRepository.tagList().call());
    }

    return returnValue;
  }