From 0a704fd39ac876fee9bda3a78469209ee9afa4e2 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Thu, 05 Sep 2013 14:09:53 -0400
Subject: [PATCH] Updated binary extensions and Lucene ignore extensions
---
src/main/java/com/gitblit/wicket/panels/BranchesPanel.java | 51 ++++++++++++++++++++++++++++++++++-----------------
1 files changed, 34 insertions(+), 17 deletions(-)
diff --git a/src/main/java/com/gitblit/wicket/panels/BranchesPanel.java b/src/main/java/com/gitblit/wicket/panels/BranchesPanel.java
index 7aa185b..dba4089 100644
--- a/src/main/java/com/gitblit/wicket/panels/BranchesPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/BranchesPanel.java
@@ -15,11 +15,13 @@
*/
package com.gitblit.wicket.panels;
+import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.link.ExternalLink;
@@ -29,6 +31,9 @@
import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.ListDataProvider;
import org.apache.wicket.model.StringResourceModel;
+import org.apache.wicket.protocol.http.RequestUtils;
+import org.apache.wicket.request.target.basic.RedirectRequestTarget;
+import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import com.gitblit.Constants;
@@ -194,28 +199,40 @@
return;
}
final String branch = entry.getName();
- boolean success = JGitUtils.deleteBranchRef(r, branch);
- if (success) {
- // clear commit cache
- CommitCache.instance().clear(repositoryModel.name, branch);
+ Ref ref = null;
+ try {
+ ref = r.getRef(branch);
+ if (ref == null && !branch.startsWith(Constants.R_HEADS)) {
+ ref = r.getRef(Constants.R_HEADS + branch);
+ }
+ } catch (IOException e) {
+ }
+ if (ref != null) {
+ boolean success = JGitUtils.deleteBranchRef(r, ref.getName());
+ if (success) {
+ // clear commit cache
+ CommitCache.instance().clear(repositoryModel.name, branch);
+
+ // optionally update reflog
+ if (RefLogUtils.hasRefLogBranch(r)) {
+ UserModel user = GitBlitWebSession.get().getUser();
+ RefLogUtils.deleteRef(user, r, ref);
+ }
+ }
- // optionally update reflog
- if (RefLogUtils.hasRefLogBranch(r)) {
- UserModel user = GitBlitWebSession.get().getUser();
- success = RefLogUtils.deleteRef(user, r, branch);
+ if (success) {
+ info(MessageFormat.format("Branch \"{0}\" deleted", branch));
+ } else {
+ error(MessageFormat.format("Failed to delete branch \"{0}\"", branch));
}
}
-
r.close();
- if (success) {
- info(MessageFormat.format("Branch \"{0}\" deleted", branch));
- // redirect to the owning page
- setResponsePage(getPage().getClass(), WicketUtils.newRepositoryParameter(repositoryModel.name));
- }
- else {
- error(MessageFormat.format("Failed to delete branch \"{0}\"", branch));
- }
+ // redirect to the owning page
+ PageParameters params = WicketUtils.newRepositoryParameter(repositoryModel.name);
+ String relativeUrl = urlFor(getPage().getClass(), params).toString();
+ String absoluteUrl = RequestUtils.toAbsolutePath(relativeUrl);
+ getRequestCycle().setRequestTarget(new RedirectRequestTarget(absoluteUrl));
}
};
--
Gitblit v1.9.1