The Unified and Autonomous Development Platform
Add a new gate keeper: verify if target branch is merged into source branch
robin shineccb4ccc458b3
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/TargetBranchIsMerged.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/TargetBranchIsMerged.javanew file mode 100644index 0000000000..04ff48444d--- /dev/null+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/TargetBranchIsMerged.java@@ -0,0 +1,41 @@+package com.pmease.gitplex.core.gatekeeper;++import org.eclipse.jgit.lib.ObjectId;+import org.eclipse.jgit.revwalk.RevCommit;++import com.google.common.collect.Lists;+import com.pmease.commons.git.GitUtils;+import com.pmease.commons.wicket.editable.annotation.Editable;+import com.pmease.gitplex.core.entity.Account;+import com.pmease.gitplex.core.entity.Depot;+import com.pmease.gitplex.core.entity.PullRequest;+import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;++@Editable(order=3100, icon="fa-ext fa-branch-merge", description="This gatekeeper will be passed if "+ + "head commit of target branch is merged into source branch of the pull request")+public class TargetBranchIsMerged extends AbstractGateKeeper {++ private static final long serialVersionUID = 1L;++ @Override+ protected GateCheckResult doCheckRequest(PullRequest request) {+ RevCommit requestHeadCommit = request.getHeadCommit();+ RevCommit branchHeadCommit = request.getTarget().getCommit();+ if (!GitUtils.isMergedInto(request.getTargetDepot().getRepository(), branchHeadCommit, requestHeadCommit)) {+ return failed(Lists.newArrayList("Please merge target branch into the source branch first"));+ } else {+ return passed(Lists.newArrayList("No more than one commit"));+ }+ }++ @Override+ protected GateCheckResult doCheckFile(Account user, Depot depot, String branch, String file) {+ return ignored();+ }++ @Override+ protected GateCheckResult doCheckPush(Account user, Depot depot, String refName, ObjectId oldCommit, ObjectId newCommit) {+ return ignored();+ }++}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/newrequest/NewRequestPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/newrequest/NewRequestPage.htmlindex c79ce46915..3e38905279 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/newrequest/NewRequestPage.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/newrequest/NewRequestPage.html@@ -49,7 +49,7 @@<wicket:fragment wicket:id="integratedFrag"><div class="alert alert-success"><div class="summary">- <span class="fa fa-lg fa-check-circle"></span>+ <span class="fa fa-lg fa-check"></span><a wicket:id="targetBranch"></a> is up to date with all commits from <a wicket:id="sourceBranch"></a>.Try <a wicket:id="swapBranches">swap source and target</a> for the comparison.</div>@@ -58,8 +58,8 @@<wicket:fragment wicket:id="rejectedFrag"><div class="alert alert-danger"><div class="summary">- <span class="fa fa-lg fa-ban"></span>- <span class="message">Gatekeeper of target repository rejects the integration request for below reasons:</span>+ <span class="fa fa-lg fa-warning"></span>+ <span class="message">Gatekeeper of target repository rejects the pull request for below reasons:</span></div><ul class="detail"><li wicket:id="reasons"><span wicket:id="reason"></span></li>diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/RequestDetailPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/RequestDetailPage.htmlindex 2854b276a0..cec544c306 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/RequestDetailPage.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/RequestDetailPage.html@@ -1,115 +1,115 @@-<wicket:extend>- <div id="request-detail">- <div wicket:id="requestHead" class="head clearfix">- <div wicket:id="title" class="title pull-left"></div>- <div wicket:id="number" class="number pull-left"></div>- <a wicket:id="editLink" title="Edit title" class="edit"><i class="fa fa-pencil"></i></a>- <form wicket:id="editForm" class="pull-left form-inline">- <input wicket:id="title" type="text" placeholder="Input title" class="form-control focusable"></input>- <input wicket:id="save" type="submit" value="Save" class="btn btn-primary"/>- <input wicket:id="cancel" type="button" value="Cancel" class="btn btn-default"/>- </form>- </div>- <div wicket:id="statusAndBranches" class="status-and-branches clearfix">- <div wicket:id="status" class="label pull-left status"></div>- <div class="pull-left branches">- <a wicket:id="user"></a> <span wicket:id="action"></span> into <a wicket:id="target" class="branch"></a>- from <a wicket:id="source" class="branch"></a> <span wicket:id="date"></span>- </div>- </div>- <div wicket:id="requestSummary" class="summary well">- <div wicket:id="discardedNote">- <i class="fa fa-info-circle"></i> This pull request has been discarded.- </div>- <div wicket:id="pendingUpdateNote" class="note with-status-reasons">- <i class="fa fa-exclamation-triangle"></i> This pull request does not pass gatekeeper- checks below, and needs to be updated with new commits.- </div>- <div wicket:id="pendingApprovalNote" class="note with-status-reasons">- <i class="fa fa-exclamation-triangle"></i> This pull request needs to be approved/verified as below, before it can be integrated- </div>- <div wicket:id="integratedNote" class="integrated-note">- <div wicket:id="fastForwarded">- <i class="fa fa-info-circle"></i> Target branch was fast-forwarded to source branch.- </div>- <div wicket:id="merged">- <i class="fa fa-info-circle"></i> Target branch was merged with source branch.- </div>- <div wicket:id="mergedOutside">- <i class="fa fa-info-circle"></i> Target branch was merged with source branch by someone outside of this pull request.- </div>- <div wicket:id="squashed">- <p><i class="fa fa-info-circle"></i> Per integration strategy, pending commits in source branch was squashed- before merging into target branch. Run this command if you want to sync local- branch with the source branch:- <kbd>git fetch origin && git rebase</kbd>- </p>- </div>- <div wicket:id="sourceRebased">- <p><i class="fa fa-info-circle"></i> Per integration strategy, pending commits in source branch was rebased- before merging into target branch. Run this command if you want to sync local- branch with the source branch:- <kbd>git fetch origin && git rebase</kbd>- </p>- </div>- <div wicket:id="targetRebased">- <p><i class="fa fa-info-circle"></i> Per integration strategy, target branch was rebased on top of source branch.- Run this command if you want to sync local branch with the target branch:- <kbd>git fetch origin && git rebase</kbd>- </p>- </div>- </div>- <div wicket:id="statusReasons" class="status-reasons">- <ul><li wicket:id="reasons" class="reason"><span wicket:id="reason"></span></li></ul>- </div>- <div wicket:id="integrationPreview" class="integration-preview">- <div wicket:id="calculating">- <wicket:link>- <img src="ajax-indicator.gif"></img> Calculating integration preview...- </wicket:link>- </div>- <div wicket:id="noConflict" class="no-conflict">- <label><i class="fa fa-check-circle"></i> Able to integrate without conflicts</label>- <wicket:enclosure child="preview">- <span class="middot"></span> <span><a wicket:id="preview">Preview</a> the integration result</span>- </wicket:enclosure>- <wicket:enclosure child="verification">- <span class="middot"></span> <span>Integration build verification <span wicket:id="verification"></span></span>- </wicket:enclosure>- </div>- <div wicket:id="conflict" class="conflict">- <span><i class="fa fa-warning"></i> There are integration conflicts.</span>- <wicket:enclosure child="resolveInstructionsTrigger">- Please follow <a wicket:id="resolveInstructionsTrigger" href="javascript:void(0);">this instruction</a> to resolve the conflicts.- </wicket:enclosure>- </div>- </div>- <div wicket:id="operations" class="operations">- <div class="buttons">- <a wicket:id="approve" class="btn btn-primary">Approve</a>- <a wicket:id="disapprove" class="btn btn-primary">Disapprove</a>- <a wicket:id="integrate" class="btn btn-success">Integrate</a>- <a wicket:id="discard" class="btn btn-danger">Discard</a>- <a wicket:id="reopen" class="btn btn-primary">Reopen</a>- <a wicket:id="deleteSourceBranch" class="btn btn-primary">Delete source branch</a>- <a wicket:id="restoreSourceBranch" class="btn btn-primary">Restore source branch</a>- </div>- <div wicket:id="confirm" class="confirm"></div>- </div>- </div>- <ul wicket:id="requestTabs" class="tabs nav nav-tabs"></ul>- <wicket:child></wicket:child>- </div>- <wicket:fragment wicket:id="operationConfirmFrag">- <form wicket:id="form" class="leave-confirm">- <div wicket:id="hint" class="hint"></div>- <div wicket:id="feedback"></div>- <textarea wicket:id="note" class="form-control focusable" rows="5" placeholder="Leave a note"></textarea>- <input wicket:id="submit" type="submit" value="Confirm" class="btn"></input>- <input wicket:id="cancel" type="button" value="Cancel" class="btn btn-default"></input>- </form>- </wicket:fragment>- <wicket:fragment wicket:id="codeCommentsTabLinkFrag">- <a wicket:id="link"><i class="fa fa-circle"></i> Code Comments</a>- </wicket:fragment>+<wicket:extend>+ <div id="request-detail">+ <div wicket:id="requestHead" class="head clearfix">+ <div wicket:id="title" class="title pull-left"></div>+ <div wicket:id="number" class="number pull-left"></div>+ <a wicket:id="editLink" title="Edit title" class="edit"><i class="fa fa-pencil"></i></a>+ <form wicket:id="editForm" class="pull-left form-inline">+ <input wicket:id="title" type="text" placeholder="Input title" class="form-control focusable"></input>+ <input wicket:id="save" type="submit" value="Save" class="btn btn-primary"/>+ <input wicket:id="cancel" type="button" value="Cancel" class="btn btn-default"/>+ </form>+ </div>+ <div wicket:id="statusAndBranches" class="status-and-branches clearfix">+ <div wicket:id="status" class="label pull-left status"></div>+ <div class="pull-left branches">+ <a wicket:id="user"></a> <span wicket:id="action"></span> into <a wicket:id="target" class="branch"></a>+ from <a wicket:id="source" class="branch"></a> <span wicket:id="date"></span>+ </div>+ </div>+ <div wicket:id="requestSummary" class="summary well">+ <div wicket:id="discardedNote">+ <i class="fa fa-info-circle"></i> This pull request has been discarded.+ </div>+ <div wicket:id="pendingUpdateNote" class="note with-status-reasons">+ <i class="fa fa-info-circle"></i> This pull request does not pass gatekeeper+ checks below, and needs to be updated with new commits.+ </div>+ <div wicket:id="pendingApprovalNote" class="note with-status-reasons">+ <i class="fa fa-info-circle"></i> This pull request needs to be approved/verified as below, before it can be integrated+ </div>+ <div wicket:id="integratedNote" class="integrated-note">+ <div wicket:id="fastForwarded">+ <i class="fa fa-info-circle"></i> Target branch was fast-forwarded to source branch.+ </div>+ <div wicket:id="merged">+ <i class="fa fa-info-circle"></i> Target branch was merged with source branch.+ </div>+ <div wicket:id="mergedOutside">+ <i class="fa fa-info-circle"></i> Target branch was merged with source branch by someone outside of this pull request.+ </div>+ <div wicket:id="squashed">+ <p><i class="fa fa-info-circle"></i> Per integration strategy, pending commits in source branch was squashed+ before merging into target branch. Run this command if you want to sync local+ branch with the source branch:+ <kbd>git fetch origin && git rebase</kbd>+ </p>+ </div>+ <div wicket:id="sourceRebased">+ <p><i class="fa fa-info-circle"></i> Per integration strategy, pending commits in source branch was rebased+ before merging into target branch. Run this command if you want to sync local+ branch with the source branch:+ <kbd>git fetch origin && git rebase</kbd>+ </p>+ </div>+ <div wicket:id="targetRebased">+ <p><i class="fa fa-info-circle"></i> Per integration strategy, target branch was rebased on top of source branch.+ Run this command if you want to sync local branch with the target branch:+ <kbd>git fetch origin && git rebase</kbd>+ </p>+ </div>+ </div>+ <div wicket:id="statusReasons" class="status-reasons">+ <ul><li wicket:id="reasons" class="reason"><span wicket:id="reason"></span></li></ul>+ </div>+ <div wicket:id="integrationPreview" class="integration-preview">+ <div wicket:id="calculating">+ <wicket:link>+ <img src="ajax-indicator.gif"></img> Calculating integration preview...+ </wicket:link>+ </div>+ <div wicket:id="noConflict" class="no-conflict">+ <label><i class="fa fa-check-circle"></i> Able to integrate without conflicts</label>+ <wicket:enclosure child="preview">+ <span class="middot"></span> <span><a wicket:id="preview">Preview</a> the integration result</span>+ </wicket:enclosure>+ <wicket:enclosure child="verification">+ <span class="middot"></span> <span>Integration build verification <span wicket:id="verification"></span></span>+ </wicket:enclosure>+ </div>+ <div wicket:id="conflict" class="conflict">+ <span><i class="fa fa-warning"></i> There are integration conflicts.</span>+ <wicket:enclosure child="resolveInstructionsTrigger">+ Please follow <a wicket:id="resolveInstructionsTrigger" href="javascript:void(0);">this instruction</a> to resolve the conflicts.+ </wicket:enclosure>+ </div>+ </div>+ <div wicket:id="operations" class="operations">+ <div class="buttons">+ <a wicket:id="approve" class="btn btn-primary">Approve</a>+ <a wicket:id="disapprove" class="btn btn-primary">Disapprove</a>+ <a wicket:id="integrate" class="btn btn-success">Integrate</a>+ <a wicket:id="discard" class="btn btn-danger">Discard</a>+ <a wicket:id="reopen" class="btn btn-primary">Reopen</a>+ <a wicket:id="deleteSourceBranch" class="btn btn-primary">Delete source branch</a>+ <a wicket:id="restoreSourceBranch" class="btn btn-primary">Restore source branch</a>+ </div>+ <div wicket:id="confirm" class="confirm"></div>+ </div>+ </div>+ <ul wicket:id="requestTabs" class="tabs nav nav-tabs"></ul>+ <wicket:child></wicket:child>+ </div>+ <wicket:fragment wicket:id="operationConfirmFrag">+ <form wicket:id="form" class="leave-confirm">+ <div wicket:id="hint" class="hint"></div>+ <div wicket:id="feedback"></div>+ <textarea wicket:id="note" class="form-control focusable" rows="5" placeholder="Leave a note"></textarea>+ <input wicket:id="submit" type="submit" value="Confirm" class="btn"></input>+ <input wicket:id="cancel" type="button" value="Cancel" class="btn btn-default"></input>+ </form>+ </wicket:fragment>+ <wicket:fragment wicket:id="codeCommentsTabLinkFrag">+ <a wicket:id="link"><i class="fa fa-circle"></i> Code Comments</a>+ </wicket:fragment></wicket:extend>\ No newline at end of file