Ejemplo n.º 1
0
  @SuppressWarnings("StringConcatenationInsideStringBufferAppend")
  private static String printErrorDetails(
      @NotNull VirtualFile root,
      @NotNull Set<VcsRef> allRefs,
      @NotNull List<VcsCommitMetadata> sortedCommits,
      @NotNull DetailedLogData firstBlockSyncData,
      @NotNull Set<VcsRef> manuallyReadBranches,
      @Nullable Set<String> currentTagNames,
      @Nullable DetailedLogData commitsFromTags) {

    StringBuilder sb = new StringBuilder();
    sb.append("[" + root.getName() + "]\n");
    sb.append("First block data from Git:\n");
    sb.append(printLogData(firstBlockSyncData));
    sb.append("\n\nManually read refs:\n");
    sb.append(printRefs(manuallyReadBranches));
    sb.append("\n\nCurrent tag names:\n");
    if (currentTagNames != null) {
      sb.append(StringUtil.join(currentTagNames, ", "));
      if (commitsFromTags != null) {
        sb.append(printLogData(commitsFromTags));
      } else {
        sb.append("\n\nCommits from new tags were not read.\n");
      }
    } else {
      sb.append("\n\nCurrent tags were not read\n");
    }

    sb.append("\n\nResult:\n");
    sb.append("\nCommits (last 100): \n");
    sb.append(printCommits(sortedCommits));
    sb.append("\nAll refs:\n");
    sb.append(printRefs(allRefs));
    return sb.toString();
  }
 private static String printLogData(DetailedLogData firstBlockSyncData) {
   StringBuilder sb = new StringBuilder();
   sb.append("Last 100 commits:\n");
   sb.append(printCommits(firstBlockSyncData.getCommits()));
   sb.append("\nRefs:\n");
   sb.append(printRefs(firstBlockSyncData.getRefs()));
   return sb.toString();
 }
 private static String printCommits(List<VcsCommitMetadata> commits) {
   StringBuilder sb = new StringBuilder();
   for (int i = 0; i < Math.min(commits.size(), 100); i++) {
     GraphCommit<Hash> commit = commits.get(i);
     sb.append(
         String.format(
             "%s -> %s\n",
             commit.getId().toShortString(),
             StringUtil.join(
                 commit.getParents(),
                 new Function<Hash, String>() {
                   @Override
                   public String fun(Hash hash) {
                     return hash.toShortString();
                   }
                 },
                 ", ")));
   }
   return sb.toString();
 }