Allow "Whitespace" when Commit

This commit is contained in:
Muhammad Tamir
2025-06-19 21:02:15 +07:00
parent 0d1712efb1
commit ed065d5557

View File

@@ -21,14 +21,23 @@ public class GitCommitSubcommand implements SubcommandExecutor {
File repoFolder = new File("."); File repoFolder = new File(".");
String message = "Commit from Minecraft"; String message = "Commit from Minecraft";
for (String arg : args) { for (int i = 0; i < args.length; i++) {
String arg = args[i];
if (arg.startsWith("--path=")) { if (arg.startsWith("--path=")) {
repoFolder = new File(arg.substring("--path=".length())); repoFolder = new File(arg.substring("--path=".length()));
} else if (arg.startsWith("--message=") || arg.startsWith("-m=")) { } else if (arg.startsWith("--message=")) {
message = arg.contains("=") ? arg.split("=", 2)[1] : message; message = arg.substring("--message=".length());
} else if (arg.equals("-m") && i + 1 < args.length) {
message = args[i + 1];
i++; // Skip next token
} }
} }
if (message.length() > 50) {
sender.sendMessage("§cCommit message must not exceed 50 characters.");
return;
}
try { try {
GitManager git = new GitManager(repoFolder); GitManager git = new GitManager(repoFolder);
git.commit(message); git.commit(message);