| | |
| | | package com.gitblit.utils;
|
| | |
|
| | | import java.io.ByteArrayOutputStream;
|
| | | import java.text.MessageFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
|
| | |
| | | * Enumeration for the diff output types.
|
| | | */
|
| | | public static enum DiffOutputType {
|
| | | PLAIN, GITWEB, GITBLIT;
|
| | | PLAIN, HTML;
|
| | |
|
| | | public static DiffOutputType forName(String name) {
|
| | | for (DiffOutputType type : values()) {
|
| | |
| | | RawTextComparator cmp = RawTextComparator.DEFAULT;
|
| | | DiffFormatter df;
|
| | | switch (outputType) {
|
| | | case GITWEB:
|
| | | df = new GitWebDiffFormatter(os);
|
| | | break;
|
| | | case GITBLIT:
|
| | | case HTML:
|
| | | df = new GitBlitDiffFormatter(os);
|
| | | break;
|
| | | case PLAIN:
|
| | |
| | | } else {
|
| | | df.format(diffEntries);
|
| | | }
|
| | | if (df instanceof GitWebDiffFormatter) {
|
| | | if (df instanceof GitBlitDiffFormatter) {
|
| | | // workaround for complex private methods in DiffFormatter
|
| | | diff = ((GitWebDiffFormatter) df).getHtml();
|
| | | diff = ((GitBlitDiffFormatter) df).getHtml();
|
| | | } else {
|
| | | diff = os.toString();
|
| | | }
|
| | |
| | | lines.add(line);
|
| | | }
|
| | | } catch (Throwable t) {
|
| | | LOGGER.error("failed to generate blame!", t);
|
| | | LOGGER.error(MessageFormat.format("failed to generate blame for {0} {1}!", blobPath, objectId), t);
|
| | | }
|
| | | return lines;
|
| | | }
|