From 4fcac9d2cbdafb51e3ee9ca3b3da64fd86103174 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Tue, 26 Nov 2013 15:58:15 -0500
Subject: [PATCH] Remove artifact setting from manager dialog

---
 src/main/java/com/gitblit/BranchGraphServlet.java |   60 ++++++++++++++++++++++++++++++++----------------------------
 1 files changed, 32 insertions(+), 28 deletions(-)

diff --git a/src/main/java/com/gitblit/BranchGraphServlet.java b/src/main/java/com/gitblit/BranchGraphServlet.java
index f46b8e6..293a291 100644
--- a/src/main/java/com/gitblit/BranchGraphServlet.java
+++ b/src/main/java/com/gitblit/BranchGraphServlet.java
@@ -55,9 +55,9 @@
 
 /**
  * Handles requests for branch graphs
- * 
+ *
  * @author James Moger
- * 
+ *
  */
 public class BranchGraphServlet extends HttpServlet {
 
@@ -82,7 +82,7 @@
 
 	/**
 	 * Returns an url to this servlet for the specified parameters.
-	 * 
+	 *
 	 * @param baseURL
 	 * @param repository
 	 * @param objectId
@@ -148,37 +148,40 @@
 			}
 
 			// fetch the requested commits plus some extra so that the last
-			// commit displayed *likely* has correct lane assignments  
+			// commit displayed *likely* has correct lane assignments
 			CommitList commitList = new CommitList();
 			commitList.source(rw);
 			commitList.fillTo(2*Math.max(requestedCommits, maxCommits));
 
 			// determine the appropriate width for the image
-			int numLanes = 0;
+			int numLanes = 1;
 			int numCommits = Math.min(requestedCommits, commitList.size());
-			Set<String> parents = new TreeSet<String>();
-			for (int i = 0; i < commitList.size(); i++) {
-				PlotCommit<Lane> commit = commitList.get(i);
-				boolean checkLane = false;
-				
-				if (i < numCommits) {
-					// commit in visible list
-					checkLane = true;
-					
-					// remember parents
-					for (RevCommit p : commit.getParents()) {
-						parents.add(p.getName());
+			if (numCommits > 1) {
+				// determine graph width
+				Set<String> parents = new TreeSet<String>();
+				for (int i = 0; i < commitList.size(); i++) {
+					PlotCommit<Lane> commit = commitList.get(i);
+					boolean checkLane = false;
+
+					if (i < numCommits) {
+						// commit in visible list
+						checkLane = true;
+
+						// remember parents
+						for (RevCommit p : commit.getParents()) {
+							parents.add(p.getName());
+						}
+					} else if (parents.contains(commit.getName())) {
+						// commit outside visible list, but it is a parent of a
+						// commit in the visible list so we need to know it's lane
+						// assignment
+						checkLane = true;
 					}
-				} else if (parents.contains(commit.getName())) {
-					// commit outside visible list, but it is a parent of a
-					// commit in the visible list so we need to know it's lane
-					// assignment
-					checkLane = true;
-				}
-				
-				if (checkLane) {
-					int pos = commit.getLane().getPosition();
-					numLanes = Math.max(numLanes, pos + 1);
+
+					if (checkLane) {
+						int pos = commit.getLane().getPosition();
+						numLanes = Math.max(numLanes, pos + 1);
+					}
 				}
 			}
 
@@ -187,6 +190,7 @@
 
 			// create an image buffer and render the lanes
 			BufferedImage image = new BufferedImage(graphWidth, rowHeight*numCommits, BufferedImage.TYPE_INT_ARGB);
+
 			Graphics2D g = null;
 			try {
 				g = image.createGraphics();
@@ -211,7 +215,7 @@
 
 			// write the image buffer to the client
 			response.setContentType("image/png");
-			if (numCommits > 0) {
+			if (numCommits > 1) {
 				response.setHeader("Cache-Control", "public, max-age=60, must-revalidate");
 				response.setDateHeader("Last-Modified", JGitUtils.getCommitDate(commitList.get(0)).getTime());
 			}

--
Gitblit v1.9.1