Skip to content

The Unified and Autonomous Development Platform

Add ability to squash commits when integrate a pull request.

robin shine0e86a793e4d7
diff --git a/commons.git/src/main/java/com/pmease/commons/git/command/CommitCommand.java b/commons.git/src/main/java/com/pmease/commons/git/command/CommitCommand.java
index 1e734e31fc..cf35c32a21 100644
--- a/commons.git/src/main/java/com/pmease/commons/git/command/CommitCommand.java
+++ b/commons.git/src/main/java/com/pmease/commons/git/command/CommitCommand.java
@@ -37,7 +37,7 @@ public class CommitCommand extends GitCommand<Void> {
this.add = add;
return this;
}
-
+
@Override
public Void call() {
Preconditions.checkNotNull(message, "Commit message has to be specified.");
@@ -54,13 +54,17 @@ public class CommitCommand extends GitCommand<Void> {
@Override
public void consume(String line) {
- logger.debug(line);
+ if (line.startsWith("no changes added to commit"))
+ logger.error(line);
+ else
+ logger.debug(line);
}
}, new LineConsumer() {
@Override
public void consume(String line) {
+ System.err.println(line);
if (line.startsWith("warning: "))
logger.warn(line.substring("warning: ".length()));
else if (line.startsWith("The file will have its original line endings"))
diff --git a/commons.git/src/main/java/com/pmease/commons/git/command/MergeCommand.java b/commons.git/src/main/java/com/pmease/commons/git/command/MergeCommand.java
index 83b14135d5..8945252b70 100644
--- a/commons.git/src/main/java/com/pmease/commons/git/command/MergeCommand.java
+++ b/commons.git/src/main/java/com/pmease/commons/git/command/MergeCommand.java
@@ -70,7 +70,7 @@ public class MergeCommand extends GitCommand<String> {
Commandline cmd = cmd().addArgs("merge");
- cmd.addArgs("--no-edit", "--log", "--quiet");
+ cmd.addArgs("--no-edit", "--quiet");
if (fastForwardMode == FastForwardMode.FF_ONLY)
cmd.addArgs("--ff-only");
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestManager.java
index ee3c9e09f0..6ecc4c9ce0 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestManager.java
@@ -5,9 +5,9 @@ import static com.pmease.gitplex.core.model.PullRequest.CriterionHelper.ofSource
import static com.pmease.gitplex.core.model.PullRequest.CriterionHelper.ofTarget;
import static com.pmease.gitplex.core.model.PullRequest.IntegrationStrategy.MERGE_ALWAYS;
import static com.pmease.gitplex.core.model.PullRequest.IntegrationStrategy.MERGE_IF_NECESSARY;
+import static com.pmease.gitplex.core.model.PullRequest.IntegrationStrategy.MERGE_WITH_SQUASH;
import static com.pmease.gitplex.core.model.PullRequest.IntegrationStrategy.REBASE_SOURCE_ONTO_TARGET;
import static com.pmease.gitplex.core.model.PullRequest.IntegrationStrategy.REBASE_TARGET_ONTO_SOURCE;
-import static com.pmease.gitplex.core.model.PullRequest.IntegrationStrategy.MERGE_WITH_SQUASH;
import java.io.File;
import java.util.Date;
@@ -153,17 +153,18 @@ public class DefaultPullRequestManager implements PullRequestManager {
Git git = request.getTarget().getRepository().git();
IntegrationStrategy strategy = request.getIntegrationStrategy();
if ((strategy == MERGE_ALWAYS || strategy == MERGE_IF_NECESSARY || strategy == MERGE_WITH_SQUASH)
- && !integrated.equals(preview.getRequestHead()) && comment != null) {
+ && !preview.getIntegrated().equals(preview.getRequestHead()) && comment != null) {
File tempDir = FileUtils.createTempDir();
try {
Git tempGit = new Git(tempDir);
tempGit.clone(git.repoDir().getAbsolutePath(), false, true, true, request.getTarget().getName());
+ tempGit.updateRef("HEAD", preview.getIntegrated(), null, null);
tempGit.reset(null, null);
- tempGit.updateRef("HEAD", integrated, null, null);
tempGit.commit(comment, false, true);
- preview.setIntegrated(tempGit.parseRevision("HEAD", true));
+ integrated = tempGit.parseRevision("HEAD", true);
git.fetch(tempGit, "+HEAD:" + request.getIntegrateRef());
+ comment = null;
} finally {
FileUtils.deleteDir(tempDir);
}
@@ -173,13 +174,13 @@ public class DefaultPullRequestManager implements PullRequestManager {
if (sourceGit.updateRef(request.getSource().getHeadRef(),
integrated, preview.getRequestHead(),
"Pull request #" + request.getId())) {
-
request.getSource().setHeadCommitHash(integrated);
request.getSource().setUpdater(user);
branchManager.save(request.getSource());
PullRequestUpdate update = new PullRequestUpdate();
update.setRequest(request);
+ update.setDate(new Date());
update.setUser(user);
update.setHeadCommitHash(integrated);
request.getUpdates().add(update);
@@ -314,7 +315,7 @@ public class DefaultPullRequestManager implements PullRequestManager {
@Override
public IntegrationPreview previewIntegration(PullRequest request) {
IntegrationPreview preview = request.getIntegrationPreview();
- if (preview != null
+ if (!request.isOpen() || preview != null
&& preview.getRequestHead().equals(request.getLatestUpdate().getHeadCommitHash())
&& preview.getTargetHead().equals(request.getTarget().getHeadCommitHash())
&& preview.getIntegrationStrategy() == request.getIntegrationStrategy()
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/IntegrationPreview.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/IntegrationPreview.java
index 93ccc1ba4d..e2fda88e38 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/IntegrationPreview.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/IntegrationPreview.java
@@ -48,6 +48,18 @@ public class IntegrationPreview implements Serializable {
return integrationStrategy;
}
+ public void setTargetHead(String targetHead) {
+ this.targetHead = targetHead;
+ }
+
+ public void setRequestHead(String requestHead) {
+ this.requestHead = requestHead;
+ }
+
+ public void setIntegrationStrategy(IntegrationStrategy integrationStrategy) {
+ this.integrationStrategy = integrationStrategy;
+ }
+
public String getIntegrated() {
return integrated;
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/assets/css/page.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/assets/css/page.css
index 8def10daf1..2f3632317d 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/assets/css/page.css
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/assets/css/page.css
@@ -684,6 +684,9 @@ h2.section-title { margin: 18px 0; font-size: 16px; }
.table-tags .list-inline a:hover { color: #09F; text-decoration: none; }
.table-tags .avatar { width: 64px; height: 64px; }
+/* BRANCH LINK */
+.branch-link .fa {margin-right: 2px;}
+
/* COMMITS */
.commit-message>.full {display: none; margin-top: 4px;}
.commit-message>.toggle {background: #DDD; padding: 0px 6px; border-radius: 2px;}
@@ -873,6 +876,17 @@ ul.status-help li:last-child .description {border-bottom: none;}
.request-detail>.overview>.panel-body>div:first-child {padding: 0 0 8px 0;}
.request-detail>.overview>.panel-body>div:first-child:last-child {padding: 0; border-bottom: none;}
+.request-detail>.overview>.panel-heading {padding: 8px 12px;}
+.request-detail>.overview>.panel-body {padding: 12px;}
+.request-detail>.overview>.panel-heading>span:before {font-family: "ponticons"; margin-right: 8px; font-size: 18px;}
+.request-detail>.overview.panel-success, .request-detail>.overview.panel-success>.panel-heading {border-color: #5EC01C;}
+.request-detail>.overview.panel-danger, .request-detail>.overview.panel-danger>.panel-heading {border-color: #E67E7E;}
+.request-detail>.overview.integrated>.panel-heading>span:before {content: "\f52A";}
+.request-detail>.overview.discarded>.panel-heading>span:before {content: "\f529";}
+.request-detail>.overview.pending-integrate>.panel-heading>span:before {content: "\f526";}
+.request-detail>.overview.pending-approval>.panel-heading>span:before {content: "\f11A";}
+.request-detail>.overview.pending-update>.panel-heading>span:before {content: "\f455";}
+
.request-detail>.overview>.panel-body>.status>.reasons>.reason .fa {font-size: 10px; vertical-align: middle;}
.request-detail>.overview>.panel-body>.integration>.preview>div {padding: 8px; margin: 8px 0 0 0;
border: none; box-shadow: none;}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestDetailPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestDetailPage.java
index ee1fe96359..4013d89e64 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestDetailPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestDetailPage.java
@@ -273,12 +273,17 @@ public abstract class RequestDetailPage extends RepositoryPage {
@Override
public String getObject() {
- if (getPullRequest().getStatus() == INTEGRATED)
- return "panel-success";
- else if (getPullRequest().getStatus() == DISCARDED)
- return "panel-danger";
- else
- return "panel-default";
+ PullRequest.Status status = getPullRequest().getStatus();
+ if (status == INTEGRATED)
+ return "panel-success integrated";
+ else if (status == DISCARDED)
+ return "panel-danger discarded";
+ else if (status == PENDING_INTEGRATE)
+ return "panel-default pending-integrate";
+ else if (status == PENDING_UPDATE)
+ return "panel-default pending-update";
+ else
+ return "panel-default pending-approval";
}
}));
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/ResolveConflictInstructionPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/ResolveConflictInstructionPanel.html
index f812386384..532d9e5799 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/ResolveConflictInstructionPanel.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/ResolveConflictInstructionPanel.html
@@ -82,33 +82,10 @@
</div>
</div>
<p>
- <p>Step 2: Resolve rebase conflicts, test chagnes and force push result commit to GitPlex.</p>
+ <p>Step 2: Resolve rebase conflicts, test changes and force push result commit to GitPlex.</p>
<div class="terminal">
git push -f origin <span wicket:id="srcBranchNameForPush"></span>
</div>
</div>
</wicket:fragment>
-
- <wicket:fragment wicket:id="squashFrag">
- <div class="conflict-resolve-instruction">
- <p>From working directory of repository <em wicket:id="destRepoName"></em>,
- check out target branch and merge with source branch with squash option.</p>
- <div class="terminal">
- <div>git checkout <span wicket:id="destBranchNameForCheckout"></span></div>
- <div wicket:id="sameRepo">
- <div>git fetch origin</div>
- <div>git merge --squash origin/<span wicket:id="srcBranchName"></span></div>
- </div>
- <div wicket:id="differentRepo">
- <div>git pull --squash <span wicket:id="srcRepoUrl"></span> <span wicket:id="srcBranchName"></span></div>
- </div>
- </div>
- <p>
- <p>Step 2: Resolve merge conflicts, commit merge result, test changes and force push result commit to GitPlex.</p>
- <div class="terminal">
- git commit
- git push -f origin <span wicket:id="destBranchNameForPush"></span>
- </div>
- </div>
- </wicket:fragment>
</wicket:panel>
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/ResolveConflictInstructionPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/ResolveConflictInstructionPanel.java
index dc3a3e6e16..cea4729826 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/ResolveConflictInstructionPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/ResolveConflictInstructionPanel.java
@@ -38,22 +38,7 @@ class ResolveConflictInstructionPanel extends Panel {
String sourceHead = preview.getRequestHead();
IntegrationStrategy strategy = request.getIntegrationStrategy();
boolean sameRepo = request.getTarget().getRepository().equals(request.getSource().getRepository());
- if (strategy == MERGE_WITH_SQUASH) {
- fragment = new Fragment("content", "squashFrag", this);
- fragment.add(new Label("destRepoName", request.getTarget().getRepository()));
- fragment.add(new Label("destBranchNameForCheckout", request.getTarget().getName()));
- fragment.add(new Label("destBranchNameForPush", request.getTarget().getName()));
- WebMarkupContainer sameRepoContainer = new WebMarkupContainer("sameRepo");
- sameRepoContainer.add(new Label("srcBranchName", request.getSource().getName()));
- sameRepoContainer.setVisible(sameRepo);
- fragment.add(sameRepoContainer);
- WebMarkupContainer differentRepoContainer = new WebMarkupContainer("differentRepo");
- differentRepoContainer.add(new Label("srcRepoUrl", request.getSource().getRepository().getUrl()));
- differentRepoContainer.add(new Label("srcBranchName", request.getSource().getName()));
- differentRepoContainer.setVisible(!sameRepo);
- fragment.add(differentRepoContainer);
- }
- if (strategy == REBASE_SOURCE_ONTO_TARGET) {
+ if (strategy == MERGE_WITH_SQUASH || strategy == REBASE_SOURCE_ONTO_TARGET) {
fragment = new Fragment("content", "rebaseInSourceFrag", this);
fragment.add(new Label("srcRepoName", request.getSource().getRepository()));
fragment.add(new Label("srcBranchNameForCheckout", request.getSource().getName()));