From 06eb51f13d9dcd4e4e5d9d7bb0db4cf18a67b23e Mon Sep 17 00:00:00 2001 From: James Moger Date: Wed, 5 Mar 2014 10:56:34 -0500 Subject: [PATCH] Allow integration (mergeTo) branch to be changed in edit ticket --- .../gitblit/wicket/pages/EditTicketPage.html | 5 ++++ .../gitblit/wicket/pages/EditTicketPage.java | 30 ++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) 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 -- 2.39.5