diff options
author | James Moger <james.moger@gitblit.com> | 2013-07-31 15:55:28 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2013-07-31 15:56:11 -0400 |
commit | 88ec32f91b3df15e063a2b2dcea3c90f3c65d835 (patch) | |
tree | 4a820a90e4f3a0286fef6c6058072cea1a24314a /src/main/java/com/gitblit/wicket/panels | |
parent | e523d77e5f9d61a7cbf0b2242c8795a22fdf7b45 (diff) | |
download | gitblit-88ec32f91b3df15e063a2b2dcea3c90f3c65d835.tar.gz gitblit-88ec32f91b3df15e063a2b2dcea3c90f3c65d835.zip |
Improvements to reflog branch deletion
Diffstat (limited to 'src/main/java/com/gitblit/wicket/panels')
-rw-r--r-- | src/main/java/com/gitblit/wicket/panels/BranchesPanel.java | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/src/main/java/com/gitblit/wicket/panels/BranchesPanel.java b/src/main/java/com/gitblit/wicket/panels/BranchesPanel.java index 85d00296..dba40897 100644 --- a/src/main/java/com/gitblit/wicket/panels/BranchesPanel.java +++ b/src/main/java/com/gitblit/wicket/panels/BranchesPanel.java @@ -199,29 +199,35 @@ public class BranchesPanel extends BasePanel { 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();
|