Skip to content

Commit

Permalink
Merge pull request #266 from gradle/atual/same-version
Browse files Browse the repository at this point in the history
Set better commit message when wrapper files have not changed (#224)
  • Loading branch information
alextu authored Nov 27, 2024
2 parents 13ea0d9 + 648fc96 commit eb2c46d
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions src/main/java/org/gradle/wrapperupgrade/UpgradeWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ public abstract class UpgradeWrapper extends DefaultTask {
private final ExecOperations execOperations;

@Inject
public UpgradeWrapper(WrapperUpgradeDomainObject upgrade, BuildToolStrategy buildToolStrategy, ProjectLayout layout, ExecOperations execOperations) {
public UpgradeWrapper(
WrapperUpgradeDomainObject upgrade,
BuildToolStrategy buildToolStrategy,
ProjectLayout layout,
ExecOperations execOperations
) {
this.upgrade = upgrade;
this.buildToolStrategy = buildToolStrategy;
this.layout = layout;
Expand Down Expand Up @@ -121,8 +126,12 @@ private String createShortDescription(Params params) {
String usedBuildToolVersion = params.usedBuildToolVersion.version;
String relativePath = params.rootProjectDirRelativePath.normalize().toString();

String title = latestBuildToolVersion.equals(usedBuildToolVersion) ?
String.format("Update %s Wrapper version %s files", buildToolName, latestBuildToolVersion) :
String.format("Bump %s Wrapper from %s to %s", buildToolName, usedBuildToolVersion, latestBuildToolVersion);

StringBuilder description = new StringBuilder();
description.append(String.format("Bump %s Wrapper from %s to %s", buildToolName, usedBuildToolVersion, latestBuildToolVersion));
description.append(title);
if (!relativePath.isEmpty()) {
String path = relativePath.startsWith("/") ? relativePath : "/" + relativePath;
description.append(String.format(" in %s", path));
Expand All @@ -136,13 +145,18 @@ private String createLongDescription(Params params) {
String usedBuildToolVersion = params.usedBuildToolVersion.version;
String releaseNotesLink = buildToolStrategy.releaseNotesLink(latestBuildToolVersion);

StringBuilder description = new StringBuilder();
description.append(String.format("Bump %s Wrapper from %s to %s.", buildToolName, usedBuildToolVersion, latestBuildToolVersion));
description.append("\n\n");
description.append(String.format("Release notes of %s %s can be found here:", buildToolName, latestBuildToolVersion));
description.append("\n");
description.append(releaseNotesLink);
return description.toString();
boolean updatedWrapperFilesOnly = latestBuildToolVersion.equals(usedBuildToolVersion);
String title = updatedWrapperFilesOnly ?
String.format("Update %s Wrapper version %s files.", buildToolName, latestBuildToolVersion) :
String.format("Bump %s Wrapper from %s to %s.", buildToolName, usedBuildToolVersion, latestBuildToolVersion);

String releaseNotes = updatedWrapperFilesOnly ? "" :
"\n\n" +
String.format("Release notes of %s %s can be found here:", buildToolName, latestBuildToolVersion) +
"\n" +
releaseNotesLink;

return title + releaseNotes;
}

private void gitCommitAndPush(Params params, String commitMessage) {
Expand Down

0 comments on commit eb2c46d

Please sign in to comment.