diff options
| author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-10-18 16:29:51 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-18 16:29:51 +0200 |
| commit | cacff66c3d86b80f5868e70aad26eff41ad0092d (patch) | |
| tree | 2424fd92098a1fb0a28ad508259d0478da158499 | |
| parent | ef2ca6fbbdf89e56c71e9425f887450d362d13a4 (diff) | |
| download | SkyHanni-cacff66c3d86b80f5868e70aad26eff41ad0092d.tar.gz SkyHanni-cacff66c3d86b80f5868e70aad26eff41ad0092d.tar.bz2 SkyHanni-cacff66c3d86b80f5868e70aad26eff41ad0092d.zip | |
Backend: More precise repo debug (#2747)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt | 14 | ||||
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/test/DebugCommand.kt | 22 |
2 files changed, 28 insertions, 8 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt index 1d81502f3..3b5915fee 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.data.repo import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigManager +import at.hannibal2.skyhanni.config.features.dev.RepositoryConfig import at.hannibal2.skyhanni.events.NeuRepositoryReloadEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.test.command.ErrorManager @@ -59,6 +60,12 @@ class RepoManager(private val configLocation: File) { fun getRepoLocation(): String { return "${config.location.user}/${config.location.name}/${config.location.branch}" } + + private val defaultUser = "hannibal002" + private val defaultName = "SkyHanni-REPO" + private val defaultBranch = "main" + + fun RepositoryConfig.RepositoryLocation.hasDefaultSettings() = user == defaultUser && name == defaultName && branch == defaultBranch } fun loadRepoInformation() { @@ -317,12 +324,9 @@ class RepoManager(private val configLocation: File) { } fun resetRepositoryLocation(manual: Boolean = false) { - val defaultUser = "hannibal002" - val defaultName = "SkyHanni-Repo" - val defaultBranch = "main" with(config.location) { - if (user == defaultUser && name == defaultName && branch == defaultBranch) { + if (hasDefaultSettings()) { if (manual) { ChatUtils.chat("Repo settings are already on default!") } @@ -346,7 +350,7 @@ class RepoManager(private val configLocation: File) { } private fun checkRepoLocation() { - if (config.location.user.isEmpty() || config.location.name.isEmpty() || config.location.branch.isEmpty()) { + if (config.location.run { user.isEmpty() || name.isEmpty() || branch.isEmpty() }) { ChatUtils.userError("Invalid Repo settings detected, resetting default settings.") resetRepositoryLocation() } diff --git a/src/main/java/at/hannibal2/skyhanni/test/DebugCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/DebugCommand.kt index f464a66ce..d75b5abc6 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/DebugCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/DebugCommand.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.HypixelData import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.data.repo.RepoManager +import at.hannibal2.skyhanni.data.repo.RepoManager.Companion.hasDefaultSettings import at.hannibal2.skyhanni.events.DebugDataCollectEvent import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils @@ -145,10 +146,18 @@ object DebugCommand { private fun repoData(event: DebugDataCollectEvent) { event.title("Repo Information") - event.addIrrelevant { - add(" repoAutoUpdate: ${SkyHanniMod.feature.dev.repo.repoAutoUpdate}") + val config = SkyHanniMod.feature.dev.repo + + val hasDefaultSettings = config.location.hasDefaultSettings() + val list = buildList { + add(" repoAutoUpdate: ${config.repoAutoUpdate}") add(" usingBackupRepo: ${RepoManager.usingBackupRepo}") - add(" repoLocation: '${RepoManager.getRepoLocation()}'") + if (hasDefaultSettings) { + add((" repo location: default")) + } else { + add(" non-default repo location: '${RepoManager.getRepoLocation()}'") + } + if (RepoManager.unsuccessfulConstants.isNotEmpty()) { add(" unsuccessful constants:") for (constant in RepoManager.unsuccessfulConstants) { @@ -156,6 +165,13 @@ object DebugCommand { } } } + + val isRelevant = RepoManager.usingBackupRepo || RepoManager.unsuccessfulConstants.isNotEmpty() || !hasDefaultSettings + if (isRelevant) { + event.addData(list) + } else { + event.addIrrelevant(list) + } } private fun player(event: DebugDataCollectEvent) { |
