Refactor of GitInfo. Removed core commit, and added Build Source
This commit is contained in:
+13
-13
@@ -31,16 +31,16 @@ import org.apache.logging.log4j.Logger;
|
||||
*
|
||||
* @author coolGi
|
||||
*/
|
||||
public final class ModGitInfo
|
||||
public final class ModJarInfo
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final String FILE_NAME = "build_info.json";
|
||||
|
||||
static
|
||||
{
|
||||
String gitMainBranch = "UNKNOWN";
|
||||
String gitMainCommit = "UNKNOWN";
|
||||
String gitCoreCommit = "UNKNOWN";
|
||||
String gitBranch = "UNKNOWN";
|
||||
String gitCommit = "UNKNOWN";
|
||||
String buildSource = "UNKNOWN";
|
||||
|
||||
try
|
||||
{
|
||||
@@ -50,22 +50,22 @@ public final class ModGitInfo
|
||||
Config jsonObject = Config.inMemory();
|
||||
JsonFormat.minimalInstance().createParser().parse(jsonString, jsonObject, ParsingMode.REPLACE);
|
||||
|
||||
gitCoreCommit = jsonObject.get("git_main_branch");
|
||||
gitMainCommit = jsonObject.get("git_main_commit");
|
||||
gitMainBranch = jsonObject.get("git_core_commit");
|
||||
gitBranch = jsonObject.get("info_git_branch");
|
||||
gitCommit = jsonObject.get("info_git_commit");
|
||||
buildSource = jsonObject.get("info_build_source");
|
||||
}
|
||||
catch (Exception | Error e)
|
||||
{
|
||||
LOGGER.warn("Unable to get the Git information from " + FILE_NAME);
|
||||
}
|
||||
|
||||
Git_Core_Commit = gitMainBranch;
|
||||
Git_Main_Commit = gitMainCommit;
|
||||
Git_Main_Branch = gitCoreCommit;
|
||||
Git_Commit = gitBranch;
|
||||
Git_Branch = gitCommit;
|
||||
Build_Source = buildSource;
|
||||
}
|
||||
|
||||
public static final String Git_Main_Branch;
|
||||
public static final String Git_Main_Commit;
|
||||
public static final String Git_Core_Commit;
|
||||
public static final String Git_Branch;
|
||||
public static final String Git_Commit;
|
||||
public static final String Build_Source;
|
||||
|
||||
}
|
||||
@@ -22,7 +22,7 @@ package com.seibel.distanthorizons.core.jar.updater;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.jar.JarUtils;
|
||||
import com.seibel.distanthorizons.core.jar.ModGitInfo;
|
||||
import com.seibel.distanthorizons.core.jar.ModJarInfo;
|
||||
import com.seibel.distanthorizons.core.jar.installer.GitlabGetter;
|
||||
import com.seibel.distanthorizons.core.jar.installer.ModrinthGetter;
|
||||
import com.seibel.distanthorizons.core.jar.installer.WebDownloader;
|
||||
@@ -126,7 +126,7 @@ public class SelfUpdater
|
||||
return false;
|
||||
com.electronwill.nightconfig.core.Config pipeline = GitlabGetter.INSTANCE.projectPipelines.get(0);
|
||||
|
||||
if (!pipeline.get("ref").equals(ModGitInfo.Git_Main_Branch))
|
||||
if (!pipeline.get("ref").equals(ModJarInfo.Git_Branch))
|
||||
{
|
||||
//LOGGER.warn("Latest pipeline was found for branch ["+ pipeline.get("ref") +"], but we are on branch ["+ ModGitInfo.Git_Main_Branch +"].");
|
||||
return false;
|
||||
@@ -134,7 +134,7 @@ public class SelfUpdater
|
||||
|
||||
if (!pipeline.get("status").equals("success"))
|
||||
{
|
||||
LOGGER.warn("Pipeline for branch ["+ ModGitInfo.Git_Main_Branch +"], commit ["+ pipeline.get("id") +"], has either failed to build, or still building.");
|
||||
LOGGER.warn("Pipeline for branch ["+ ModJarInfo.Git_Branch +"], commit ["+ pipeline.get("id") +"], has either failed to build, or still building.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ public class SelfUpdater
|
||||
|
||||
String latestCommit = pipeline.get("sha");
|
||||
|
||||
if (ModGitInfo.Git_Main_Commit.equals(latestCommit)) // If we are already on the latest commit, then dont update
|
||||
if (ModJarInfo.Git_Commit.equals(latestCommit)) // If we are already on the latest commit, then dont update
|
||||
return false;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user