diff --git a/common/src/main/java/net/pcal/fastback/commands/InfoCommand.java b/common/src/main/java/net/pcal/fastback/commands/InfoCommand.java index eb504872..ba966418 100644 --- a/common/src/main/java/net/pcal/fastback/commands/InfoCommand.java +++ b/common/src/main/java/net/pcal/fastback/commands/InfoCommand.java @@ -28,6 +28,7 @@ import net.pcal.fastback.retention.RetentionPolicy; import net.pcal.fastback.retention.RetentionPolicyCodec; import net.pcal.fastback.retention.RetentionPolicyType; +import net.pcal.fastback.utils.EnvironmentUtils; import java.util.function.Function; @@ -75,6 +76,8 @@ private static int info(final CommandSourceStack scs) { try { ulog.message(UserMessage.localized("fastback.chat.info-header")); ulog.message(UserMessage.localized("fastback.chat.info-fastback-version", mod().getModVersion())); + gitVersion = getGitVersion(); + gitLfsVersion = getGitLfsVersion(); if (!rf().isGitRepo(mod().getWorldDirectory())) { // If they haven't yet run 'backup init', make sure they've installed native. if (!isNativeOk(true, ulog, true)) return FAILURE; diff --git a/common/src/main/java/net/pcal/fastback/mod/ModImpl.java b/common/src/main/java/net/pcal/fastback/mod/ModImpl.java index 69b6df30..15c4449c 100644 --- a/common/src/main/java/net/pcal/fastback/mod/ModImpl.java +++ b/common/src/main/java/net/pcal/fastback/mod/ModImpl.java @@ -24,6 +24,7 @@ import net.pcal.fastback.logging.UserMessage; import net.pcal.fastback.repo.Repo; import net.pcal.fastback.repo.RepoFactory; +import net.pcal.fastback.utils.EnvironmentUtils; import org.eclipse.jgit.transport.SshSessionFactory; import java.io.IOException; @@ -37,8 +38,7 @@ import static net.pcal.fastback.config.FastbackConfigKey.SHUTDOWN_ACTION; import static net.pcal.fastback.logging.SystemLogger.syslog; import static net.pcal.fastback.logging.UserMessage.localized; -import static net.pcal.fastback.utils.EnvironmentUtils.getGitLfsVersion; -import static net.pcal.fastback.utils.EnvironmentUtils.getGitVersion; +import static net.pcal.fastback.utils.EnvironmentUtils.*; import static net.pcal.fastback.utils.Executor.executor; class ModImpl implements LifecycleListener, Mod { @@ -147,7 +147,7 @@ public Collection getModsBackupPaths() { @Override public void onInitialize() { { - final String gitVersion = getGitVersion(); + gitVersion = getGitVersion(); if (gitVersion == null) { syslog().warn("git is not installed."); } else { @@ -155,7 +155,7 @@ public void onInitialize() { } } { - final String gitLfsVersion = getGitLfsVersion(); + gitLfsVersion = getGitLfsVersion(); if (gitLfsVersion == null) { syslog().warn("git-lfs is not installed."); } else { diff --git a/common/src/main/java/net/pcal/fastback/utils/EnvironmentUtils.java b/common/src/main/java/net/pcal/fastback/utils/EnvironmentUtils.java index 55516b6f..d3115543 100644 --- a/common/src/main/java/net/pcal/fastback/utils/EnvironmentUtils.java +++ b/common/src/main/java/net/pcal/fastback/utils/EnvironmentUtils.java @@ -36,6 +36,9 @@ public class EnvironmentUtils { + public static String gitVersion; + public static String gitLfsVersion; + public static String getGitVersion() { return execForVersion(new String[]{"git", "--version"}); } @@ -57,8 +60,11 @@ public static boolean isNativeOk(final GitConfig conf, final UserLogger ulog, fi public static boolean isNativeOk(boolean isNativeGitEnabled, UserLogger ulog, boolean verbose) { if (isNativeGitEnabled) { final Component notInstalled = Component.translatable("fastback.values.not-installed"); - final String gitVersion = getGitVersion(); - final String gitLfsVersion = getGitLfsVersion(); + // if gitVersion or gitLfsVersion is null, then run the check again + if (gitVersion == null || gitLfsVersion == null) { + gitVersion = getGitVersion(); + gitLfsVersion = getGitLfsVersion(); + } final boolean isNativeInstalled = (gitVersion != null && gitLfsVersion != null); if (verbose || !isNativeInstalled) { ulog.message(localized("fastback.chat.info-native-git-version", gitVersion != null ? gitVersion : notInstalled));