Fix BuildInformationCrashCategory
All checks were successful
PRs & Pushes / test (push) Successful in 4m1s
PRs & Pushes / build-jars (push) Successful in 4m0s
PRs & Pushes / build-apidoc (push) Successful in 4m15s

This commit is contained in:
JeremyStar™ 2025-01-01 16:13:19 +01:00
parent 9685729de9
commit 90158850ef
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D
2 changed files with 32 additions and 26 deletions

View file

@ -33,7 +33,7 @@ import de.staropensource.engine.base.utility.dnihbd.BuildInformation
* @constructor Initializes this crash category
* @since v1-alpha10
*/
class EngineCrashCategory private constructor() : BuildInformation.BuildInformationCrashCategory() {
class EngineCrashCategory private constructor() : BuildInformation.BuildInformationCrashCategory({ Engine.info }) {
/**
* Companion object of [EngineCrashCategory].
*

View file

@ -19,7 +19,6 @@
package de.staropensource.engine.base.utility.dnihbd
import de.staropensource.engine.base.Engine.Companion.info
import de.staropensource.engine.base.implementable.logging.CrashCategory
import de.staropensource.engine.base.type.Origin
import de.staropensource.engine.base.type.logging.Call
@ -35,7 +34,6 @@ import java.io.InputStreamReader
import java.io.Reader
import java.io.StringReader
import java.util.*
import kotlin.Throws
/**
* Loads the specified `-git.properties` and
@ -62,7 +60,10 @@ import kotlin.Throws
@Suppress("Unused")
open class BuildInformation
@Throws(RuntimeException::class)
constructor(val loadPrefix: String, val loadLocation: FileAccess? = null) {
constructor(
val loadPrefix: String,
val loadLocation: FileAccess? = null
) {
// -----> Versioning
/**
* Returns the current version string.
@ -433,15 +434,20 @@ open class BuildInformation
* details about your running build.
*
* @constructor Initializes this crash category
* @param lambda lambda which returns a [BuildInformation] instance to use
* @since v1-alpha10
*/
abstract class BuildInformationCrashCategory : CrashCategory {
abstract class BuildInformationCrashCategory(
val lambda: () -> BuildInformation?
) : CrashCategory {
override fun execute(
call: Call,
channelSettings: ChannelSettings?,
throwable: Throwable?,
fatal: Boolean,
): LinkedHashMap<String, Any?> {
val info: BuildInformation? = lambda.invoke()
// Check if Engine.info is 'null'
if (info == null)
return linkedMapOf(
@ -452,71 +458,71 @@ open class BuildInformation
// Add metadata
// -> Versioning
map.put("Version", "${info!!.versionString(semver = false)} \"${info!!.versionCodename}\"")
map.put("Version", "${info.versionString(semver = false)} \"${info.versionCodename}\"")
// -> Languages
if (!info!!.languages.isEmpty()) {
if (!info.languages.isEmpty()) {
val languagesMap: LinkedHashMap<String, String> = linkedMapOf()
// Add all languages
for (language: String in info!!.languages.keys)
languagesMap.put(language, info!!.languages[language]!!)
for (language: String in info.languages.keys)
languagesMap.put(language, info.languages[language]!!)
// Add to output map
map.put("Languages", languagesMap)
}
// -> Dependencies
if (!info!!.dependencies.isEmpty()) {
if (!info.dependencies.isEmpty()) {
val dependenciesMap: LinkedHashMap<String, String> = linkedMapOf()
// Add all dependencies
for (dependency: String in info!!.dependencies.keys)
dependenciesMap.put(dependency, info!!.dependencies[dependency]!!)
for (dependency: String in info.dependencies.keys)
dependenciesMap.put(dependency, info.dependencies[dependency]!!)
// Add to output map
map.put("Dependencies", dependenciesMap)
}
if (!info!!.testDependencies.isEmpty()) {
if (!info.testDependencies.isEmpty()) {
val testDependenciesMap: LinkedHashMap<String, String> = linkedMapOf()
// Add all test dependencies
for (testDependency: String in info!!.testDependencies.keys)
testDependenciesMap.put(testDependency, info!!.testDependencies[testDependency]!!)
for (testDependency: String in info.testDependencies.keys)
testDependenciesMap.put(testDependency, info.testDependencies[testDependency]!!)
// Add to output map
map.put("Test dependencies", testDependenciesMap)
}
// -> Git
if (info!!.gitFaked)
if (info.gitFaked)
map.put("Git", "Unavailable")
else {
val gitMap: LinkedHashMap<String, Any> = linkedMapOf()
val gitCommitMap: LinkedHashMap<String, Any> = linkedMapOf()
val gitCommitAuthorMap: LinkedHashMap<String, String> = linkedMapOf()
val gitBuilderMap: LinkedHashMap<String, String> = linkedMapOf()
val gitCommitTime: LocalDateTime = info!!.gitCommitTime.toLocalDateTime(TimeZone.UTC)
val gitCommitTime: LocalDateTime = info.gitCommitTime.toLocalDateTime(TimeZone.UTC)
// Add to 'gitCommitAuthorMap'
gitCommitAuthorMap.put("Username", info!!.gitCommitAuthorUsername)
gitCommitAuthorMap.put("Email address", info!!.gitCommitAuthorEmail)
gitCommitAuthorMap.put("Username", info.gitCommitAuthorUsername)
gitCommitAuthorMap.put("Email address", info.gitCommitAuthorEmail)
// Add to 'gitCommitMap'
gitCommitMap.put("Identifier", info!!.gitCommitIdentifierLong)
gitCommitMap.put("Message (short)", info!!.gitCommitMessageShort)
gitCommitMap.put("Identifier", info.gitCommitIdentifierLong)
gitCommitMap.put("Message (short)", info.gitCommitMessageShort)
gitCommitMap.put("Time", "${gitCommitTime.dayOfMonth}.${gitCommitTime.monthNumber}.${gitCommitTime.year} ${gitCommitTime.hour}:${gitCommitTime.minute}:${gitCommitTime.second} UTC")
gitCommitMap.put("Author", gitCommitAuthorMap)
// Add to 'gitCommitMap'
gitBuilderMap.put("Hostname", info!!.gitBuildHostname)
gitBuilderMap.put("Username", info!!.gitBuildUsername)
gitBuilderMap.put("Email address", info!!.gitBuildEmail)
gitBuilderMap.put("Hostname", info.gitBuildHostname)
gitBuilderMap.put("Username", info.gitBuildUsername)
gitBuilderMap.put("Email address", info.gitBuildEmail)
// Add to 'gitMap'
gitMap.put("Dirty", if (info!!.gitDirty) "yes" else "no")
gitMap.put("Branch", info!!.gitBranch)
gitMap.put("Dirty", if (info.gitDirty) "yes" else "no")
gitMap.put("Branch", info.gitBranch)
gitMap.put("Commit", gitCommitMap)
gitMap.put("Builder", gitBuilderMap)