3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-20 15:00:11 +01:00

Use Indra to get branch name

Dieser Commit ist enthalten in:
Camotoy 2022-09-14 21:22:34 -04:00
Ursprung e64e12ff98
Commit 27b948a09b
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F

Datei anzeigen

@ -79,20 +79,18 @@ configure<BlossomExtension> {
val indra = the<IndraGitExtension>() val indra = the<IndraGitExtension>()
val mainFile = "src/main/java/org/geysermc/geyser/GeyserImpl.java" val mainFile = "src/main/java/org/geysermc/geyser/GeyserImpl.java"
val branchName = indra.branchName() ?: "DEV"
val commit = indra.commit() val commit = indra.commit()
val git = indra.git() val git = indra.git()
val gitVersion = "git-${branchName()}-${commit?.name?.substring(0, 7) ?: "0000000"}" val gitVersion = "git-${branchName}-${commit?.name?.substring(0, 7) ?: "0000000"}"
replaceToken("\${version}", "${project.version} ($gitVersion)", mainFile) replaceToken("\${version}", "${project.version} ($gitVersion)", mainFile)
replaceToken("\${gitVersion}", gitVersion, mainFile) replaceToken("\${gitVersion}", gitVersion, mainFile)
replaceToken("\${buildNumber}", buildNumber(), mainFile) replaceToken("\${buildNumber}", buildNumber(), mainFile)
replaceToken("\${branch}", branchName(), mainFile) replaceToken("\${branch}", branchName, mainFile)
if (commit != null && commit.name != null) replaceToken("\${commit}", commit.name, mainFile) if (commit != null && commit.name != null) replaceToken("\${commit}", commit.name, mainFile)
if (git != null) replaceToken("\${repository}", git.repository.config.getString("remote", "origin", "url")) if (git != null) replaceToken("\${repository}", git.repository.config.getString("remote", "origin", "url"))
} }
fun Project.branchName(): String =
System.getenv("GIT_BRANCH") ?: "local/dev"
fun Project.buildNumber(): Int = fun Project.buildNumber(): Int =
Integer.parseInt(System.getenv("BUILD_NUMBER") ?: "-1") Integer.parseInt(System.getenv("BUILD_NUMBER") ?: "-1")