diff options
author | Paul Martin <paul@paulsputer.com> | 2016-04-27 23:58:06 +0100 |
---|---|---|
committer | Paul Martin <paul@paulsputer.com> | 2016-04-27 23:58:06 +0100 |
commit | c2188a840bc4153ae92112b04b2e06a90d3944aa (patch) | |
tree | c11b48170773fcf1edfc53def832fe5a9b76f1c0 /src/main/java/com/gitblit/wicket | |
parent | 56619e42f0a1e555c004374e7f2b13f744ab23f5 (diff) | |
download | gitblit-c2188a840bc4153ae92112b04b2e06a90d3944aa.tar.gz gitblit-c2188a840bc4153ae92112b04b2e06a90d3944aa.zip |
Ticket Reference handling #1048
+ Supports referencing:
+ Tickets from other tickets via comments
+ Tickets from commits on any branch
+ Common TicketLink class used for both commits and tickets
+ TicketLink is temporary and persisted to ticket as a Reference
+ Support deletion of ticket references
+ Rebasing patchsets/branches will generate new references
+ Deleting old patchsets/branches will remove the relevant references
+ Substantial testing of use cases
+ With and without patchsets, deleting, amending
+ BranchTicketService used during testing to allow end-to-end ref testing
+ Relocated common git helper functions to JGitUtils
Diffstat (limited to 'src/main/java/com/gitblit/wicket')
3 files changed, 41 insertions, 8 deletions
diff --git a/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties b/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties index cee7eaba..a215b4d6 100644 --- a/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties +++ b/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties @@ -778,4 +778,6 @@ gb.fileNotMergeable = Unable to commit {0}. This file can not be automatically gb.fileCommitted = Successfully committed {0}. gb.deletePatchset = Delete Patchset {0} gb.deletePatchsetSuccess = Deleted Patchset {0}. -gb.deletePatchsetFailure = Error deleting Patchset {0}. +gb.deletePatchsetFailure = Error deleting Patchset {0}. +gb.referencedByCommit = Referenced by commit. +gb.referencedByTicket = Referenced by ticket. diff --git a/src/main/java/com/gitblit/wicket/pages/TicketPage.html b/src/main/java/com/gitblit/wicket/pages/TicketPage.html index 974dcc03..46c0f7ee 100644 --- a/src/main/java/com/gitblit/wicket/pages/TicketPage.html +++ b/src/main/java/com/gitblit/wicket/pages/TicketPage.html @@ -461,7 +461,7 @@ pt push</pre> <td style="text-align:right;">
<span wicket:id="patchsetType">[revision type]</span>
</td>
- <td><span class="hidden-phone hidden-tablet aui-lozenge aui-lozenge-subtle" wicket:id="patchsetRevision">[R1]</span>
+ <td><span class="hidden-phone hidden-tablet" wicket:id="patchsetRevision">[R1]</span>
<span class="fa fa-fw" style="padding-left:15px;"><a wicket:id="deleteRevision" class="fa fa-fw fa-trash delete-patchset"></a></span>
<span class="hidden-tablet hidden-phone" style="padding-left:15px;"><span wicket:id="patchsetDiffStat"></span></span>
</td>
diff --git a/src/main/java/com/gitblit/wicket/pages/TicketPage.java b/src/main/java/com/gitblit/wicket/pages/TicketPage.java index b2e63a60..cd049f4d 100644 --- a/src/main/java/com/gitblit/wicket/pages/TicketPage.java +++ b/src/main/java/com/gitblit/wicket/pages/TicketPage.java @@ -36,7 +36,6 @@ import org.apache.wicket.AttributeModifier; import org.apache.wicket.Component;
import org.apache.wicket.MarkupContainer;
import org.apache.wicket.PageParameters;
-import org.apache.wicket.RequestCycle;
import org.apache.wicket.RestartResponseException;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.behavior.SimpleAttributeModifier;
@@ -45,7 +44,6 @@ import org.apache.wicket.markup.html.image.ContextImage; import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.link.ExternalLink;
import org.apache.wicket.markup.html.link.Link;
-import org.apache.wicket.markup.html.link.StatelessLink;
import org.apache.wicket.markup.html.pages.RedirectPage;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.markup.repeater.Item;
@@ -54,7 +52,6 @@ import org.apache.wicket.markup.repeater.data.ListDataProvider; import org.apache.wicket.model.Model;
import org.apache.wicket.protocol.http.RequestUtils;
import org.apache.wicket.protocol.http.WebRequest;
-import org.apache.wicket.request.target.basic.RedirectRequestTarget;
import org.eclipse.jgit.diff.DiffEntry.ChangeType;
import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.lib.Ref;
@@ -863,9 +860,6 @@ public class TicketPage extends RepositoryPage { if (event.hasPatchset()) {
// patchset
Patchset patchset = event.patchset;
- //In the case of using a cached change list
- item.setVisible(!patchset.isDeleted());
-
String what;
if (event.isStatusChange() && (Status.New == event.getStatus())) {
what = getString("gb.proposedThisChange");
@@ -883,6 +877,7 @@ public class TicketPage extends RepositoryPage { LinkPanel psr = new LinkPanel("patchsetRevision", null, patchset.number + "-" + patchset.rev,
ComparePage.class, WicketUtils.newRangeParameter(repositoryName, patchset.parent == null ? patchset.base : patchset.parent, patchset.tip), true);
WicketUtils.setHtmlTooltip(psr, patchset.toString());
+ WicketUtils.setCssClass(psr, "aui-lozenge aui-lozenge-subtle");
item.add(psr);
String typeCss = getPatchsetTypeCss(patchset.type);
Label typeLabel = new Label("patchsetType", patchset.type.toString());
@@ -910,6 +905,42 @@ public class TicketPage extends RepositoryPage { item.add(new Label("patchsetType").setVisible(false));
item.add(new Label("deleteRevision").setVisible(false));
item.add(new Label("patchsetDiffStat").setVisible(false));
+ } else if (event.hasReference()) {
+ // reference
+ switch (event.reference.getSourceType()) {
+ case Commit: {
+ final int shaLen = app().settings().getInteger(Keys.web.shortCommitIdLength, 6);
+
+ item.add(new Label("what", getString("gb.referencedByCommit")));
+ LinkPanel psr = new LinkPanel("patchsetRevision", null, event.reference.toString().substring(0, shaLen),
+ CommitPage.class, WicketUtils.newObjectParameter(repositoryName, event.reference.toString()), true);
+ WicketUtils.setHtmlTooltip(psr, event.reference.toString());
+ WicketUtils.setCssClass(psr, "ticketReference-commit shortsha1");
+ item.add(psr);
+
+ } break;
+
+ case Ticket: {
+ final String text = MessageFormat.format("ticket/{0}", event.reference.ticketId);
+
+ item.add(new Label("what", getString("gb.referencedByTicket")));
+ //NOTE: Ideally reference the exact comment using reference.toString,
+ // however anchor hash is used and is escaped resulting in broken link
+ LinkPanel psr = new LinkPanel("patchsetRevision", null, text,
+ TicketsPage.class, WicketUtils.newObjectParameter(repositoryName, event.reference.ticketId.toString()), true);
+ WicketUtils.setCssClass(psr, "ticketReference-comment");
+ item.add(psr);
+ } break;
+
+ default: {
+ item.add(new Label("what").setVisible(false));
+ item.add(new Label("patchsetRevision").setVisible(false));
+ }
+ }
+
+ item.add(new Label("patchsetType").setVisible(false));
+ item.add(new Label("deleteRevision").setVisible(false));
+ item.add(new Label("patchsetDiffStat").setVisible(false));
} else if (event.hasReview()) {
// review
String score;
|