From f76fee63ed9cb3a30d3c0c092d860b1cb93a481b Mon Sep 17 00:00:00 2001
From: Gerard Smyth <gerard.smyth@gmail.com>
Date: Thu, 08 May 2014 13:09:30 -0400
Subject: [PATCH] Updated the SyndicationServlet to provide an additional option to return details of the tags in the repository instead of the commits. This uses a new 'ot' request parameter to indicate the object type of the content to return, which can be ither TAG or COMMIT. If this is not provided, then COMMIT is assumed to maintain backwards compatability. If tags are returned, then the paging parameters, 'l' and 'pg' are still supported, but searching options are currently ignored.

---
 src/main/java/com/gitblit/client/EditRepositoryDialog.java |  151 +++++++++++++++++++++++++++++--------------------
 1 files changed, 89 insertions(+), 62 deletions(-)

diff --git a/src/main/java/com/gitblit/client/EditRepositoryDialog.java b/src/main/java/com/gitblit/client/EditRepositoryDialog.java
index 8851de4..ef665d1 100644
--- a/src/main/java/com/gitblit/client/EditRepositoryDialog.java
+++ b/src/main/java/com/gitblit/client/EditRepositoryDialog.java
@@ -58,6 +58,8 @@
 import javax.swing.ListCellRenderer;
 import javax.swing.ScrollPaneConstants;
 
+import org.eclipse.jgit.lib.Repository;
+
 import com.gitblit.Constants.AccessRestrictionType;
 import com.gitblit.Constants.AuthorizationControl;
 import com.gitblit.Constants.FederationStrategy;
@@ -69,7 +71,7 @@
 
 /**
  * Dialog to create/edit a repository.
- * 
+ *
  * @author James Moger
  */
 public class EditRepositoryDialog extends JDialog {
@@ -88,13 +90,17 @@
 
 	private JTextField descriptionField;
 
-	private JCheckBox useTickets;
+	private JCheckBox acceptNewPatchsets;
 
-	private JCheckBox useDocs;
+	private JCheckBox acceptNewTickets;
+
+	private JCheckBox requireApproval;
+
+	private JComboBox mergeToField;
+
+	private JCheckBox useIncrementalPushTags;
 
 	private JCheckBox showRemoteBranches;
-
-	private JCheckBox showReadme;
 
 	private JCheckBox skipSizeCalculation;
 
@@ -105,11 +111,11 @@
 	private JTextField mailingListsField;
 
 	private JComboBox accessRestriction;
-	
+
 	private JRadioButton allowAuthenticated;
-	
+
 	private JRadioButton allowNamed;
-	
+
 	private JCheckBox allowForks;
 
 	private JCheckBox verifyCommitter;
@@ -119,19 +125,19 @@
 	private JPalette<String> ownersPalette;
 
 	private JComboBox headRefField;
-	
+
 	private JComboBox gcPeriod;
-	
+
 	private JTextField gcThreshold;
-	
+
 	private JComboBox maxActivityCommits;
-	
+
 	private RegistrantPermissionsPanel usersPalette;
 
 	private JPalette<String> setsPalette;
 
 	private RegistrantPermissionsPanel teamsPalette;
-	
+
 	private JPalette<String> indexedBranchesPalette;
 
 	private JPalette<String> preReceivePalette;
@@ -143,9 +149,9 @@
 	private JLabel postReceiveInherited;
 
 	private Set<String> repositoryNames;
-	
+
 	private JPanel customFieldsPanel;
-	
+
 	private List<JTextField> customTextfields;
 
 	public EditRepositoryDialog(int protocolVersion) {
@@ -173,6 +179,7 @@
 		KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
 		JRootPane rootPane = new JRootPane();
 		rootPane.registerKeyboardAction(new ActionListener() {
+			@Override
 			public void actionPerformed(ActionEvent actionEvent) {
 				setVisible(false);
 			}
@@ -192,31 +199,43 @@
 
 		if (ArrayUtils.isEmpty(anRepository.availableRefs)) {
 			headRefField = new JComboBox();
-			headRefField.setEnabled(false);			
+			headRefField.setEnabled(false);
 		} else {
 			headRefField = new JComboBox(
 					anRepository.availableRefs.toArray());
 			headRefField.setSelectedItem(anRepository.HEAD);
 		}
-		
+
 		Integer []  gcPeriods =  { 1, 2, 3, 4, 5, 7, 10, 14 };
 		gcPeriod = new JComboBox(gcPeriods);
 		gcPeriod.setSelectedItem(anRepository.gcPeriod);
-		
+
 		gcThreshold = new JTextField(8);
 		gcThreshold.setText(anRepository.gcThreshold);
 
 		ownersPalette = new JPalette<String>(true);
 
-		useTickets = new JCheckBox(Translation.get("gb.useTicketsDescription"),
-				anRepository.useTickets);
-		useDocs = new JCheckBox(Translation.get("gb.useDocsDescription"),
-				anRepository.useDocs);
+		acceptNewTickets = new JCheckBox(Translation.get("gb.acceptsNewTicketsDescription"),
+				anRepository.acceptNewTickets);
+		acceptNewPatchsets = new JCheckBox(Translation.get("gb.acceptsNewPatchsetsDescription"),
+				anRepository.acceptNewPatchsets);
+		requireApproval = new JCheckBox(Translation.get("gb.requireApprovalDescription"),
+				anRepository.requireApproval);
+
+		if (ArrayUtils.isEmpty(anRepository.availableRefs)) {
+			mergeToField = new JComboBox();
+			mergeToField.setEnabled(false);
+		} else {
+			mergeToField = new JComboBox(
+					anRepository.availableRefs.toArray());
+			mergeToField.setSelectedItem(anRepository.mergeTo);
+		}
+
+		useIncrementalPushTags = new JCheckBox(Translation.get("gb.useIncrementalPushTagsDescription"),
+				anRepository.useIncrementalPushTags);
 		showRemoteBranches = new JCheckBox(
 				Translation.get("gb.showRemoteBranchesDescription"),
 				anRepository.showRemoteBranches);
-		showReadme = new JCheckBox(Translation.get("gb.showReadmeDescription"),
-				anRepository.showReadme);
 		skipSizeCalculation = new JCheckBox(
 				Translation.get("gb.skipSizeCalculationDescription"),
 				anRepository.skipSizeCalculation);
@@ -246,21 +265,21 @@
 				}
 			}
 		});
-		
-		boolean authenticated = anRepository.authorizationControl != null 
+
+		boolean authenticated = anRepository.authorizationControl != null
 				&& AuthorizationControl.AUTHENTICATED.equals(anRepository.authorizationControl);
 		allowAuthenticated = new JRadioButton(Translation.get("gb.allowAuthenticatedDescription"));
 		allowAuthenticated.setSelected(authenticated);
 		allowAuthenticated.addItemListener(new ItemListener() {
 			@Override
 			public void itemStateChanged(ItemEvent e) {
-				if (e.getStateChange() == ItemEvent.SELECTED) {					
+				if (e.getStateChange() == ItemEvent.SELECTED) {
 					usersPalette.setEnabled(false);
 					teamsPalette.setEnabled(false);
 				}
 			}
 		});
-		
+
 		allowNamed = new JRadioButton(Translation.get("gb.allowNamedDescription"));
 		allowNamed.setSelected(!authenticated);
 		allowNamed.addItemListener(new ItemListener() {
@@ -272,15 +291,15 @@
 				}
 			}
 		});
-		
+
 		ButtonGroup group = new ButtonGroup();
 		group.add(allowAuthenticated);
 		group.add(allowNamed);
-		
+
 		JPanel authorizationPanel = new JPanel(new GridLayout(0, 1));
 		authorizationPanel.add(allowAuthenticated);
 		authorizationPanel.add(allowNamed);
-		
+
 		allowForks = new JCheckBox(Translation.get("gb.allowForksDescription"), anRepository.allowForks);
 		verifyCommitter = new JCheckBox(Translation.get("gb.verifyCommitterDescription"), anRepository.verifyCommitter);
 
@@ -305,14 +324,17 @@
 		fieldsPanel.add(newFieldPanel(Translation.get("gb.gcPeriod"), gcPeriod));
 		fieldsPanel.add(newFieldPanel(Translation.get("gb.gcThreshold"), gcThreshold));
 
-		fieldsPanel.add(newFieldPanel(Translation.get("gb.enableTickets"),
-				useTickets));
+		fieldsPanel.add(newFieldPanel(Translation.get("gb.acceptsNewTickets"),
+				acceptNewTickets));
+		fieldsPanel.add(newFieldPanel(Translation.get("gb.acceptsNewPatchsets"),
+				acceptNewPatchsets));
+		fieldsPanel.add(newFieldPanel(Translation.get("gb.requireApproval"),
+				requireApproval));
+		fieldsPanel.add(newFieldPanel(Translation.get("gb.mergeTo"), mergeToField));
 		fieldsPanel
-				.add(newFieldPanel(Translation.get("gb.enableDocs"), useDocs));
+		.add(newFieldPanel(Translation.get("gb.enableIncrementalPushTags"), useIncrementalPushTags));
 		fieldsPanel.add(newFieldPanel(Translation.get("gb.showRemoteBranches"),
 				showRemoteBranches));
-		fieldsPanel.add(newFieldPanel(Translation.get("gb.showReadme"),
-				showReadme));
 		fieldsPanel
 				.add(newFieldPanel(Translation.get("gb.skipSizeCalculation"),
 						skipSizeCalculation));
@@ -381,7 +403,7 @@
 		JPanel postReceivePanel = new JPanel(new BorderLayout(5, 5));
 		postReceivePanel.add(postReceivePalette, BorderLayout.CENTER);
 		postReceivePanel.add(postReceiveInherited, BorderLayout.WEST);
-		
+
 		customFieldsPanel = new JPanel();
 		customFieldsPanel.setLayout(new BoxLayout(customFieldsPanel, BoxLayout.Y_AXIS));
 		JScrollPane customFieldsScrollPane = new JScrollPane(customFieldsPanel);
@@ -400,14 +422,15 @@
 		}
 		panel.addTab(Translation.get("gb.preReceiveScripts"), preReceivePanel);
 		panel.addTab(Translation.get("gb.postReceiveScripts"), postReceivePanel);
-		
+
 		panel.addTab(Translation.get("gb.customFields"), customFieldsScrollPane);
-		
+
 
 		setupAccessPermissions(anRepository.accessRestriction);
 
 		JButton createButton = new JButton(Translation.get("gb.save"));
 		createButton.addActionListener(new ActionListener() {
+			@Override
 			public void actionPerformed(ActionEvent event) {
 				if (validateFields()) {
 					canceled = false;
@@ -418,6 +441,7 @@
 
 		JButton cancelButton = new JButton(Translation.get("gb.cancel"));
 		cancelButton.addActionListener(new ActionListener() {
+			@Override
 			public void actionPerformed(ActionEvent event) {
 				canceled = true;
 				setVisible(false);
@@ -446,7 +470,7 @@
 		pack();
 		nameField.requestFocus();
 	}
-	
+
 	private JPanel newFieldPanel(String label, JComponent comp) {
 		return newFieldPanel(label, 150, comp);
 	}
@@ -460,12 +484,12 @@
 		panel.add(comp);
 		return panel;
 	}
-	
+
 	private void setupAccessPermissions(AccessRestrictionType art) {
 		if (AccessRestrictionType.NONE.equals(art)) {
 			usersPalette.setEnabled(false);
 			teamsPalette.setEnabled(false);
-			
+
 			allowAuthenticated.setEnabled(false);
 			allowNamed.setEnabled(false);
 			verifyCommitter.setEnabled(false);
@@ -473,7 +497,7 @@
 			allowAuthenticated.setEnabled(true);
 			allowNamed.setEnabled(true);
 			verifyCommitter.setEnabled(true);
-			
+
 			if (allowNamed.isSelected()) {
 				usersPalette.setEnabled(true);
 				teamsPalette.setEnabled(true);
@@ -561,14 +585,17 @@
 				: headRefField.getSelectedItem().toString();
 		repository.gcPeriod = (Integer) gcPeriod.getSelectedItem();
 		repository.gcThreshold = gcThreshold.getText();
-		repository.useTickets = useTickets.isSelected();
-		repository.useDocs = useDocs.isSelected();
+		repository.acceptNewPatchsets = acceptNewPatchsets.isSelected();
+		repository.acceptNewTickets = acceptNewTickets.isSelected();
+		repository.requireApproval = requireApproval.isSelected();
+		repository.mergeTo = mergeToField.getSelectedItem() == null ? null
+				: Repository.shortenRefName(mergeToField.getSelectedItem().toString());
+		repository.useIncrementalPushTags = useIncrementalPushTags.isSelected();
 		repository.showRemoteBranches = showRemoteBranches.isSelected();
-		repository.showReadme = showReadme.isSelected();
 		repository.skipSizeCalculation = skipSizeCalculation.isSelected();
 		repository.skipSummaryMetrics = skipSummaryMetrics.isSelected();
 		repository.maxActivityCommits = (Integer) maxActivityCommits.getSelectedItem();
-		
+
 		repository.isFrozen = isFrozen.isSelected();
 		repository.allowForks = allowForks.isSelected();
 		repository.verifyCommitter = verifyCommitter.isSelected();
@@ -587,7 +614,7 @@
 
 		repository.accessRestriction = (AccessRestrictionType) accessRestriction
 				.getSelectedItem();
-		repository.authorizationControl = allowAuthenticated.isSelected() ? 
+		repository.authorizationControl = allowAuthenticated.isSelected() ?
 				AuthorizationControl.AUTHENTICATED : AuthorizationControl.NAMED;
 		repository.federationStrategy = (FederationStrategy) federationStrategy
 				.getSelectedItem();
@@ -595,11 +622,11 @@
 		if (repository.federationStrategy.exceeds(FederationStrategy.EXCLUDE)) {
 			repository.federationSets = setsPalette.getSelections();
 		}
-		
+
 		repository.indexedBranches = indexedBranchesPalette.getSelections();
 		repository.preReceiveScripts = preReceivePalette.getSelections();
 		repository.postReceiveScripts = postReceivePalette.getSelections();
-		
+
 		// Custom Fields
 		repository.customFields = new LinkedHashMap<String, String>();
 		if (customTextfields != null) {
@@ -616,7 +643,7 @@
 		JOptionPane.showMessageDialog(EditRepositoryDialog.this, message,
 				Translation.get("gb.error"), JOptionPane.ERROR_MESSAGE);
 	}
-	
+
 	public void setAccessRestriction(AccessRestrictionType restriction) {
 		this.accessRestriction.setSelectedItem(restriction);
 		setupAccessPermissions(restriction);
@@ -651,7 +678,7 @@
 	public void setFederationSets(List<String> all, List<String> selected) {
 		setsPalette.setObjects(all, selected);
 	}
-	
+
 	public void setIndexedBranches(List<String> all, List<String> selected) {
 		indexedBranchesPalette.setObjects(all, selected);
 	}
@@ -694,11 +721,11 @@
 	public List<RegistrantAccessPermission> getTeamAccessPermissions() {
 		return teamsPalette.getPermissions();
 	}
-	
+
 	public void setCustomFields(RepositoryModel repository, Map<String, String> customFields) {
 		customFieldsPanel.removeAll();
 		customTextfields = new ArrayList<JTextField>();
-		
+
 		final Insets insets = new Insets(5, 5, 5, 5);
 		JPanel fields = new JPanel(new GridLayout(0, 1, 0, 5)) {
 
@@ -708,8 +735,8 @@
 			public Insets getInsets() {
 				return insets;
 			}
-		};		
-		
+		};
+
 		for (Map.Entry<String, String> entry : customFields.entrySet()) {
 			String field = entry.getKey();
 			String value = "";
@@ -718,14 +745,14 @@
 			}
 			JTextField textField = new JTextField(value);
 			textField.setName(field);
-			
+
 			textField.setPreferredSize(new Dimension(450, 26));
-			
+
 			fields.add(newFieldPanel(entry.getValue(), 250, textField));
-			
+
 			customTextfields.add(textField);
 		}
-		JScrollPane jsp = new JScrollPane(fields);		
+		JScrollPane jsp = new JScrollPane(fields);
 		jsp.getVerticalScrollBar().setBlockIncrement(100);
 		jsp.getVerticalScrollBar().setUnitIncrement(100);
 		jsp.setViewportBorder(null);
@@ -736,7 +763,7 @@
 	/**
 	 * ListCellRenderer to display descriptive text about the access
 	 * restriction.
-	 * 
+	 *
 	 */
 	private class AccessRestrictionRenderer extends DefaultListCellRenderer {
 
@@ -746,7 +773,7 @@
 		public Component getListCellRendererComponent(JList list, Object value,
 				int index, boolean isSelected, boolean cellHasFocus) {
 			super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
-			
+
 			if (value instanceof AccessRestrictionType) {
 				AccessRestrictionType restriction = (AccessRestrictionType) value;
 				switch (restriction) {

--
Gitblit v1.9.1