From df162cdbdfeb5fbf5500546c9783e1685be6980f Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Wed, 04 Jan 2012 08:42:54 -0500
Subject: [PATCH] Federation pull_scripts request. Documentation.
---
src/com/gitblit/wicket/pages/EditRepositoryPage.java | 72 +++++++++++++++++++++++++++++++-----
1 files changed, 62 insertions(+), 10 deletions(-)
diff --git a/src/com/gitblit/wicket/pages/EditRepositoryPage.java b/src/com/gitblit/wicket/pages/EditRepositoryPage.java
index 56e44f8..0f3a0bb 100644
--- a/src/com/gitblit/wicket/pages/EditRepositoryPage.java
+++ b/src/com/gitblit/wicket/pages/EditRepositoryPage.java
@@ -19,9 +19,11 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.wicket.PageParameters;
import org.apache.wicket.extensions.markup.html.form.palette.Palette;
@@ -48,6 +50,7 @@
import com.gitblit.utils.StringUtils;
import com.gitblit.wicket.GitBlitWebSession;
import com.gitblit.wicket.WicketUtils;
+import com.gitblit.wicket.panels.BulletListPanel;
public class EditRepositoryPage extends RootSubPage {
@@ -55,7 +58,7 @@
private boolean isAdmin;
- private IModel<String> mailRecipients;
+ private IModel<String> mailingLists;
public EditRepositoryPage() {
// create constructor
@@ -80,6 +83,9 @@
List<String> federationSets = new ArrayList<String>();
List<String> repositoryUsers = new ArrayList<String>();
List<String> repositoryTeams = new ArrayList<String>();
+ List<String> preReceiveScripts = new ArrayList<String>();
+ List<String> postReceiveScripts = new ArrayList<String>();
+
if (isCreate) {
super.setupPage(getString("gb.newRepository"), "");
} else {
@@ -101,13 +107,31 @@
// teams palette
final Palette<String> teamsPalette = new Palette<String>("teams", new ListModel<String>(
repositoryTeams), new CollectionModel<String>(GitBlit.self().getAllTeamnames()),
- new ChoiceRenderer<String>("", ""), 10, false);
+ new ChoiceRenderer<String>("", ""), 5, false);
// federation sets palette
List<String> sets = GitBlit.getStrings(Keys.federation.sets);
final Palette<String> federationSetsPalette = new Palette<String>("federationSets",
new ListModel<String>(federationSets), new CollectionModel<String>(sets),
- new ChoiceRenderer<String>("", ""), 10, false);
+ new ChoiceRenderer<String>("", ""), 5, false);
+
+ // pre-receive palette
+ if (repositoryModel.preReceiveScripts != null) {
+ preReceiveScripts.addAll(repositoryModel.preReceiveScripts);
+ }
+ final Palette<String> preReceivePalette = new Palette<String>("preReceiveScripts",
+ new ListModel<String>(preReceiveScripts), new CollectionModel<String>(GitBlit
+ .self().getPreReceiveScriptsUnused(repositoryModel)),
+ new ChoiceRenderer<String>("", ""), 12, true);
+
+ // post-receive palette
+ if (repositoryModel.postReceiveScripts != null) {
+ postReceiveScripts.addAll(repositoryModel.postReceiveScripts);
+ }
+ final Palette<String> postReceivePalette = new Palette<String>("postReceiveScripts",
+ new ListModel<String>(postReceiveScripts), new CollectionModel<String>(GitBlit
+ .self().getPostReceiveScriptsUnused(repositoryModel)),
+ new ChoiceRenderer<String>("", ""), 12, true);
CompoundPropertyModel<RepositoryModel> model = new CompoundPropertyModel<RepositoryModel>(
repositoryModel);
@@ -172,12 +196,34 @@
}
}
- // set mail recipients
- String ml = mailRecipients.getObject();
+ // set mailing lists
+ String ml = mailingLists.getObject();
if (!StringUtils.isEmpty(ml)) {
- List<String> list = StringUtils.getStringsFromValue(ml.trim(), " ");
- repositoryModel.mailRecipients = list;
+ Set<String> list = new HashSet<String>();
+ for (String address : ml.split("(,|\\s)")) {
+ if (StringUtils.isEmpty(address)) {
+ continue;
+ }
+ list.add(address.toLowerCase());
+ }
+ repositoryModel.mailingLists = new ArrayList<String>(list);
}
+
+ // pre-receive scripts
+ List<String> preReceiveScripts = new ArrayList<String>();
+ Iterator<String> pres = preReceivePalette.getSelectedChoices();
+ while (pres.hasNext()) {
+ preReceiveScripts.add(pres.next());
+ }
+ repositoryModel.preReceiveScripts = preReceiveScripts;
+
+ // post-receive scripts
+ List<String> postReceiveScripts = new ArrayList<String>();
+ Iterator<String> post = postReceivePalette.getSelectedChoices();
+ while (post.hasNext()) {
+ postReceiveScripts.add(post.next());
+ }
+ repositoryModel.postReceiveScripts = postReceiveScripts;
// save the repository
GitBlit.self().updateRepositoryModel(oldName, repositoryModel, isCreate);
@@ -240,12 +286,18 @@
form.add(new CheckBox("showReadme"));
form.add(new CheckBox("skipSizeCalculation"));
form.add(new CheckBox("skipSummaryMetrics"));
- mailRecipients = new Model<String>(repositoryModel.mailRecipients == null ? ""
- : StringUtils.flattenStrings(repositoryModel.mailRecipients, " "));
- form.add(new TextField<String>("mailRecipients", mailRecipients));
+ mailingLists = new Model<String>(repositoryModel.mailingLists == null ? ""
+ : StringUtils.flattenStrings(repositoryModel.mailingLists, " "));
+ form.add(new TextField<String>("mailingLists", mailingLists));
form.add(usersPalette);
form.add(teamsPalette);
form.add(federationSetsPalette);
+ form.add(preReceivePalette);
+ form.add(new BulletListPanel("inheritedPreReceive", "inherited", GitBlit.self()
+ .getPreReceiveScriptsInherited(repositoryModel)));
+ form.add(postReceivePalette);
+ form.add(new BulletListPanel("inheritedPostReceive", "inherited", GitBlit.self()
+ .getPostReceiveScriptsInherited(repositoryModel)));
form.add(new Button("save"));
Button cancel = new Button("cancel") {
--
Gitblit v1.9.1