From f993f870b23805438a1b2f6104130733d008b4bd Mon Sep 17 00:00:00 2001 From: Martin Wittlinger Date: Sat, 24 Jun 2023 18:58:57 +0200 Subject: [PATCH] =?UTF-8?q?fix(git):=20=F0=9F=90=9B=20Improve=20commit=20m?= =?UTF-8?q?essage=20for=20single=20badsmell=20PRs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/RefactorService.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/github-bot/src/main/java/io/github/martinwitt/laughing_train/services/RefactorService.java b/github-bot/src/main/java/io/github/martinwitt/laughing_train/services/RefactorService.java index ad3c0960f..b9f5e3d9c 100644 --- a/github-bot/src/main/java/io/github/martinwitt/laughing_train/services/RefactorService.java +++ b/github-bot/src/main/java/io/github/martinwitt/laughing_train/services/RefactorService.java @@ -212,12 +212,20 @@ private void createCommit(GHRepository repo, Path dir, List ch private String createCommitMessage(List changes) { StringBuilder message = new StringBuilder(); - message.append("Refactor bad smells:\n"); - changes.stream().map(Change::getBadSmell).distinct().forEach(v -> message.append("- ") - .append(v.getName().asText()) - .append("\n") - .append(v.getDescription().asText()) - .append("\n")); + if (changes.stream().map(v -> v.getBadSmell()).distinct().count() == 1) { + message.append("Refactor bad smell ") + .append(changes.get(0).getBadSmell().getName().asText()) + .append("\n\n") + .append(changes.get(0).getBadSmell().getDescription().asText()); + + } else { + message.append("Refactor bad smells ") + .append(changes.stream() + .map(v -> v.getBadSmell().getName().asText()) + .distinct() + .collect(Collectors.joining(", "))) + .append("\n"); + } return message.toString(); }