Skip to content

Commit

Permalink
Merge pull request #263 from StefMa/support-labels
Browse files Browse the repository at this point in the history
Support for custom labels
  • Loading branch information
alextu authored Nov 25, 2024
2 parents daae1ae + 43987d6 commit 13ea0d9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ wrapperUpgrade {
| `baseBranch` | The git branch to checkout and that the pull request will target |
| `options.gitCommitExtraArgs` | List of additional git commit arguments |
| `options.allowPreRelease` | Boolean: true will get the latest Maven/Gradle version even if it's a pre-release. Default is false. |
| `options.labels` | Optional list of label (names) that will be added to the PR. |

## License

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/gradle/wrapperupgrade/UpgradeWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ private void gitCommitAndPush(Params params, String commitMessage) {
private void gitCreatePr(Params params, String prTitle, String prBody) throws IOException {
if (!isDryRun()) {
GHPullRequest pr = params.gitHub.getRepository(params.repository).createPullRequest(prTitle, params.prBranch, params.baseBranch, prBody);
List<String> labels = upgrade.getOptions().getLabels().get();
if (!labels.isEmpty()) {
pr.addLabels(labels.toArray(new String[0]));
}
getLogger().lifecycle(String.format("PR '%s' created at %s to upgrade %s Wrapper to %s for project '%s'",
params.prBranch, pr.getHtmlUrl(), buildToolStrategy.buildToolName(), params.latestBuildToolVersion.version, params.project));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ public static class Options {

private final ListProperty<String> gitCommitExtraArgs;
private final Property<Boolean> allowPreRelease;
private final ListProperty<String> labels;

@Inject
public Options(ObjectFactory objects) {
this.gitCommitExtraArgs = objects.listProperty(String.class);
this.allowPreRelease = objects.property(Boolean.class);
this.labels = objects.listProperty(String.class);
}

public ListProperty<String> getGitCommitExtraArgs() {
Expand All @@ -65,6 +67,10 @@ public ListProperty<String> getGitCommitExtraArgs() {
public Property<Boolean> getAllowPreRelease() {
return allowPreRelease;
}

public ListProperty<String> getLabels() {
return labels;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class GradleWrapperUpgradePluginFuncTest extends Specification {
dir = 'samples/gradle'
options {
allowPreRelease = ${allowPreRelease}
labels = ["dependencies", "java"]
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ wrapperUpgrade {
dir = 'samples/maven'
options {
allowPreRelease = ${allowPreRelease}
labels = ["dependencies", "java"]
}
}
}
Expand Down

0 comments on commit 13ea0d9

Please sign in to comment.