Merge "Cut down to below 73 characters when reverting changes"
This commit is contained in:
commit
8b457aeb17
@ -1457,6 +1457,10 @@ response body.
|
|||||||
|
|
||||||
Reverts a change.
|
Reverts a change.
|
||||||
|
|
||||||
|
The subject of the newly created change will be
|
||||||
|
'Revert "<subject-of-reverted-change>"'. If the subject of the change reverted is
|
||||||
|
above 63 characters, it will be cut down to 59 characters with "..." in the end.
|
||||||
|
|
||||||
The request body does not need to include a link:#revert-input[
|
The request body does not need to include a link:#revert-input[
|
||||||
RevertInput] entity if no review comment is added.
|
RevertInput] entity if no review comment is added.
|
||||||
|
|
||||||
@ -1515,7 +1519,9 @@ the error message is contained in the response body.
|
|||||||
|
|
||||||
Creates open revert changes for all of the changes of a certain submission.
|
Creates open revert changes for all of the changes of a certain submission.
|
||||||
|
|
||||||
The subject of each revert change will be "Revert <subject-of-reverted-change".
|
The subject of each revert change will be 'Revert "<subject-of-reverted-change"'.
|
||||||
|
If the subject is above 63 characters, the subject will be cut to 59 characters
|
||||||
|
with "..." in the end.
|
||||||
|
|
||||||
Details for the revert can be specified in the request body inside a link:#revert-input[
|
Details for the revert can be specified in the request body inside a link:#revert-input[
|
||||||
RevertInput] The topic of all created revert changes will be
|
RevertInput] The topic of all created revert changes will be
|
||||||
|
@ -146,12 +146,14 @@ public class CommitUtil {
|
|||||||
revertCommitBuilder.setCommitter(authorIdent);
|
revertCommitBuilder.setCommitter(authorIdent);
|
||||||
|
|
||||||
Change changeToRevert = notes.getChange();
|
Change changeToRevert = notes.getChange();
|
||||||
|
String subject = changeToRevert.getSubject();
|
||||||
|
if (subject.length() > 63) {
|
||||||
|
subject = subject.substring(0, 59) + "...";
|
||||||
|
}
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
message =
|
message =
|
||||||
MessageFormat.format(
|
MessageFormat.format(
|
||||||
ChangeMessages.get().revertChangeDefaultMessage,
|
ChangeMessages.get().revertChangeDefaultMessage, subject, patch.commitId().name());
|
||||||
changeToRevert.getSubject(),
|
|
||||||
patch.commitId().name());
|
|
||||||
}
|
}
|
||||||
if (generatedChangeId != null) {
|
if (generatedChangeId != null) {
|
||||||
revertCommitBuilder.setMessage(ChangeIdUtil.insertId(message, generatedChangeId, true));
|
revertCommitBuilder.setMessage(ChangeIdUtil.insertId(message, generatedChangeId, true));
|
||||||
|
@ -313,6 +313,9 @@ public class RevertSubmission
|
|||||||
|
|
||||||
private String getMessage(RevertInput revertInput, ChangeNotes changeNotes) {
|
private String getMessage(RevertInput revertInput, ChangeNotes changeNotes) {
|
||||||
String subject = changeNotes.getChange().getSubject();
|
String subject = changeNotes.getChange().getSubject();
|
||||||
|
if (subject.length() > 63) {
|
||||||
|
subject = subject.substring(0, 59) + "...";
|
||||||
|
}
|
||||||
if (revertInput.message == null) {
|
if (revertInput.message == null) {
|
||||||
return MessageFormat.format(
|
return MessageFormat.format(
|
||||||
ChangeMessages.get().revertChangeDefaultMessage,
|
ChangeMessages.get().revertChangeDefaultMessage,
|
||||||
|
@ -283,6 +283,27 @@ public class RevertIT extends AbstractDaemonTest {
|
|||||||
.isEqualTo(revertInput.message);
|
.isEqualTo(revertInput.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void revertChangeWithLongSubject() throws Exception {
|
||||||
|
String changeTitle =
|
||||||
|
"This change has a very long title and therefore it will be cut to 50 characters when the"
|
||||||
|
+ " revert change will revert this change";
|
||||||
|
String result = createChange(changeTitle, "a.txt", "message").getChangeId();
|
||||||
|
gApi.changes().id(result).current().review(ReviewInput.approve());
|
||||||
|
gApi.changes().id(result).current().submit();
|
||||||
|
RevertInput revertInput = new RevertInput();
|
||||||
|
ChangeInfo revertChange = gApi.changes().id(result).revert(revertInput).get();
|
||||||
|
assertThat(revertChange.subject)
|
||||||
|
.isEqualTo(String.format("Revert \"%s...\"", changeTitle.substring(0, 59)));
|
||||||
|
assertThat(gApi.changes().id(revertChange.id).current().commit(false).message)
|
||||||
|
.isEqualTo(
|
||||||
|
String.format(
|
||||||
|
"Revert \"%s...\"\n\nThis reverts commit %s.\n\nChange-Id: %s\n",
|
||||||
|
changeTitle.substring(0, 59),
|
||||||
|
gApi.changes().id(result).get().currentRevision,
|
||||||
|
revertChange.changeId));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void revertNotifications() throws Exception {
|
public void revertNotifications() throws Exception {
|
||||||
PushOneCommit.Result r = createChange();
|
PushOneCommit.Result r = createChange();
|
||||||
@ -704,6 +725,28 @@ public class RevertIT extends AbstractDaemonTest {
|
|||||||
gApi.changes().id(result).get().currentRevision, revertChange.changeId));
|
gApi.changes().id(result).get().currentRevision, revertChange.changeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void revertSubmissionRevertsChangeWithLongSubject() throws Exception {
|
||||||
|
String changeTitle =
|
||||||
|
"This change has a very long title and therefore it will be cut to 50 characters when the"
|
||||||
|
+ " revert change will revert this change";
|
||||||
|
String result = createChange(changeTitle, "a.txt", "message").getChangeId();
|
||||||
|
gApi.changes().id(result).current().review(ReviewInput.approve());
|
||||||
|
gApi.changes().id(result).current().submit();
|
||||||
|
RevertInput revertInput = new RevertInput();
|
||||||
|
ChangeInfo revertChange =
|
||||||
|
gApi.changes().id(result).revertSubmission(revertInput).revertChanges.get(0);
|
||||||
|
assertThat(revertChange.subject)
|
||||||
|
.isEqualTo(String.format("Revert \"%s...\"", changeTitle.substring(0, 59)));
|
||||||
|
assertThat(gApi.changes().id(revertChange.id).current().commit(false).message)
|
||||||
|
.isEqualTo(
|
||||||
|
String.format(
|
||||||
|
"Revert \"%s...\"\n\nThis reverts commit %s.\n\nChange-Id: %s\n",
|
||||||
|
changeTitle.substring(0, 59),
|
||||||
|
gApi.changes().id(result).get().currentRevision,
|
||||||
|
revertChange.changeId));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@GerritConfig(name = "change.submitWholeTopic", value = "true")
|
@GerritConfig(name = "change.submitWholeTopic", value = "true")
|
||||||
public void revertSubmissionDifferentRepositoriesWithDependantChange() throws Exception {
|
public void revertSubmissionDifferentRepositoriesWithDependantChange() throws Exception {
|
||||||
|
Loading…
Reference in New Issue
Block a user