コード例 #1
0
 private static GitCommit createCommit(
     Project project, SymbolicRefsI refs, VirtualFile root, GitLogRecord record)
     throws VcsException {
   GitCommit gitCommit;
   final Collection<String> currentRefs = record.getRefs();
   List<String> locals = new ArrayList<String>();
   List<String> remotes = new ArrayList<String>();
   List<String> tags = new ArrayList<String>();
   final String s = parseRefs(refs, currentRefs, locals, remotes, tags);
   gitCommit =
       new GitCommit(
           root,
           AbstractHash.create(record.getShortHash()),
           new SHAHash(record.getHash()),
           record.getAuthorName(),
           record.getCommitterName(),
           record.getDate(),
           record.getSubject(),
           record.getFullMessage(),
           new HashSet<String>(Arrays.asList(record.getParentsShortHashes())),
           record.getFilePaths(root),
           record.getAuthorEmail(),
           record.getCommitterEmail(),
           tags,
           locals,
           remotes,
           record.parseChanges(project, root),
           record.getAuthorTimeStamp() * 1000);
   gitCommit.setCurrentBranch(s);
   /*final String current = refs.getCurrent().getName();
   gitCommit.setOnLocal((current != null) && (! current.startsWith(GitBranch.REFS_REMOTES_PREFIX)) &&
                        (! current.startsWith("remotes/")) && branches.contains(current));
   String remoteName = refs.getTrackedRemoteName();
   if (".".equals(remoteName)) {
     gitCommit.setOnTracked(gitCommit.isOnLocal());
   } else {
     remoteName = remoteName.startsWith("refs/") ? remoteName.substring("refs/".length()) : remoteName;
     gitCommit.setOnTracked(remoteName != null && branches.contains(remoteName));
   }*/
   return gitCommit;
 }
コード例 #2
0
  public static long getAuthorTime(Project project, FilePath path, final String commitsId)
      throws VcsException {
    // adjust path using change manager
    path = getLastCommitName(project, path);
    final VirtualFile root = GitUtil.getGitRoot(path);
    GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.SHOW);
    GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.STATUS, AUTHOR_TIME);
    h.setNoSSH(true);
    h.setStdoutSuppressed(true);
    h.addParameters("--name-status", parser.getPretty(), "--encoding=UTF-8");
    h.addParameters(commitsId);

    String output;
    try {
      output = h.run();

      GitLogRecord logRecord = parser.parseOneRecord(output);
      return logRecord.getAuthorTimeStamp() * 1000;

    } catch (VcsException e) {
      throw e;
    }
  }