From 9bc17d16ea48a7978b198126d346828b1d24fe4e Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Mon, 18 Apr 2011 22:29:20 -0400 Subject: [PATCH] Color-coded change type indicator with tooltip for changed paths. --- src/com/gitblit/utils/JGitUtils.java | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/com/gitblit/utils/JGitUtils.java b/src/com/gitblit/utils/JGitUtils.java index 49fbf1e..b126768 100644 --- a/src/com/gitblit/utils/JGitUtils.java +++ b/src/com/gitblit/utils/JGitUtils.java @@ -19,6 +19,7 @@ import org.eclipse.jgit.diff.DiffEntry; import org.eclipse.jgit.diff.DiffFormatter; import org.eclipse.jgit.diff.RawTextComparator; +import org.eclipse.jgit.diff.DiffEntry.ChangeType; import org.eclipse.jgit.errors.ConfigInvalidException; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; @@ -49,6 +50,7 @@ import com.gitblit.wicket.models.Metric; import com.gitblit.wicket.models.PathModel; +import com.gitblit.wicket.models.PathModel.PathChangeModel; import com.gitblit.wicket.models.RefModel; import com.gitblit.wicket.models.TicketModel; import com.gitblit.wicket.models.TicketModel.Comment; @@ -256,13 +258,13 @@ return list; } - public static List<PathModel> getFilesInCommit(Repository r, String commitId) { + public static List<PathChangeModel> getFilesInCommit(Repository r, String commitId) { RevCommit commit = getCommit(r, commitId); return getFilesInCommit(r, commit); } - public static List<PathModel> getFilesInCommit(Repository r, RevCommit commit) { - List<PathModel> list = new ArrayList<PathModel>(); + public static List<PathChangeModel> getFilesInCommit(Repository r, RevCommit commit) { + List<PathChangeModel> list = new ArrayList<PathChangeModel>(); try { final RevWalk rw = new RevWalk(r); RevCommit parent = rw.parseCommit(commit.getParent(0).getId()); @@ -283,7 +285,11 @@ df.setDetectRenames(true); List<DiffEntry> diffs = df.scan(parentTree, commitTree); for (DiffEntry diff : diffs) { - list.add(new PathModel(diff.getNewPath(), diff.getNewPath(), 0, diff.getNewMode().getBits(), commit.getId().getName())); + if (diff.getChangeType().equals(ChangeType.DELETE)) { + list.add(new PathChangeModel(diff.getOldPath(), diff.getOldPath(), 0, diff.getNewMode().getBits(), commit.getId().getName(), diff.getChangeType())); + } else { + list.add(new PathChangeModel(diff.getNewPath(), diff.getNewPath(), 0, diff.getNewMode().getBits(), commit.getId().getName(), diff.getChangeType())); + } } } catch (Throwable t) { LOGGER.error("failed to determine files in commit!", t); -- Gitblit v1.9.1