From: James Moger Date: Wed, 5 Mar 2014 15:56:34 +0000 (-0500) Subject: Allow integration (mergeTo) branch to be changed in edit ticket X-Git-Tag: v1.4.0~48 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=06eb51f13d9dcd4e4e5d9d7bb0db4cf18a67b23e;p=gitblit.git Allow integration (mergeTo) branch to be changed in edit ticket --- diff --git a/src/main/java/com/gitblit/wicket/pages/EditTicketPage.html b/src/main/java/com/gitblit/wicket/pages/EditTicketPage.html index 5d8f6829..424eece3 100644 --- a/src/main/java/com/gitblit/wicket/pages/EditTicketPage.html +++ b/src/main/java/com/gitblit/wicket/pages/EditTicketPage.html @@ -41,6 +41,7 @@ * + @@ -62,5 +63,9 @@ + + + + \ No newline at end of file diff --git a/src/main/java/com/gitblit/wicket/pages/EditTicketPage.java b/src/main/java/com/gitblit/wicket/pages/EditTicketPage.java index 5446dde3..aad1d6fe 100644 --- a/src/main/java/com/gitblit/wicket/pages/EditTicketPage.java +++ b/src/main/java/com/gitblit/wicket/pages/EditTicketPage.java @@ -31,7 +31,9 @@ import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.markup.html.panel.Fragment; import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; +import org.eclipse.jgit.lib.Repository; +import com.gitblit.Constants; import com.gitblit.Constants.AccessPermission; import com.gitblit.models.RegistrantAccessPermission; import com.gitblit.models.TicketModel; @@ -68,6 +70,8 @@ public class EditTicketPage extends RepositoryPage { private IModel topicModel; + private IModel mergeToModel; + private IModel responsibleModel; private IModel milestoneModel; @@ -105,6 +109,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); setStatelessHint(false); setOutputMarkupId(true); @@ -174,6 +179,13 @@ public class EditTicketPage extends RepositoryPage { } } + String mergeTo = mergeToModel.getObject(); + if ((StringUtils.isEmpty(ticket.mergeTo) && !StringUtils.isEmpty(mergeTo)) + || (!StringUtils.isEmpty(mergeTo) && !mergeTo.equals(ticket.mergeTo))) { + // integration branch change + change.setField(Field.mergeTo, mergeTo); + } + if (change.hasFieldChanges()) { if (!ticket.isWatching(createdBy)) { change.watch(createdBy); @@ -258,10 +270,27 @@ public class EditTicketPage extends RepositoryPage { milestone.add(new DropDownChoice("milestone", milestoneModel, milestones)); form.add(milestone.setVisible(!milestones.isEmpty())); + + // mergeTo (integration branch) + List branches = new ArrayList(); + for (String branch : getRepositoryModel().getLocalBranches()) { + // exclude ticket branches + if (!branch.startsWith(Constants.R_TICKET)) { + branches.add(Repository.shortenRefName(branch)); + } + } + branches.remove(Repository.shortenRefName(getRepositoryModel().HEAD)); + branches.add(0, Repository.shortenRefName(getRepositoryModel().HEAD)); + + Fragment mergeto = new Fragment("mergeto", "mergeToFragment", this); + mergeto.add(new DropDownChoice("mergeto", mergeToModel, branches)); + form.add(mergeto.setVisible(!branches.isEmpty())); + } else { // user does not have permission to assign milestone or responsible form.add(new Label("responsible").setVisible(false)); form.add(new Label("milestone").setVisible(false)); + form.add(new Label("mergeto").setVisible(false)); } form.add(new Button("update")); @@ -275,7 +304,6 @@ public class EditTicketPage extends RepositoryPage { }; cancel.setDefaultFormProcessing(false); form.add(cancel); - } @Override