James Moger
2013-06-12 0078c2b7816bcfc32078226e263ce346926014d0
Workaround incomplete blame commit dara (issue-254)
3 files modified
41 ■■■■ changed files
releases.moxie 4 ●●● patch | view | raw | blame | history
src/main/java/com/gitblit/models/AnnotatedLine.java 13 ●●●● patch | view | raw | blame | history
src/main/java/com/gitblit/wicket/pages/BlamePage.java 24 ●●●●● patch | view | raw | blame | history
releases.moxie
@@ -28,7 +28,9 @@
     - Ensure Redmine url is properly formatted (issue 223)
     - Use standard ServletRequestWrapper instead of custom wrapper (issue 224)
     - Switch commit message back to a pre and ensure that it is properly escaped when combined with commit message regex substitution (issue 242)
     - Fixed AddIndexedBranch tool --branch parameter (issue 247)
     - Improve NPE handling for hook script enumeration (issue-253)
     - Workaround missing commit information in blame page (JGit bug 374382, issue-254)
    changes:
     - Improved error logging for servlet containers which provide a null contextFolder (issue 199)
@@ -82,7 +84,7 @@
    - Lukasz Jader
    - Martijn Laan
    - Matthias Bauer
    - Michaël Pailloncy
    - Micha�l Pailloncy
    - Michael Schaefers
    - Philip Boutros
    - Rafael Cavazin
src/main/java/com/gitblit/models/AnnotatedLine.java
@@ -18,6 +18,7 @@
import java.io.Serializable;
import java.util.Date;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.revwalk.RevCommit;
/**
@@ -38,9 +39,15 @@
    public final String data;
    public AnnotatedLine(RevCommit commit, int lineNumber, String data) {
        this.commitId = commit.getName();
        this.author = commit.getAuthorIdent().getName();
        this.when = commit.getAuthorIdent().getWhen();
        if (commit == null) {
            this.commitId = ObjectId.zeroId().getName();
            this.author = "?";
            this.when = new Date(0);
        } else {
            this.commitId = commit.getName();
            this.author = commit.getAuthorIdent().getName();
            this.when = commit.getAuthorIdent().getWhen();
        }
        this.lineNumber = lineNumber;
        this.data = data;
    }
src/main/java/com/gitblit/wicket/pages/BlamePage.java
@@ -27,6 +27,7 @@
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;
@@ -96,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();
@@ -105,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;