예제 #1
0
  /** Prints the help message to stdout. */
  void help() {
    if (config.getUrl() == null) {
      out.println(ProgramConfig.getUsage());
    } else {

      try {
        final Action action = Action.valueOf(config.getUrl().toUpperCase());
        out.print(action.getUsage());
      } catch (final Exception e) {
        LOGGER.trace("Unrecognized help parameter", e);
        out.println(ProgramConfig.getUsage());
      }
    }
  }
예제 #2
0
  private void analyze() throws GitAPIException, SVNException {

    if (config.getUrl() == null) {

      out.println();

    } else {

      ClocService.init();

      if (config.shouldForceGit()) {
        analyzeAsGit();
      } else if (config.shouldForceSvn()) {
        analyzeAsSVN();
      } else {

        if (config.getUrl().endsWith(".git")) {
          analyzeAsGit();
        } else {
          analyzeAsSVN();
        }
      }
    }
  }
예제 #3
0
  private void analyzeAsGit() throws GitAPIException {

    final UsernamePasswordCredentialsProvider cp =
        new UsernamePasswordCredentialsProvider(config.getUsername(), config.getPassword());

    final GitRepo repo = new GitRepo(config.getUrl(), config.getBranch(), false, cp);
    repo.sync(config.getBranch(), config.shouldGenerateStats(), config.shouldUseCloc());

    if (!(config.getStart() == null && config.getEnd() == null)) {

      if (config.getBranch() != null) {
        printLimitedRange(repo.getRepoStatistics().getBranchInfoFor(config.getBranch()));
      } else {
        printLimitedRange(repo.getRepoStatistics().getBranchInfos());
      }

    } else {
      out.println(repo.getRepoStatistics().toString(config.shouldShowCommits()));
    }

    repo.close();
  }
예제 #4
0
  /**
   * Treats the url as a svn repo
   *
   * @throws SVNException
   * @throws BranchNotFoundException
   */
  private void analyzeAsSVN() throws SVNException, BranchNotFoundException {

    if (config.shouldForceSvn()) {
      LOGGER.debug("Force running as SVN");
    }

    final SVNRepo repo =
        new SVNRepo(
            config.getUrl(),
            config.getBranch(),
            config.getUsername(),
            config.getPassword(),
            false,
            false);

    repo.setLogEntryCacheDisabled(config.svnIgnoreCache);

    repo.sync(
        config.getBranch(),
        config.shouldGetLangStats(),
        config.shouldGenerateStats(),
        config.getRevA(),
        config.getRevB());

    if (!(config.getStart() == null && config.getEnd() == null)) {

      if (config.getBranch() != null) {
        printLimitedRange(repo.getRepoStatistics().getBranchInfoFor(config.getBranch()));
      } else {
        printLimitedRange(repo.getRepoStatistics().getBranchInfos());
      }

    } else {
      out.println(repo.getRepoStatistics().toString(config.shouldShowCommits()));
    }
  }