Add links to commit diff and blob diff pages to toggle whitespace setting
| | |
| | | * Enumeration for the diff comparator types.
|
| | | */
|
| | | public static enum DiffComparator {
|
| | | DEFAULT(RawTextComparator.DEFAULT),
|
| | | WS_IGNORE_ALL(RawTextComparator.WS_IGNORE_ALL),
|
| | | WS_IGNORE_LEADING(RawTextComparator.WS_IGNORE_LEADING),
|
| | | WS_IGNORE_TRAILING(RawTextComparator.WS_IGNORE_TRAILING),
|
| | | WS_IGNORE_CHANGE(RawTextComparator.WS_IGNORE_CHANGE);
|
| | | SHOW_WHITESPACE(RawTextComparator.DEFAULT),
|
| | | IGNORE_WHITESPACE(RawTextComparator.WS_IGNORE_ALL),
|
| | | IGNORE_LEADING(RawTextComparator.WS_IGNORE_LEADING),
|
| | | IGNORE_TRAILING(RawTextComparator.WS_IGNORE_TRAILING),
|
| | | IGNORE_CHANGES(RawTextComparator.WS_IGNORE_CHANGE);
|
| | |
|
| | | public final RawTextComparator textComparator;
|
| | |
|
| | | DiffComparator(RawTextComparator textComparator) {
|
| | | this.textComparator = textComparator;
|
| | | }
|
| | |
|
| | | public DiffComparator getOpposite() {
|
| | | return this == SHOW_WHITESPACE ? IGNORE_WHITESPACE : SHOW_WHITESPACE;
|
| | | }
|
| | |
|
| | | public String getTranslationKey() {
|
| | | return "gb." + name().toLowerCase();
|
| | | }
|
| | |
|
| | | public static DiffComparator forName(String name) {
|
| | |
| | | break;
|
| | | }
|
| | | df.setRepository(repository);
|
| | | df.setDiffComparator((comparator == null ? DiffComparator.DEFAULT : comparator).textComparator);
|
| | | df.setDiffComparator((comparator == null ? DiffComparator.SHOW_WHITESPACE : comparator).textComparator);
|
| | | df.setDetectRenames(true);
|
| | |
|
| | | RevTree commitTree = commit.getTree();
|
| | |
| | | gb.imgdiffSubtract = Subtract (black = identical) |
| | | gb.deleteRepositoryHeader = Delete Repository |
| | | gb.deleteRepositoryDescription = Deleted repositories will be unrecoverable. |
| | | gb.show_whitespace = show whitespace |
| | | gb.ignore_whitespace = ignore whitespace |
| | |
| | | return new PageParameters(parameterMap);
|
| | | }
|
| | |
|
| | | public static PageParameters newDiffParameter(String repositoryName,
|
| | | String objectId, DiffComparator diffComparator) {
|
| | | Map<String, String> parameterMap = new HashMap<String, String>();
|
| | | if (StringUtils.isEmpty(objectId)) {
|
| | | return newRepositoryParameter(repositoryName);
|
| | | }
|
| | | parameterMap.put("r", repositoryName);
|
| | | parameterMap.put("h", objectId);
|
| | | parameterMap.put("w", "" + diffComparator.ordinal());
|
| | | return new PageParameters(parameterMap);
|
| | | }
|
| | |
|
| | | public static PageParameters newDiffParameter(String repositoryName,
|
| | | String objectId, DiffComparator diffComparator, String blobPath) {
|
| | | Map<String, String> parameterMap = new HashMap<String, String>();
|
| | | if (StringUtils.isEmpty(objectId)) {
|
| | | return newRepositoryParameter(repositoryName);
|
| | | }
|
| | | parameterMap.put("r", repositoryName);
|
| | | parameterMap.put("h", objectId);
|
| | | parameterMap.put("w", "" + diffComparator.ordinal());
|
| | | parameterMap.put("f", blobPath);
|
| | | return new PageParameters(parameterMap);
|
| | | }
|
| | |
|
| | | public static PageParameters newRangeParameter(String repositoryName,
|
| | | String startRange, String endRange) {
|
| | | Map<String, String> parameterMap = new HashMap<String, String>();
|
| | |
| | |
|
| | | <!-- blob nav links -->
|
| | | <div class="page_nav2">
|
| | | <a wicket:id="blameLink"><wicket:message key="gb.blame"></wicket:message></a> | <a wicket:id="historyLink"><wicket:message key="gb.history"></wicket:message></a> | <a wicket:id="patchLink"><wicket:message key="gb.patch"></wicket:message></a> | <a wicket:id="commitLink"><wicket:message key="gb.commit"></wicket:message></a> | <a wicket:id="commitDiffLink"><wicket:message key="gb.commitdiff"></wicket:message></a>
|
| | | <a wicket:id="blameLink"><wicket:message key="gb.blame"></wicket:message></a> | <a wicket:id="historyLink"><wicket:message key="gb.history"></wicket:message></a> | <a wicket:id="patchLink"><wicket:message key="gb.patch"></wicket:message></a> | <a wicket:id="commitLink"><wicket:message key="gb.commit"></wicket:message></a> | <a wicket:id="commitDiffLink"><wicket:message key="gb.commitdiff"></wicket:message></a> | <a wicket:id="whitespaceLink"></a>
|
| | | </div>
|
| | |
|
| | | <!-- commit header -->
|
| | |
| | | import com.gitblit.wicket.CacheControl.LastModified;
|
| | | import com.gitblit.wicket.WicketUtils;
|
| | | import com.gitblit.wicket.panels.CommitHeaderPanel;
|
| | | import com.gitblit.wicket.panels.LinkPanel;
|
| | | import com.gitblit.wicket.panels.PathBreadcrumbsPanel;
|
| | |
|
| | | @CacheControl(LastModified.BOOT)
|
| | |
| | | WicketUtils.newObjectParameter(repositoryName, objectId)));
|
| | | add(new BookmarkablePageLink<Void>("commitDiffLink", CommitDiffPage.class,
|
| | | WicketUtils.newObjectParameter(repositoryName, objectId)));
|
| | | add(new LinkPanel("whitespaceLink", null, getString(diffComparator.getOpposite().getTranslationKey()),
|
| | | BlobDiffPage.class, WicketUtils.newDiffParameter(repositoryName, objectId, diffComparator.getOpposite(), blobPath)));
|
| | |
|
| | | // diff page links
|
| | | add(new BookmarkablePageLink<Void>("blameLink", BlamePage.class,
|
| | |
| | |
|
| | | <!-- commitdiff nav links -->
|
| | | <div class="page_nav2">
|
| | | <wicket:message key="gb.parent"></wicket:message>: <span wicket:id="parentLink">[parent link]</span> | <a wicket:id="patchLink"><wicket:message key="gb.patch"></wicket:message></a> | <a wicket:id="commitLink"><wicket:message key="gb.commit"></wicket:message></a>
|
| | | <wicket:message key="gb.parent"></wicket:message>: <span wicket:id="parentLink">[parent link]</span> | <a wicket:id="patchLink"><wicket:message key="gb.patch"></wicket:message></a> | <a wicket:id="commitLink"><wicket:message key="gb.commit"></wicket:message></a> | <a wicket:id="whitespaceLink"></a>
|
| | | </div>
|
| | |
|
| | | <!-- commit header -->
|
| | |
| | | public CommitDiffPage(PageParameters params) { |
| | | super(params); |
| | | |
| | | Repository r = getRepository(); |
| | | |
| | | RevCommit commit = getCommit(); |
| | | final Repository r = getRepository(); |
| | | final RevCommit commit = getCommit(); |
| | | final DiffComparator diffComparator = WicketUtils.getDiffComparator(params); |
| | | |
| | | List<String> parents = new ArrayList<String>(); |
| | | if (commit.getParentCount() > 0) { |
| | |
| | | WicketUtils.newObjectParameter(repositoryName, objectId))); |
| | | add(new BookmarkablePageLink<Void>("commitLink", CommitPage.class, |
| | | WicketUtils.newObjectParameter(repositoryName, objectId))); |
| | | add(new LinkPanel("whitespaceLink", null, getString(diffComparator.getOpposite().getTranslationKey()), |
| | | CommitDiffPage.class, WicketUtils.newDiffParameter(repositoryName, objectId, diffComparator.getOpposite()))); |
| | | |
| | | add(new CommitHeaderPanel("commitHeader", repositoryName, commit)); |
| | | |
| | |
| | | final ImageDiffHandler handler = new ImageDiffHandler(this, repositoryName, |
| | | parents.isEmpty() ? null : parents.get(0), commit.getName(), imageExtensions); |
| | | |
| | | final DiffComparator diffComparator = WicketUtils.getDiffComparator(params); |
| | | final DiffOutput diff = DiffUtils.getCommitDiff(r, commit, diffComparator, DiffOutputType.HTML, handler); |
| | | if (handler.getImgDiffCount() > 0) { |
| | | addBottomScript("scripts/imgdiff.js"); // Tiny support script for image diffs |
| | |
| | | Repository repository = GitBlitSuite.getHelloworldRepository();
|
| | | RevCommit commit = JGitUtils.getCommit(repository,
|
| | | "1d0c2933a4ae69c362f76797d42d6bd182d05176");
|
| | | String diff = DiffUtils.getCommitDiff(repository, commit, DiffComparator.DEFAULT, DiffOutputType.PLAIN).content;
|
| | | String diff = DiffUtils.getCommitDiff(repository, commit, DiffComparator.SHOW_WHITESPACE, DiffOutputType.PLAIN).content;
|
| | | repository.close();
|
| | | assertTrue(diff != null && diff.length() > 0);
|
| | | String expected = "- system.out.println(\"Hello World\");\n+ System.out.println(\"Hello World\"";
|
| | |
| | | "8baf6a833b5579384d9b9ceb8a16b5d0ea2ec4ca");
|
| | | RevCommit commit = JGitUtils.getCommit(repository,
|
| | | "1d0c2933a4ae69c362f76797d42d6bd182d05176");
|
| | | String diff = DiffUtils.getDiff(repository, baseCommit, commit, DiffComparator.DEFAULT, DiffOutputType.PLAIN).content;
|
| | | String diff = DiffUtils.getDiff(repository, baseCommit, commit, DiffComparator.SHOW_WHITESPACE, DiffOutputType.PLAIN).content;
|
| | | repository.close();
|
| | | assertTrue(diff != null && diff.length() > 0);
|
| | | String expected = "- system.out.println(\"Hello World\");\n+ System.out.println(\"Hello World\"";
|
| | |
| | | Repository repository = GitBlitSuite.getHelloworldRepository();
|
| | | RevCommit commit = JGitUtils.getCommit(repository,
|
| | | "1d0c2933a4ae69c362f76797d42d6bd182d05176");
|
| | | String diff = DiffUtils.getDiff(repository, commit, "java.java", DiffComparator.DEFAULT, DiffOutputType.PLAIN).content;
|
| | | String diff = DiffUtils.getDiff(repository, commit, "java.java", DiffComparator.SHOW_WHITESPACE, DiffOutputType.PLAIN).content;
|
| | | repository.close();
|
| | | assertTrue(diff != null && diff.length() > 0);
|
| | | String expected = "- system.out.println(\"Hello World\");\n+ System.out.println(\"Hello World\"";
|