From 56d1c441d3b591c161e36e5a001cca83a7d17c93 Mon Sep 17 00:00:00 2001 From: Dongsu, KIM <ds5apn@gmail.com> Date: Fri, 19 Jul 2013 05:39:08 -0400 Subject: [PATCH] Update Korean Translation --- src/main/java/com/gitblit/wicket/pages/BlamePage.java | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 50 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gitblit/wicket/pages/BlamePage.java b/src/main/java/com/gitblit/wicket/pages/BlamePage.java index d76181d..5148915 100644 --- a/src/main/java/com/gitblit/wicket/pages/BlamePage.java +++ b/src/main/java/com/gitblit/wicket/pages/BlamePage.java @@ -27,12 +27,15 @@ import org.apache.wicket.markup.repeater.data.DataView; import org.apache.wicket.markup.repeater.data.ListDataProvider; import org.eclipse.jgit.lib.Constants; +import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.revwalk.RevCommit; import com.gitblit.GitBlit; import com.gitblit.Keys; import com.gitblit.models.AnnotatedLine; +import com.gitblit.models.PathModel; import com.gitblit.utils.DiffUtils; +import com.gitblit.utils.JGitUtils; import com.gitblit.utils.StringUtils; import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.panels.CommitHeaderPanel; @@ -69,6 +72,24 @@ "EEEE, MMMM d, yyyy HH:mm Z"); final DateFormat df = new SimpleDateFormat(format); df.setTimeZone(getTimeZone()); + + PathModel pathModel = null; + List<PathModel> paths = JGitUtils.getFilesInPath(getRepository(), StringUtils.getRootPath(blobPath), commit); + for (PathModel path : paths) { + if (path.path.equals(blobPath)) { + pathModel = path; + break; + } + } + + if (pathModel == null) { + add(new Label("annotation").setVisible(false)); + add(new Label("missingBlob", missingBlob(blobPath, commit)).setEscapeModelStrings(false)); + return; + } + + add(new Label("missingBlob").setVisible(false)); + List<AnnotatedLine> lines = DiffUtils.blame(getRepository(), blobPath, objectId); ListDataProvider<AnnotatedLine> blameDp = new ListDataProvider<AnnotatedLine>(lines); DataView<AnnotatedLine> blameView = new DataView<AnnotatedLine>("annotation", blameDp) { @@ -76,6 +97,7 @@ private int count; private String lastCommitId = ""; private boolean showInitials = true; + private String zeroId = ObjectId.zeroId().getName(); public void populateItem(final Item<AnnotatedLine> item) { AnnotatedLine entry = item.getModelObject(); @@ -85,14 +107,20 @@ if (!lastCommitId.equals(entry.commitId)) { lastCommitId = entry.commitId; count++; - // show the link for first line - LinkPanel commitLink = new LinkPanel("commit", null, - getShortObjectId(entry.commitId), CommitPage.class, - newCommitParameter(entry.commitId)); - WicketUtils.setHtmlTooltip(commitLink, - MessageFormat.format("{0}, {1}", entry.author, df.format(entry.when))); - item.add(commitLink); - showInitials = true; + if (zeroId.equals(entry.commitId)) { + // unknown commit + item.add(new Label("commit", "<?>")); + showInitials = false; + } else { + // show the link for first line + LinkPanel commitLink = new LinkPanel("commit", null, + getShortObjectId(entry.commitId), CommitPage.class, + newCommitParameter(entry.commitId)); + WicketUtils.setHtmlTooltip(commitLink, + MessageFormat.format("{0}, {1}", entry.author, df.format(entry.when))); + item.add(commitLink); + showInitials = true; + } } else { if (showInitials) { showInitials = false; @@ -126,4 +154,18 @@ protected String getPageName() { return getString("gb.blame"); } + + @Override + protected Class<? extends BasePage> getRepoNavPageClass() { + return TreePage.class; + } + + protected String missingBlob(String blobPath, RevCommit commit) { + StringBuilder sb = new StringBuilder(); + sb.append("<div class=\"alert alert-error\">"); + String pattern = getString("gb.doesNotExistInTree").replace("{0}", "<b>{0}</b>").replace("{1}", "<b>{1}</b>"); + sb.append(MessageFormat.format(pattern, blobPath, commit.getTree().getId().getName())); + sb.append("</div>"); + return sb.toString(); + } } -- Gitblit v1.9.1