mirror of
https://github.com/NekoMonci12/Git-Craft.git
synced 2025-12-19 14:59:22 +00:00
Allow "Whitespace" when Commit
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user