diff options
9 files changed, 59 insertions, 21 deletions
diff --git a/src/main/java/com/gitblit/client/EditRepositoryDialog.java b/src/main/java/com/gitblit/client/EditRepositoryDialog.java index c3690f37..ef665d10 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.KeyStroke; 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;
@@ -92,7 +94,9 @@ public class EditRepositoryDialog extends JDialog { private JCheckBox acceptNewTickets;
- private JCheckBox requireApproval; + private JCheckBox requireApproval;
+
+ private JComboBox mergeToField; private JCheckBox useIncrementalPushTags;
@@ -217,6 +221,16 @@ public class EditRepositoryDialog extends JDialog { 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(
@@ -316,6 +330,7 @@ public class EditRepositoryDialog extends JDialog { acceptNewPatchsets));
fieldsPanel.add(newFieldPanel(Translation.get("gb.requireApproval"),
requireApproval));
+ fieldsPanel.add(newFieldPanel(Translation.get("gb.mergeTo"), mergeToField));
fieldsPanel
.add(newFieldPanel(Translation.get("gb.enableIncrementalPushTags"), useIncrementalPushTags));
fieldsPanel.add(newFieldPanel(Translation.get("gb.showRemoteBranches"),
@@ -573,6 +588,8 @@ public class EditRepositoryDialog extends JDialog { 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.skipSizeCalculation = skipSizeCalculation.isSelected();
diff --git a/src/main/java/com/gitblit/manager/RepositoryManager.java b/src/main/java/com/gitblit/manager/RepositoryManager.java index 1e917984..839671c2 100644 --- a/src/main/java/com/gitblit/manager/RepositoryManager.java +++ b/src/main/java/com/gitblit/manager/RepositoryManager.java @@ -804,6 +804,7 @@ public class RepositoryManager implements IRepositoryManager { model.acceptNewPatchsets = getConfig(config, "acceptNewPatchsets", true); model.acceptNewTickets = getConfig(config, "acceptNewTickets", true); model.requireApproval = getConfig(config, "requireApproval", settings.getBoolean(Keys.tickets.requireApproval, false)); + model.mergeTo = getConfig(config, "mergeTo", null); model.useIncrementalPushTags = getConfig(config, "useIncrementalPushTags", false); model.incrementalPushTagPrefix = getConfig(config, "incrementalPushTagPrefix", null); model.allowForks = getConfig(config, "allowForks", true); @@ -854,6 +855,9 @@ public class RepositoryManager implements IRepositoryManager { } } model.HEAD = JGitUtils.getHEADRef(r); + if (StringUtils.isEmpty(model.mergeTo)) { + model.mergeTo = model.HEAD; + } model.availableRefs = JGitUtils.getAvailableHeadTargets(r); model.sparkleshareId = JGitUtils.getSparkleshareId(r); model.hasCommits = JGitUtils.hasCommits(r); @@ -1418,6 +1422,9 @@ public class RepositoryManager implements IRepositoryManager { // override default config.setBoolean(Constants.CONFIG_GITBLIT, null, "requireApproval", repository.requireApproval); } + if (!StringUtils.isEmpty(repository.mergeTo)) { + config.setString(Constants.CONFIG_GITBLIT, null, "mergeTo", repository.mergeTo); + } config.setBoolean(Constants.CONFIG_GITBLIT, null, "useIncrementalPushTags", repository.useIncrementalPushTags); if (StringUtils.isEmpty(repository.incrementalPushTagPrefix) || repository.incrementalPushTagPrefix.equals(settings.getString(Keys.git.defaultIncrementalPushTagPrefix, "r"))) { diff --git a/src/main/java/com/gitblit/models/RepositoryModel.java b/src/main/java/com/gitblit/models/RepositoryModel.java index 5bd2ec03..f84e96b9 100644 --- a/src/main/java/com/gitblit/models/RepositoryModel.java +++ b/src/main/java/com/gitblit/models/RepositoryModel.java @@ -88,6 +88,7 @@ public class RepositoryModel implements Serializable, Comparable<RepositoryModel public boolean acceptNewPatchsets;
public boolean acceptNewTickets;
public boolean requireApproval; + public String mergeTo;
public transient boolean isCollectingGarbage;
public Date lastGC;
diff --git a/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties b/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties index 9f090c89..2ab023ff 100644 --- a/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties +++ b/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties @@ -669,3 +669,4 @@ gb.repositoryIsFrozen = This repository is frozen. gb.repositoryDoesNotAcceptPatchsets = This repository does not accept patchsets. gb.serverDoesNotAcceptPatchsets = This server does not accept patchsets. gb.ticketIsClosed = This ticket is closed. +gb.mergeToDescription = default integration branch for merging ticket patchsets diff --git a/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.html b/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.html index da19ca0f..f82ac3d5 100644 --- a/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.html +++ b/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.html @@ -37,15 +37,17 @@ <tr><th><wicket:message key="gb.acceptNewTickets"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="acceptNewTickets" tabindex="7" /> <span class="help-inline"><wicket:message key="gb.acceptNewTicketsDescription"></wicket:message></span></label></td></tr>
<tr><th><wicket:message key="gb.acceptNewPatchsets"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="acceptNewPatchsets" tabindex="8" /> <span class="help-inline"><wicket:message key="gb.acceptNewPatchsetsDescription"></wicket:message></span></label></td></tr>
<tr><th><wicket:message key="gb.requireApproval"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="requireApproval" tabindex="9" /> <span class="help-inline"><wicket:message key="gb.requireApprovalDescription"></wicket:message></span></label></td></tr>
- <tr><th><wicket:message key="gb.enableIncrementalPushTags"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="useIncrementalPushTags" tabindex="10" /> <span class="help-inline"><wicket:message key="gb.useIncrementalPushTagsDescription"></wicket:message></span></label></td></tr>
- <tr><th><wicket:message key="gb.showRemoteBranches"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="showRemoteBranches" tabindex="11" /> <span class="help-inline"><wicket:message key="gb.showRemoteBranchesDescription"></wicket:message></span></label></td></tr>
- <tr><th><wicket:message key="gb.skipSizeCalculation"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="skipSizeCalculation" tabindex="12" /> <span class="help-inline"><wicket:message key="gb.skipSizeCalculationDescription"></wicket:message></span></label></td></tr>
- <tr><th><wicket:message key="gb.skipSummaryMetrics"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="skipSummaryMetrics" tabindex="13" /> <span class="help-inline"><wicket:message key="gb.skipSummaryMetricsDescription"></wicket:message></span></label></td></tr>
- <tr><th><wicket:message key="gb.maxActivityCommits"></wicket:message></th><td class="edit"><select class="span2" wicket:id="maxActivityCommits" tabindex="14" /> <span class="help-inline"><wicket:message key="gb.maxActivityCommitsDescription"></wicket:message></span></td></tr>
- <tr><th><wicket:message key="gb.metricAuthorExclusions"></wicket:message></th><td class="edit"><input class="span8" type="text" wicket:id="metricAuthorExclusions" size="40" tabindex="15" /></td></tr>
- <tr><th><wicket:message key="gb.commitMessageRenderer"></wicket:message></th><td class="edit"><select class="span2" wicket:id="commitMessageRenderer" tabindex="16" /></td></tr>
+ <tr><th><wicket:message key="gb.mergeTo"></wicket:message></th><td class="edit"><select class="span2" wicket:id="mergeTo" tabindex="10" /> <span class="help-inline"><wicket:message key="gb.mergeToDescription"></wicket:message></span></td></tr>
<tr><th colspan="2"><hr/></th></tr>
- <tr><th><wicket:message key="gb.mailingLists"></wicket:message></th><td class="edit"><input class="span8" type="text" wicket:id="mailingLists" size="40" tabindex="17" /></td></tr>
+ <tr><th><wicket:message key="gb.enableIncrementalPushTags"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="useIncrementalPushTags" tabindex="11" /> <span class="help-inline"><wicket:message key="gb.useIncrementalPushTagsDescription"></wicket:message></span></label></td></tr>
+ <tr><th><wicket:message key="gb.showRemoteBranches"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="showRemoteBranches" tabindex="12" /> <span class="help-inline"><wicket:message key="gb.showRemoteBranchesDescription"></wicket:message></span></label></td></tr>
+ <tr><th><wicket:message key="gb.skipSizeCalculation"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="skipSizeCalculation" tabindex="13" /> <span class="help-inline"><wicket:message key="gb.skipSizeCalculationDescription"></wicket:message></span></label></td></tr>
+ <tr><th><wicket:message key="gb.skipSummaryMetrics"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="skipSummaryMetrics" tabindex="14" /> <span class="help-inline"><wicket:message key="gb.skipSummaryMetricsDescription"></wicket:message></span></label></td></tr>
+ <tr><th><wicket:message key="gb.maxActivityCommits"></wicket:message></th><td class="edit"><select class="span2" wicket:id="maxActivityCommits" tabindex="15" /> <span class="help-inline"><wicket:message key="gb.maxActivityCommitsDescription"></wicket:message></span></td></tr>
+ <tr><th><wicket:message key="gb.metricAuthorExclusions"></wicket:message></th><td class="edit"><input class="span8" type="text" wicket:id="metricAuthorExclusions" size="40" tabindex="16" /></td></tr>
+ <tr><th><wicket:message key="gb.commitMessageRenderer"></wicket:message></th><td class="edit"><select class="span2" wicket:id="commitMessageRenderer" tabindex="17" /></td></tr>
+ <tr><th colspan="2"><hr/></th></tr>
+ <tr><th><wicket:message key="gb.mailingLists"></wicket:message></th><td class="edit"><input class="span8" type="text" wicket:id="mailingLists" size="40" tabindex="18" /></td></tr>
</tbody>
</table>
</div>
@@ -54,15 +56,15 @@ <div class="tab-pane" id="permissions">
<table class="plain">
<tbody class="settings">
- <tr><th><wicket:message key="gb.owners"></wicket:message></th><td class="edit"><span wicket:id="owners" tabindex="18" /> </td></tr>
+ <tr><th><wicket:message key="gb.owners"></wicket:message></th><td class="edit"><span wicket:id="owners" tabindex="19" /> </td></tr>
<tr><th colspan="2"><hr/></th></tr>
- <tr><th><wicket:message key="gb.accessRestriction"></wicket:message></th><td class="edit"><select class="span4" wicket:id="accessRestriction" tabindex="19" /></td></tr>
+ <tr><th><wicket:message key="gb.accessRestriction"></wicket:message></th><td class="edit"><select class="span4" wicket:id="accessRestriction" tabindex="20" /></td></tr>
<tr><th colspan="2"><hr/></th></tr>
<tr><th><wicket:message key="gb.authorizationControl"></wicket:message></th><td style="padding:2px;"><span class="authorizationControl" wicket:id="authorizationControl"></span></td></tr>
<tr><th colspan="2"><hr/></th></tr>
- <tr><th><wicket:message key="gb.isFrozen"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="isFrozen" tabindex="20" /> <span class="help-inline"><wicket:message key="gb.isFrozenDescription"></wicket:message></span></label></td></tr>
- <tr><th><wicket:message key="gb.allowForks"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="allowForks" tabindex="21" /> <span class="help-inline"><wicket:message key="gb.allowForksDescription"></wicket:message></span></label></td></tr>
- <tr><th><wicket:message key="gb.verifyCommitter"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="verifyCommitter" tabindex="22" /> <span class="help-inline"><wicket:message key="gb.verifyCommitterDescription"></wicket:message></span><br/><span class="help-inline" style="padding-left:10px;"><wicket:message key="gb.verifyCommitterNote"></wicket:message></span></label></td></tr>
+ <tr><th><wicket:message key="gb.isFrozen"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="isFrozen" tabindex="21" /> <span class="help-inline"><wicket:message key="gb.isFrozenDescription"></wicket:message></span></label></td></tr>
+ <tr><th><wicket:message key="gb.allowForks"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="allowForks" tabindex="22" /> <span class="help-inline"><wicket:message key="gb.allowForksDescription"></wicket:message></span></label></td></tr>
+ <tr><th><wicket:message key="gb.verifyCommitter"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="verifyCommitter" tabindex="23" /> <span class="help-inline"><wicket:message key="gb.verifyCommitterDescription"></wicket:message></span><br/><span class="help-inline" style="padding-left:10px;"><wicket:message key="gb.verifyCommitterNote"></wicket:message></span></label></td></tr>
<tr><th colspan="2"><hr/></th></tr>
<tr><th><wicket:message key="gb.userPermissions"></wicket:message></th><td style="padding:2px;"><span wicket:id="users"></span></td></tr>
<tr><th colspan="2"><hr/></th></tr>
@@ -75,7 +77,7 @@ <div class="tab-pane" id="federation">
<table class="plain">
<tbody class="settings">
- <tr><th><wicket:message key="gb.federationStrategy"></wicket:message></th><td class="edit"><select class="span4" wicket:id="federationStrategy" tabindex="23" /></td></tr>
+ <tr><th><wicket:message key="gb.federationStrategy"></wicket:message></th><td class="edit"><select class="span4" wicket:id="federationStrategy" tabindex="24" /></td></tr>
<tr><th><wicket:message key="gb.federationSets"></wicket:message></th><td style="padding:2px;"><span wicket:id="federationSets"></span></td></tr>
</tbody>
</table>
diff --git a/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java index 3a5f122f..f860eeb3 100644 --- a/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java +++ b/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java @@ -49,6 +49,7 @@ import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model;
import org.apache.wicket.model.util.CollectionModel;
import org.apache.wicket.model.util.ListModel;
+import org.eclipse.jgit.lib.Repository;
import com.gitblit.Constants;
import com.gitblit.Constants.AccessRestrictionType;
@@ -443,8 +444,16 @@ public class EditRepositoryPage extends RootSubPage { // allow relinking HEAD to a branch or tag other than master on edit repository
List<String> availableRefs = new ArrayList<String>();
+ List<String> availableBranches = new ArrayList<String>();
if (!ArrayUtils.isEmpty(repositoryModel.availableRefs)) {
- availableRefs.addAll(repositoryModel.availableRefs);
+ for (String ref : repositoryModel.availableRefs) {
+ if (!ref.startsWith(Constants.R_TICKET)) {
+ availableRefs.add(ref);
+ if (ref.startsWith(Constants.R_HEADS)) {
+ availableBranches.add(Repository.shortenRefName(ref));
+ }
+ }
+ }
}
form.add(new DropDownChoice<String>("HEAD", availableRefs).setEnabled(availableRefs.size() > 0));
@@ -469,6 +478,7 @@ public class EditRepositoryPage extends RootSubPage { form.add(new CheckBox("acceptNewPatchsets"));
form.add(new CheckBox("acceptNewTickets")); form.add(new CheckBox("requireApproval"));
+ form.add(new DropDownChoice<String>("mergeTo", availableBranches).setEnabled(availableBranches.size() > 0));
form.add(new CheckBox("useIncrementalPushTags"));
form.add(new CheckBox("showRemoteBranches"));
form.add(new CheckBox("skipSizeCalculation"));
diff --git a/src/main/java/com/gitblit/wicket/pages/EditTicketPage.java b/src/main/java/com/gitblit/wicket/pages/EditTicketPage.java index b5004861..00cd47d9 100644 --- a/src/main/java/com/gitblit/wicket/pages/EditTicketPage.java +++ b/src/main/java/com/gitblit/wicket/pages/EditTicketPage.java @@ -108,7 +108,7 @@ public class EditTicketPage extends RepositoryPage { topicModel = Model.of(ticket.topic == null ? "" : ticket.topic);
responsibleModel = Model.of();
milestoneModel = Model.of();
- mergeToModel = Model.of(ticket.mergeTo == null ? "" : ticket.mergeTo);
+ mergeToModel = Model.of(ticket.mergeTo == null ? getRepositoryModel().mergeTo : ticket.mergeTo);
statusModel = Model.of(ticket.status);
setStatelessHint(false);
@@ -309,8 +309,8 @@ public class EditTicketPage extends RepositoryPage { branches.add(Repository.shortenRefName(branch));
}
}
- branches.remove(Repository.shortenRefName(getRepositoryModel().HEAD));
- branches.add(0, Repository.shortenRefName(getRepositoryModel().HEAD));
+ branches.remove(Repository.shortenRefName(getRepositoryModel().mergeTo));
+ branches.add(0, Repository.shortenRefName(getRepositoryModel().mergeTo));
Fragment mergeto = new Fragment("mergeto", "mergeToFragment", this);
mergeto.add(new DropDownChoice<String>("mergeto", mergeToModel, branches));
diff --git a/src/main/java/com/gitblit/wicket/pages/NewTicketPage.java b/src/main/java/com/gitblit/wicket/pages/NewTicketPage.java index 25fe48f4..fda2e9f3 100644 --- a/src/main/java/com/gitblit/wicket/pages/NewTicketPage.java +++ b/src/main/java/com/gitblit/wicket/pages/NewTicketPage.java @@ -87,7 +87,7 @@ public class NewTicketPage extends RepositoryPage { typeModel = Model.of(TicketModel.Type.defaultType);
titleModel = Model.of();
topicModel = Model.of();
- mergeToModel = Model.of(Repository.shortenRefName(getRepositoryModel().HEAD));
+ mergeToModel = Model.of(Repository.shortenRefName(getRepositoryModel().mergeTo));
responsibleModel = Model.of();
milestoneModel = Model.of();
diff --git a/src/main/java/com/gitblit/wicket/pages/TicketPage.java b/src/main/java/com/gitblit/wicket/pages/TicketPage.java index 434882f4..1a1686d3 100644 --- a/src/main/java/com/gitblit/wicket/pages/TicketPage.java +++ b/src/main/java/com/gitblit/wicket/pages/TicketPage.java @@ -988,7 +988,7 @@ public class TicketPage extends TicketBasePage { md = md.replace("${ticketId}", "" + ticketId);
md = md.replace("${patchset}", "" + 1);
md = md.replace("${reviewBranch}", Repository.shortenRefName(PatchsetCommand.getTicketBranch(ticketId)));
- String integrationBranch = Repository.shortenRefName(getRepositoryModel().HEAD);
+ String integrationBranch = Repository.shortenRefName(getRepositoryModel().mergeTo);
if (!StringUtils.isEmpty(ticket.mergeTo)) {
integrationBranch = ticket.mergeTo;
}
|