From b85642562a6cf1d0adacc43521f01ce8358aaacf Mon Sep 17 00:00:00 2001
From: Stardrad Yin <yin8086@gmail.com>
Date: Tue, 04 Mar 2014 08:16:27 -0500
Subject: [PATCH] Add Chinese translation for 1.4.0
---
src/main/java/com/gitblit/wicket/panels/BranchesPanel.java | 62 +++++++++++++++++--------------
1 files changed, 34 insertions(+), 28 deletions(-)
diff --git a/src/main/java/com/gitblit/wicket/panels/BranchesPanel.java b/src/main/java/com/gitblit/wicket/panels/BranchesPanel.java
index 85d0029..28751fa 100644
--- a/src/main/java/com/gitblit/wicket/panels/BranchesPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/BranchesPanel.java
@@ -37,11 +37,10 @@
import org.eclipse.jgit.lib.Repository;
import com.gitblit.Constants;
-import com.gitblit.GitBlit;
-import com.gitblit.SyndicationServlet;
import com.gitblit.models.RefModel;
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.UserModel;
+import com.gitblit.servlet.SyndicationServlet;
import com.gitblit.utils.CommitCache;
import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.RefLogUtils;
@@ -101,15 +100,16 @@
// branches page
add(new Label("branches", new StringResourceModel("gb.branches", this, null)));
}
-
+
// only allow delete if we have multiple branches
final boolean showDelete = showAdmin && branches.size() > 1;
-
+
ListDataProvider<RefModel> branchesDp = new ListDataProvider<RefModel>(branches);
DataView<RefModel> branchesView = new DataView<RefModel>("branch", branchesDp) {
private static final long serialVersionUID = 1L;
int counter;
+ @Override
public void populateItem(final Item<RefModel> item) {
final RefModel entry = item.getModelObject();
@@ -136,7 +136,7 @@
WicketUtils.setHtmlTooltip(shortlog, shortMessage);
}
item.add(shortlog);
-
+
if (maxCount <= 0) {
Fragment fragment = new Fragment("branchLinks", showDelete? "branchPageAdminLinks" : "branchPageLinks", this);
fragment.add(new BookmarkablePageLink<Void>("log", LogPage.class, WicketUtils
@@ -189,9 +189,9 @@
@Override
public void onClick() {
- Repository r = GitBlit.self().getRepository(repositoryModel.name);
+ Repository r = app().repositories().getRepository(repositoryModel.name);
if (r == null) {
- if (GitBlit.self().isCollectingGarbage(repositoryModel.name)) {
+ if (app().repositories().isCollectingGarbage(repositoryModel.name)) {
error(MessageFormat.format(getString("gb.busyCollectingGarbage"), repositoryModel.name));
} else {
error(MessageFormat.format("Failed to find repository {0}", repositoryModel.name));
@@ -199,29 +199,35 @@
return;
}
final String branch = entry.getName();
- boolean success = JGitUtils.deleteBranchRef(r, branch);
- if (success) {
- // clear commit cache
- CommitCache.instance().clear(repositoryModel.name, branch);
-
- // optionally update reflog
- if (RefLogUtils.hasRefLogBranch(r)) {
- UserModel user = GitBlitWebSession.get().getUser();
- success = RefLogUtils.deleteRef(user, r, 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);
+ }
+ }
+
+ 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();
@@ -229,7 +235,7 @@
getRequestCycle().setRequestTarget(new RedirectRequestTarget(absoluteUrl));
}
};
-
+
deleteLink.add(new JavascriptEventConfirmation("onclick", MessageFormat.format(
"Delete branch \"{0}\"?", entry.displayName )));
return deleteLink;
--
Gitblit v1.9.1