Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend: More precise repo debug #2747

Open
wants to merge 1 commit into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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!")
}
Expand All @@ -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()
}
Expand Down
22 changes: 19 additions & 3 deletions src/main/java/at/hannibal2/skyhanni/test/DebugCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -145,17 +146,32 @@ 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) {
add(" - $constant")
}
}
}

val isRelevant = RepoManager.usingBackupRepo || RepoManager.unsuccessfulConstants.isNotEmpty() || !hasDefaultSettings
if (isRelevant) {
event.addData(list)
} else {
event.addIrrelevant(list)
}
}

private fun player(event: DebugDataCollectEvent) {
Expand Down
Loading