fun getRevisionId()

in src/main/kotlin/org/jetbrains/qodana/requests.kt [290:311]


fun getRevisionId(sarifPath: String): String? {
    return try {
        val reader = JsonReader(FileReader(sarifPath))
        val jsonObject = JsonParser.parseReader(reader).asJsonObject
        val runsArray = jsonObject.getAsJsonArray("runs")

        if (runsArray.size() == 0) return null

        val runObject = runsArray[0].asJsonObject
        val versionControlArray = runObject.getAsJsonArray("versionControlProvenance")

        if (versionControlArray.size() == 0) return null

        versionControlArray[0].asJsonObject.get("revisionId")?.asString
    } catch (e: FileNotFoundException) {
        logger.error("File not found: ${e.localizedMessage}")
        null
    } catch (e: Exception) {
        logger.error("Failed to parse JSON: ${e.localizedMessage}")
        null
    }
}