Make the variables / messages more consistant
| | |
| | |
|
| | | public static final String DEFAULT_BRANCH = "default";
|
| | |
|
| | | public static String CUSTOM_DEFINED_PROP_SECTION = "gitblit";
|
| | | public static String CUSTOM_FIELDS_PROP_SECTION = "gitblit";
|
| | |
|
| | | public static String CUSTOM_DEFINED_PROP_SUBSECTION = "customDefinedProperties";
|
| | | public static String CUSTOM_FIELDS_PROP_SUBSECTION = "customFields";
|
| | |
|
| | | public static String getGitBlitVersion() {
|
| | | return NAME + " v" + VERSION;
|
| | |
| | | "gitblit", null, "indexBranch")));
|
| | |
|
| | | // Custom defined properties
|
| | | model.customDefinedProperties = new HashMap<String, String>();
|
| | | for (String aProperty : config.getNames(Constants.CUSTOM_DEFINED_PROP_SECTION, Constants.CUSTOM_DEFINED_PROP_SUBSECTION)) {
|
| | | model.customDefinedProperties.put(aProperty, config.getString(Constants.CUSTOM_DEFINED_PROP_SECTION, Constants.CUSTOM_DEFINED_PROP_SUBSECTION, aProperty));
|
| | | model.customFields = new HashMap<String, String>();
|
| | | for (String aProperty : config.getNames(Constants.CUSTOM_FIELDS_PROP_SECTION, Constants.CUSTOM_FIELDS_PROP_SUBSECTION)) {
|
| | | model.customFields.put(aProperty, config.getString(Constants.CUSTOM_FIELDS_PROP_SECTION, Constants.CUSTOM_FIELDS_PROP_SUBSECTION, aProperty));
|
| | | }
|
| | | }
|
| | | model.HEAD = JGitUtils.getHEADRef(r);
|
| | |
| | | updateList(config, "indexBranch", repository.indexedBranches);
|
| | |
|
| | | // User Defined Properties
|
| | | for (Entry<String, String> singleProperty : repository.customDefinedProperties.entrySet()) {
|
| | | config.setString(Constants.CUSTOM_DEFINED_PROP_SECTION, Constants.CUSTOM_DEFINED_PROP_SUBSECTION, singleProperty.getKey(), singleProperty.getValue());
|
| | | for (Entry<String, String> singleProperty : repository.customFields.entrySet()) {
|
| | | config.setString(Constants.CUSTOM_FIELDS_PROP_SECTION, Constants.CUSTOM_FIELDS_PROP_SUBSECTION, singleProperty.getKey(), singleProperty.getValue());
|
| | | }
|
| | |
|
| | | try {
|
| | |
| | | public List<String> preReceiveScripts;
|
| | | public List<String> postReceiveScripts;
|
| | | public List<String> mailingLists;
|
| | | public Map<String, String> customDefinedProperties;
|
| | | public Map<String, String> customFields;
|
| | | private String displayName;
|
| | |
|
| | | public RepositoryModel() {
|
| | |
| | | gb.preReceiveScripts = pre-receive scripts
|
| | | gb.postReceiveScripts = post-receive scripts
|
| | | gb.hookScripts = hook scripts
|
| | | gb.customDefinedProperties = custom defined properties
|
| | | gb.customDefinedPropertiesDescription = custom properties available to groovy hooks
|
| | | gb.customFields = custom fields
|
| | | gb.customFieldsDescription = custom fields available to groovy hooks
|
| | | gb.accessPermissions = access permissions
|
| | | gb.filters = filters
|
| | | gb.generalDescription = common settings
|
| | |
| | | <tr><td colspan="2"><h3><wicket:message key="gb.hookScripts"></wicket:message> <small><wicket:message key="gb.hookScriptsDescription"></wicket:message></small></h3></td></tr>
|
| | | <tr><th style="vertical-align: top;"><wicket:message key="gb.preReceiveScripts"></wicket:message><p></p><span wicket:id="inheritedPreReceive"></span></th><td style="padding:2px;"><span wicket:id="preReceiveScripts"></span></td></tr>
|
| | | <tr><th style="vertical-align: top;"><wicket:message key="gb.postReceiveScripts"></wicket:message><p></p><span wicket:id="inheritedPostReceive"></span></th><td style="padding:2px;"><span wicket:id="postReceiveScripts"></span></td></tr>
|
| | | <div wicket:id="customDefinedPropertiesSection">
|
| | | <tr><td colspan="2"><h3><wicket:message key="gb.customDefinedProperties"></wicket:message> <small><wicket:message key="gb.customDefinedPropertiesDescription"></wicket:message></small></h3></td></tr>
|
| | | <tr wicket:id="customDefinedProperties"><th style="vertical-align: top;"><span wicket:id="customLabel"></span></th><td class="edit"><input class="span8" type="text" wicket:id="customValue" size="30" tabindex="16" /></td></tr>
|
| | | <div wicket:id="customFiledsSection">
|
| | | <tr><td colspan="2"><h3><wicket:message key="gb.customFields"></wicket:message> <small><wicket:message key="gb.customFieldsDescription"></wicket:message></small></h3></td></tr>
|
| | | <tr wicket:id="customFieldsListView"><th style="vertical-align: top;"><span wicket:id="customFieldLabel"></span></th><td class="edit"><input class="span8" type="text" wicket:id="customFieldValue" size="30" tabindex="16" /></td></tr>
|
| | | </div>
|
| | | <tr><td colspan='2'><div class="form-actions"><input class="btn btn-primary" type="submit" value="Save" wicket:message="value:gb.save" wicket:id="save" tabindex="17" /> <input class="btn" type="submit" value="Cancel" wicket:message="value:gb.cancel" wicket:id="cancel" tabindex="18" /></div></td></tr>
|
| | | </tbody>
|
| | |
| | | definedProperties.add(new AbstractMap.SimpleEntry<String, String>(customFieldProperty[0], customFieldProperty[1]));
|
| | | }
|
| | |
|
| | | final ListView<Entry<String, String>> customDefinedProperties = new ListView<Entry<String, String>>("customDefinedProperties", definedProperties) {
|
| | | final ListView<Entry<String, String>> customFieldsListView = new ListView<Entry<String, String>>("customFieldsListView", definedProperties) {
|
| | | @Override
|
| | | protected void populateItem(ListItem<Entry<String, String>> item) {
|
| | | String value = repositoryModel.customDefinedProperties.get(item.getModelObject().getKey());
|
| | | String value = repositoryModel.customFields.get(item.getModelObject().getKey());
|
| | |
|
| | | item.add(new Label(item.getModelObject().getKey(), item.getModelObject().getValue())); // Used to get the key later
|
| | | item.add(new Label("customLabel", item.getModelObject().getValue()));
|
| | | item.add(new TextField<String>("customValue", new Model<String>(value)));
|
| | | item.add(new Label("customFieldLabel", item.getModelObject().getValue()));
|
| | | item.add(new TextField<String>("customFieldValue", new Model<String>(value)));
|
| | | }
|
| | | };
|
| | | customDefinedProperties.setReuseItems(true);
|
| | | customFieldsListView.setReuseItems(true);
|
| | |
|
| | | CompoundPropertyModel<RepositoryModel> model = new CompoundPropertyModel<RepositoryModel>(
|
| | | repositoryModel);
|
| | |
| | | repositoryModel.postReceiveScripts = postReceiveScripts;
|
| | |
|
| | | // Loop over each of the user defined properties
|
| | | for (int i = 0; i < customDefinedProperties.size(); i++) {
|
| | | ListItem<ListItemModel<String>> item = (ListItem<ListItemModel<String>>) customDefinedProperties.get(i);
|
| | | for (int i = 0; i < customFieldsListView.size(); i++) {
|
| | | ListItem<ListItemModel<String>> item = (ListItem<ListItemModel<String>>) customFieldsListView.get(i);
|
| | | String key = item.get(0).getId(); // Item 0 is our 'fake' label
|
| | | String value = ((TextField<String>)item.get(2)).getValue(); // Item 2 is out text box
|
| | |
|
| | | repositoryModel.customDefinedProperties.put(key, value);
|
| | | repositoryModel.customFields.put(key, value);
|
| | | }
|
| | |
|
| | | // save the repository
|
| | |
| | | form.add(new BulletListPanel("inheritedPostReceive", "inherited", GitBlit.self()
|
| | | .getPostReceiveScriptsInherited(repositoryModel)));
|
| | |
|
| | | WebMarkupContainer customDefinedPropertiesSection = new WebMarkupContainer("customDefinedPropertiesSection") {
|
| | | WebMarkupContainer customFiledsSection = new WebMarkupContainer("customFiledsSection") {
|
| | | public boolean isVisible() {
|
| | | return GitBlit.getString(Keys.repository.customFields, "").isEmpty() == false;
|
| | | };
|
| | | };
|
| | | customDefinedPropertiesSection.add(customDefinedProperties);
|
| | | form.add(customDefinedPropertiesSection);
|
| | | customFiledsSection.add(customFieldsListView);
|
| | | form.add(customFiledsSection);
|
| | |
|
| | | form.add(new Button("save"));
|
| | | Button cancel = new Button("cancel") {
|
| | |
| | | public static void startGitBlit() throws Exception { |
| | | wasStarted = GitBlitSuite.startGitblit() == false; |
| | | |
| | | oldSection = Constants.CUSTOM_DEFINED_PROP_SECTION; |
| | | oldSubSection = Constants.CUSTOM_DEFINED_PROP_SUBSECTION; |
| | | oldSection = Constants.CUSTOM_FIELDS_PROP_SECTION; |
| | | oldSubSection = Constants.CUSTOM_FIELDS_PROP_SUBSECTION; |
| | | |
| | | Constants.CUSTOM_DEFINED_PROP_SECTION = "RepositoryModelTest"; |
| | | Constants.CUSTOM_DEFINED_PROP_SUBSECTION = "RepositoryModelTestSubSection"; |
| | | Constants.CUSTOM_FIELDS_PROP_SECTION = "RepositoryModelTest"; |
| | | Constants.CUSTOM_FIELDS_PROP_SUBSECTION = "RepositoryModelTestSubSection"; |
| | | } |
| | | |
| | | @AfterClass |
| | |
| | | if (wasStarted == false) |
| | | GitBlitSuite.stopGitblit(); |
| | | |
| | | Constants.CUSTOM_DEFINED_PROP_SECTION = oldSection; |
| | | Constants.CUSTOM_DEFINED_PROP_SUBSECTION = oldSubSection; |
| | | Constants.CUSTOM_FIELDS_PROP_SECTION = oldSection; |
| | | Constants.CUSTOM_FIELDS_PROP_SUBSECTION = oldSubSection; |
| | | } |
| | | |
| | | @Before |
| | |
| | | Repository r = GitBlitSuite.getHelloworldRepository(); |
| | | StoredConfig config = JGitUtils.readConfig(r); |
| | | |
| | | config.unsetSection(Constants.CUSTOM_DEFINED_PROP_SECTION, Constants.CUSTOM_DEFINED_PROP_SUBSECTION); |
| | | config.setString(Constants.CUSTOM_DEFINED_PROP_SECTION, Constants.CUSTOM_DEFINED_PROP_SUBSECTION, "commitMessageRegEx", "\\d"); |
| | | config.setString(Constants.CUSTOM_DEFINED_PROP_SECTION, Constants.CUSTOM_DEFINED_PROP_SUBSECTION, "anotherProperty", "Hello"); |
| | | config.unsetSection(Constants.CUSTOM_FIELDS_PROP_SECTION, Constants.CUSTOM_FIELDS_PROP_SUBSECTION); |
| | | config.setString(Constants.CUSTOM_FIELDS_PROP_SECTION, Constants.CUSTOM_FIELDS_PROP_SUBSECTION, "commitMessageRegEx", "\\d"); |
| | | config.setString(Constants.CUSTOM_FIELDS_PROP_SECTION, Constants.CUSTOM_FIELDS_PROP_SUBSECTION, "anotherProperty", "Hello"); |
| | | |
| | | config.save(); |
| | | } |
| | |
| | | Repository r = GitBlitSuite.getHelloworldRepository(); |
| | | StoredConfig config = JGitUtils.readConfig(r); |
| | | |
| | | config.unsetSection(Constants.CUSTOM_DEFINED_PROP_SECTION, Constants.CUSTOM_DEFINED_PROP_SUBSECTION); |
| | | config.unsetSection(Constants.CUSTOM_FIELDS_PROP_SECTION, Constants.CUSTOM_FIELDS_PROP_SUBSECTION); |
| | | config.save(); |
| | | } |
| | | |
| | |
| | | RepositoryModel model = GitBlit.self().getRepositoryModel( |
| | | GitBlitSuite.getHelloworldRepository().getDirectory().getName()); |
| | | |
| | | assertEquals("\\d", model.customDefinedProperties.get("commitMessageRegEx")); |
| | | assertEquals("Hello", model.customDefinedProperties.get("anotherProperty")); |
| | | assertEquals("\\d", model.customFields.get("commitMessageRegEx")); |
| | | assertEquals("Hello", model.customFields.get("anotherProperty")); |
| | | } |
| | | |
| | | @Test |
| | |
| | | RepositoryModel model = GitBlit.self().getRepositoryModel( |
| | | GitBlitSuite.getHelloworldRepository().getDirectory().getName()); |
| | | |
| | | assertEquals("\\d", model.customDefinedProperties.get("commitMessageRegEx")); |
| | | assertEquals("Hello", model.customDefinedProperties.get("anotherProperty")); |
| | | assertEquals("\\d", model.customFields.get("commitMessageRegEx")); |
| | | assertEquals("Hello", model.customFields.get("anotherProperty")); |
| | | |
| | | assertEquals("Hello", model.customDefinedProperties.put("anotherProperty", "GoodBye")); |
| | | assertEquals("Hello", model.customFields.put("anotherProperty", "GoodBye")); |
| | | GitBlit.self().updateRepositoryModel(model.name, model, false); |
| | | |
| | | model = GitBlit.self().getRepositoryModel( |
| | | GitBlitSuite.getHelloworldRepository().getDirectory().getName()); |
| | | |
| | | assertEquals("\\d", model.customDefinedProperties.get("commitMessageRegEx")); |
| | | assertEquals("GoodBye", model.customDefinedProperties.get("anotherProperty")); |
| | | assertEquals("\\d", model.customFields.get("commitMessageRegEx")); |
| | | assertEquals("GoodBye", model.customFields.get("anotherProperty")); |
| | | } |
| | | |
| | | } |