コード例 #1
0
ファイル: Log.java プロジェクト: rouault/GeoGit
 @Override
 public void print(RevCommit commit) throws IOException {
   Ansi ansi = AnsiDecorator.newAnsi(useColor);
   ansi.fg(Color.YELLOW).a(getIdAsString(commit.getId())).reset();
   String message = Strings.nullToEmpty(commit.getMessage());
   String title = Splitter.on('\n').split(message).iterator().next();
   ansi.a(" ").a(title);
   console.println(ansi.toString());
 }
コード例 #2
0
ファイル: Log.java プロジェクト: rouault/GeoGit
    @Override
    public void print(RevCommit commit) throws IOException {
      Ansi ansi = AnsiDecorator.newAnsi(useColor);

      ansi.a("Commit:  ").fg(Color.YELLOW).a(getIdAsString(commit.getId())).reset().newline();
      if (commit.getParentIds().size() > 1) {
        ansi.a("Merge: ");
        for (ObjectId parent : commit.getParentIds()) {
          ansi.a(parent.toString().substring(0, 7)).a(" ");
        }
        ansi.newline();
      }
      ansi.a("Author:  ").fg(Color.GREEN).a(formatPerson(commit.getAuthor())).reset().newline();

      final long timestamp = commit.getAuthor().getTimestamp();
      final int timeZoneOffset = commit.getAuthor().getTimeZoneOffset();

      String friendlyString = estimateSince(now, timestamp);
      DATE_FORMAT.getCalendar().getTimeZone().setRawOffset(timeZoneOffset);
      String formattedDate = DATE_FORMAT.format(timestamp);

      ansi.a("Date:    (")
          .fg(Color.RED)
          .a(friendlyString)
          .reset()
          .a(") ")
          .a(formattedDate)
          .newline();
      ansi.a("Subject: ").a(commit.getMessage()).newline();
      if ((detail.equals(LOG_DETAIL.NAMES_ONLY)) && commit.getParentIds().size() == 1) {
        ansi.a("Affected paths:").newline();
        Iterator<DiffEntry> diff =
            geogit
                .command(DiffOp.class)
                .setOldVersion(commit.parentN(0).get())
                .setNewVersion(commit.getId())
                .call();
        DiffEntry diffEntry;
        while (diff.hasNext()) {
          diffEntry = diff.next();
          ansi.a("\t" + diffEntry.newPath()).newline();
        }
      }
      if (detail.equals(LOG_DETAIL.STATS) && commit.getParentIds().size() == 1) {

        Iterator<DiffEntry> diff =
            geogit
                .command(DiffOp.class)
                .setOldVersion(commit.parentN(0).get())
                .setNewVersion(commit.getId())
                .call();
        int adds = 0, deletes = 0, changes = 0;
        DiffEntry diffEntry;
        while (diff.hasNext()) {
          diffEntry = diff.next();
          switch (diffEntry.changeType()) {
            case ADDED:
              ++adds;
              break;
            case REMOVED:
              ++deletes;
              break;
            case MODIFIED:
              ++changes;
              break;
          }
        }

        ansi.a("Changes:");
        ansi.fg(Color.GREEN)
            .a(adds)
            .reset()
            .a(" features added, ")
            .fg(Color.YELLOW)
            .a(changes)
            .reset()
            .a(" changed, ")
            .fg(Color.RED)
            .a(deletes)
            .reset()
            .a(" deleted.")
            .reset()
            .newline();
      }

      console.println(ansi.toString());
      if (detail.equals(LOG_DETAIL.SUMMARY) && commit.getParentIds().size() == 1) {
        ansi.a("Changes:").newline();
        Iterator<DiffEntry> diff =
            geogit
                .command(DiffOp.class)
                .setOldVersion(commit.parentN(0).get())
                .setNewVersion(commit.getId())
                .call();
        DiffEntry diffEntry;
        while (diff.hasNext()) {
          diffEntry = diff.next();
          if (detail.equals(LOG_DETAIL.SUMMARY)) {
            new FullDiffPrinter(true, false).print(geogit, console, diffEntry);
          }
        }
      }
    }