From 3daba4304dba818d54eb9b74d8d35df5aab8fee5 Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Fri, 22 Nov 2013 10:36:05 -0500 Subject: [PATCH] Add pull request linking in changelog to generated documentation --- src/main/java/com/gitblit/wicket/panels/HistoryPanel.java | 49 ++++++++++++++++++++++++++++--------------------- 1 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/gitblit/wicket/panels/HistoryPanel.java b/src/main/java/com/gitblit/wicket/panels/HistoryPanel.java index 4d27589..10a8b57 100644 --- a/src/main/java/com/gitblit/wicket/panels/HistoryPanel.java +++ b/src/main/java/com/gitblit/wicket/panels/HistoryPanel.java @@ -42,9 +42,9 @@ import com.gitblit.GitBlit; import com.gitblit.Keys; import com.gitblit.models.PathModel; -import com.gitblit.models.SubmoduleModel; import com.gitblit.models.PathModel.PathChangeModel; import com.gitblit.models.RefModel; +import com.gitblit.models.SubmoduleModel; import com.gitblit.utils.JGitUtils; import com.gitblit.utils.StringUtils; import com.gitblit.wicket.WicketUtils; @@ -107,13 +107,13 @@ tw.release(); } } - + final boolean isTree = matchingPath == null ? true : matchingPath.isTree(); final boolean isSubmodule = matchingPath == null ? false : matchingPath.isSubmodule(); // submodule final String submodulePath; - final boolean hasSubmodule; + final boolean hasSubmodule; if (isSubmodule) { SubmoduleModel submodule = getSubmodule(submodules, repositoryName, matchingPath == null ? null : matchingPath.path); submodulePath = submodule.gitblitPath; @@ -122,7 +122,7 @@ submodulePath = ""; hasSubmodule = false; } - + final Map<ObjectId, List<RefModel>> allRefs = JGitUtils.getAllRefs(r, showRemoteRefs); List<RevCommit> commits; if (pageResults) { @@ -149,6 +149,7 @@ private static final long serialVersionUID = 1L; int counter; + @Override public void populateItem(final Item<RevCommit> item) { final RevCommit entry = item.getModelObject(); final Date date = JGitUtils.getCommitDate(entry); @@ -195,31 +196,37 @@ TreePage.class, WicketUtils.newObjectParameter( repositoryName, entry.getName())); WicketUtils.setCssClass(commitHash, "shortsha1"); - WicketUtils.setHtmlTooltip(commitHash, entry.getName()); + WicketUtils.setHtmlTooltip(commitHash, entry.getName()); item.add(commitHash); - + Fragment links = new Fragment("historyLinks", "treeLinks", this); links.add(new BookmarkablePageLink<Void>("commitdiff", CommitDiffPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName()))); item.add(links); } else if (isSubmodule) { // submodule - item.add(new Label("hashLabel", submodulePath + "@")); Repository repository = GitBlit.self().getRepository(repositoryName); String submoduleId = JGitUtils.getSubmoduleCommitId(repository, path, entry); repository.close(); - LinkPanel commitHash = new LinkPanel("hashLink", null, submoduleId.substring(0, hashLen), - TreePage.class, WicketUtils.newObjectParameter( - submodulePath, submoduleId)); - WicketUtils.setCssClass(commitHash, "shortsha1"); - WicketUtils.setHtmlTooltip(commitHash, submoduleId); - item.add(commitHash.setEnabled(hasSubmodule)); - + if (StringUtils.isEmpty(submoduleId)) { + // not a submodule at this commit, just a matching path + item.add(new Label("hashLabel").setVisible(false)); + item.add(new Label("hashLink").setVisible(false)); + } else { + // really a submodule + item.add(new Label("hashLabel", submodulePath + "@")); + LinkPanel commitHash = new LinkPanel("hashLink", null, submoduleId.substring(0, hashLen), + TreePage.class, WicketUtils.newObjectParameter( + submodulePath, submoduleId)); + WicketUtils.setCssClass(commitHash, "shortsha1"); + WicketUtils.setHtmlTooltip(commitHash, submoduleId); + item.add(commitHash.setEnabled(hasSubmodule)); + } Fragment links = new Fragment("historyLinks", "treeLinks", this); links.add(new BookmarkablePageLink<Void>("commitdiff", CommitDiffPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName()))); item.add(links); - } else { + } else { // commit item.add(new Label("hashLabel", getString("gb.blob") + "@")); LinkPanel commitHash = new LinkPanel("hashLink", null, entry.getName().substring(0, hashLen), @@ -228,7 +235,7 @@ WicketUtils.setCssClass(commitHash, "sha1"); WicketUtils.setHtmlTooltip(commitHash, entry.getName()); item.add(commitHash); - + Fragment links = new Fragment("historyLinks", "blobLinks", this); links.add(new BookmarkablePageLink<Void>("commitdiff", CommitDiffPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName()))); @@ -270,7 +277,7 @@ public boolean hasMore() { return hasMore; } - + protected SubmoduleModel getSubmodule(Map<String, SubmoduleModel> submodules, String repositoryName, String path) { SubmoduleModel model = submodules.get(path); if (model == null) { @@ -283,7 +290,7 @@ // extract the repository name from the clone url List<String> patterns = GitBlit.getStrings(Keys.git.submoduleUrlPatterns); String submoduleName = StringUtils.extractRepositoryPath(model.url, patterns.toArray(new String[0])); - + // determine the current path for constructing paths relative // to the current repository String currentPath = ""; @@ -303,7 +310,7 @@ if (submoduleName.lastIndexOf('/') > -1) { String name = submoduleName.substring(submoduleName.lastIndexOf('/') + 1); candidates.add(currentPath + StringUtils.stripDotGit(name)); - candidates.add(currentPath + candidates.get(candidates.size() - 1) + ".git"); + candidates.add(candidates.get(candidates.size() - 1) + ".git"); } // absolute @@ -326,10 +333,10 @@ return model; } } - + // we do not have a copy of the submodule, but we need a path model.gitblitPath = candidates.get(0); return model; - } + } } } -- Gitblit v1.9.1