Mark cherry-pick change as WIP if cherry-pick resulted in conflicts

Marking the target change as work-in-progress makes it more obvious to
users that conflicts need to be resolved before the change can be
submitted.

Change-Id: I585f75050d49151db6a685b6dc75119b44826c9d
Signed-off-by: Edwin Kempin <ekempin@google.com>
(cherry picked from commit 3c4113abdf)
This commit is contained in:
Edwin Kempin
2018-10-12 10:49:33 +02:00
parent cd6d87fa65
commit 341fd94394
3 changed files with 10 additions and 3 deletions

View File

@@ -5969,7 +5969,8 @@ created change contain git conflict markers to indicate the conflicts.
Callers can find out if there were conflicts by checking the Callers can find out if there were conflicts by checking the
`contains_git_conflicts` field in the link:#cherry-pick-change-info[ `contains_git_conflicts` field in the link:#cherry-pick-change-info[
CherryPickChangeInfo] that is returned by the cherry-pick REST CherryPickChangeInfo] that is returned by the cherry-pick REST
endpoints. endpoints. If there are conflicts the cherry-pick change is marked as
work-in-progress.
|=========================== |===========================
[[comment-info]] [[comment-info]]

View File

@@ -369,6 +369,7 @@ public class CherryPickChange {
messageForDestinationChange( messageForDestinationChange(
ins.getPatchSetId(), sourceBranch, sourceCommit, cherryPickCommit)) ins.getPatchSetId(), sourceBranch, sourceCommit, cherryPickCommit))
.setTopic(topic) .setTopic(topic)
.setWorkInProgress(!cherryPickCommit.getFilesWithGitConflicts().isEmpty())
.setNotify(input.notify) .setNotify(input.notify)
.setAccountsToNotify(notifyUtil.resolveAccounts(input.notifyDetails)); .setAccountsToNotify(notifyUtil.resolveAccounts(input.notifyDetails));
if (input.keepReviewers && sourceChange != null) { if (input.keepReviewers && sourceChange != null) {

View File

@@ -320,10 +320,13 @@ public class RevisionIT extends AbstractDaemonTest {
assertThat(orig.get().messages).hasSize(1); assertThat(orig.get().messages).hasSize(1);
CherryPickChangeInfo changeInfo = orig.revision(r.getCommit().name()).cherryPickAsInfo(in); CherryPickChangeInfo changeInfo = orig.revision(r.getCommit().name()).cherryPickAsInfo(in);
assertThat(changeInfo.containsGitConflicts).isNull(); assertThat(changeInfo.containsGitConflicts).isNull();
assertThat(changeInfo.workInProgress).isNull();
ChangeApi cherry = gApi.changes().id(changeInfo._number); ChangeApi cherry = gApi.changes().id(changeInfo._number);
Collection<ChangeMessageInfo> messages = ChangeInfo changeInfoWithDetails =
gApi.changes().id(project.get() + "~master~" + r.getChangeId()).get().messages; gApi.changes().id(project.get() + "~master~" + r.getChangeId()).get();
assertThat(changeInfoWithDetails.workInProgress).isNull();
Collection<ChangeMessageInfo> messages = changeInfoWithDetails.messages;
assertThat(messages).hasSize(2); assertThat(messages).hasSize(2);
String cherryPickedRevision = cherry.get().currentRevision; String cherryPickedRevision = cherry.get().currentRevision;
@@ -546,6 +549,7 @@ public class RevisionIT extends AbstractDaemonTest {
CherryPickChangeInfo cherryPickChange = CherryPickChangeInfo cherryPickChange =
changeApi.revision(r.getCommit().name()).cherryPickAsInfo(in); changeApi.revision(r.getCommit().name()).cherryPickAsInfo(in);
assertThat(cherryPickChange.containsGitConflicts).isTrue(); assertThat(cherryPickChange.containsGitConflicts).isTrue();
assertThat(cherryPickChange.workInProgress).isTrue();
// Verify that subject and topic on the cherry-pick change have been correctly populated. // Verify that subject and topic on the cherry-pick change have been correctly populated.
assertThat(cherryPickChange.subject).contains(in.message); assertThat(cherryPickChange.subject).contains(in.message);
@@ -580,6 +584,7 @@ public class RevisionIT extends AbstractDaemonTest {
// Get details of cherry-pick change. // Get details of cherry-pick change.
ChangeInfo cherryPickChangeWithDetails = gApi.changes().id(cherryPickChange._number).get(); ChangeInfo cherryPickChangeWithDetails = gApi.changes().id(cherryPickChange._number).get();
assertThat(cherryPickChangeWithDetails.workInProgress).isTrue();
// Verify that a message has been posted on the original change. // Verify that a message has been posted on the original change.
String cherryPickedRevision = cherryPickChangeWithDetails.currentRevision; String cherryPickedRevision = cherryPickChangeWithDetails.currentRevision;