Skip to content

Commit

Permalink
fix(git): 🐛 Improve commit message for single badsmell PRs (#767)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinWitt authored Jun 24, 2023
1 parent 3bea25c commit b11d8a8
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,20 @@ private void createCommit(GHRepository repo, Path dir, List<? extends Change> ch

private String createCommitMessage(List<? extends Change> 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();
}

Expand Down

0 comments on commit b11d8a8

Please sign in to comment.