Skip to content

Commit

Permalink
Fix command argument order
Browse files Browse the repository at this point in the history
  • Loading branch information
Matyrobbrt committed Aug 11, 2024
1 parent 1487d0d commit 8a0f0a5
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions src/main/java/net/neoforged/automation/command/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,34 @@ public class Commands {
public static CommandDispatcher<GHCommandContext> register(CommandDispatcher<GHCommandContext> dispatcher) {
dispatcher.register(literal("run")
.requires(Requirement.IS_PR.and(Requirement.IS_MAINTAINER.or(Requirement.IS_PR)))
.then(argument("tasks", StringArgumentType.greedyString()))
.executes(FunctionalInterfaces.throwingCommand(context -> {
var pr = context.getSource().pullRequest();
var config = Configuration.get();
var repoConfig = Configuration.get(context.getSource().repository());
if (repoConfig.baseRunCommand() != null) {
var tasks = context.getArgument("tasks", String.class).trim();
var comment = pr.comment("Running Gradle tasks `" + tasks + "`...");
FormattingCommand.run(
context.getSource().gitHub(), pr,
config.prActions(), repoConfig,
Arrays.stream(tasks.split(" ")).map(t -> "./gradlew " + t).collect(Collectors.joining(" && ")),
err -> {
context.getSource().onError().run();
try {
context.getSource().issue()
.comment("Workflow failed: " + err.getHtmlUrl());
} catch (Exception ex) {
throw new RuntimeException(ex);
.then(argument("tasks", StringArgumentType.greedyString())
.executes(FunctionalInterfaces.throwingCommand(context -> {
var pr = context.getSource().pullRequest();
var config = Configuration.get();
var repoConfig = Configuration.get(context.getSource().repository());
if (repoConfig.baseRunCommand() != null) {
var tasks = context.getArgument("tasks", String.class).trim();
var comment = pr.comment("Running Gradle tasks `" + tasks + "`...");
FormattingCommand.run(
context.getSource().gitHub(), pr,
config.prActions(), repoConfig,
Arrays.stream(tasks.split(" ")).map(t -> "./gradlew " + t).collect(Collectors.joining(" && ")),
err -> {
context.getSource().onError().run();
try {
context.getSource().issue()
.comment("Workflow failed: " + err.getHtmlUrl());
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}, () -> {
context.getSource().onSuccess().run();
FunctionalInterfaces.ignoreExceptions(comment::delete);
}
}, () -> {
context.getSource().onSuccess().run();
FunctionalInterfaces.ignoreExceptions(comment::delete);
}
);
}
return GHCommandContext.DEFERRED_RESPONSE;
})));
);
}
return GHCommandContext.DEFERRED_RESPONSE;
}))));

return dispatcher;
}
Expand Down

0 comments on commit 8a0f0a5

Please sign in to comment.