Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  GitUtils.kt   Sprache: unbekannt

 
Spracherkennung für: .kt vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

package utils

import java.io.File

/**
 * Return the git hash, if git is installed.
 */
fun getGitHash(): String =
    runGitCommand("rev-parse", "--short", "HEAD")
        ?.ifEmpty { "?" }
        ?: "?"

/**
 * Return the latest available domain version from git, if git is installed.
 */
fun getGitVersion(): String? {
    val domainTagPrefix = "domain-v"
    val output = runGitCommand("describe", "--tags", "--match", "$domainTagPrefix*")
        ?: return null
    val regex = "^$domainTagPrefix([0-9.]+).*\$".toRegex()
    return regex.find(output)
        ?.groups
        ?.get(1)
        ?.value
}

/**
 * Return the name of the current git branch, if git is installed and the app is built from a git repository.
 * Otherwise, an empty string is returned.
 */
fun getGitBranch(): String? =
    runGitCommand("rev-parse", "--abbrev-ref", "HEAD")
        .orEmpty()

private fun runGitCommand(vararg args:  String): String? {
    val outputFile = File.createTempFile("git-command", "")
    try {
        val processBuilder = ProcessBuilder(listOf("git") + args.toList())
        processBuilder.redirectOutput(outputFile)
        val process = processBuilder.start()
        process.waitFor()
        return outputFile.readText().trim()
    } catch (_: Exception) {
        return null
    } finally {
        outputFile.delete()
    }
}

[Dauer der Verarbeitung: 0.24 Sekunden, vorverarbeitet 2026-04-27]

                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge