mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
fancynpcs: add snapshot changelog and implement GitService for commit details
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package de.oliver.deployment.git;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class GitService {
|
||||
|
||||
public static String getCommitHash() {
|
||||
ProcessBuilder processBuilder = new ProcessBuilder("git", "rev-parse", "HEAD");
|
||||
processBuilder.redirectErrorStream(true);
|
||||
processBuilder.directory(new java.io.File("."));
|
||||
|
||||
try {
|
||||
Process process = processBuilder.start();
|
||||
return new String(process.getInputStream().readAllBytes()).trim();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
public static String getCommitMessage() {
|
||||
ProcessBuilder processBuilder = new ProcessBuilder("git", "log", "-1", "--pretty=%B");
|
||||
processBuilder.redirectErrorStream(true);
|
||||
processBuilder.directory(new java.io.File("."));
|
||||
|
||||
try {
|
||||
Process process = processBuilder.start();
|
||||
return new String(process.getInputStream().readAllBytes()).trim();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.oliver.deployment.modrinth;
|
||||
|
||||
import de.oliver.deployment.Configuration;
|
||||
import de.oliver.deployment.git.GitService;
|
||||
import masecla.modrinth4j.client.agent.UserAgent;
|
||||
import masecla.modrinth4j.endpoints.version.CreateVersion;
|
||||
import masecla.modrinth4j.main.ModrinthAPI;
|
||||
@@ -32,6 +33,9 @@ public class ModrinthService {
|
||||
|
||||
public void deployPlugin(Configuration config) throws IOException {
|
||||
String changelog = Files.readString(Path.of(config.changeLogPath()));
|
||||
changelog = changelog.replaceAll("%COMMIT_HASH%", GitService.getCommitHash());
|
||||
changelog = changelog.replaceAll("%COMMIT_MESSAGE%", GitService.getCommitMessage());
|
||||
|
||||
String version = Files.readString(Path.of(config.versionPath()));
|
||||
|
||||
String pluginJarPath = config.pluginJarPath().replace("%VERSION%", version);
|
||||
|
||||
Reference in New Issue
Block a user