#310 - Polishing.
Add linebreak to commit message only if detail is present.
This commit is contained in:
@@ -42,11 +42,16 @@ public class Commit {
|
|||||||
|
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
builder.append(ticket.getId()).append(" - ").append(summary).append("\n");
|
builder.append(ticket.getId()).append(" - ").append(summary);
|
||||||
|
|
||||||
|
if (!summary.endsWith(".")) {
|
||||||
|
builder.append(".");
|
||||||
|
}
|
||||||
|
|
||||||
details.ifPresent(it -> {
|
details.ifPresent(it -> {
|
||||||
builder.append("\n");
|
builder.append("\n");
|
||||||
builder.append(it).append("\n");
|
builder.append("\n");
|
||||||
|
builder.append(it);
|
||||||
});
|
});
|
||||||
|
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.springframework.data.release.git;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.*;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
|
import org.springframework.data.release.issues.Ticket;
|
||||||
|
import org.springframework.data.release.issues.TicketStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Mark Paluch
|
||||||
|
*/
|
||||||
|
public class CommitUnitTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldRenderCommitMessage() {
|
||||||
|
|
||||||
|
assertThat(new Commit(new Ticket("1234", "Hello", Mockito.mock(TicketStatus.class)), "Summary", Optional.empty()))
|
||||||
|
.hasToString("1234 - Summary.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldRenderCommitMessageWithDetail() {
|
||||||
|
|
||||||
|
assertThat(
|
||||||
|
new Commit(new Ticket("1234", "Hello", Mockito.mock(TicketStatus.class)), "Summary", Optional.of("detail")))
|
||||||
|
.hasToString("1234 - Summary.\n" + "\n" + "detail");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user