Skip to content

Commit

Permalink
update report info
Browse files Browse the repository at this point in the history
  • Loading branch information
reymondzzzz committed Dec 29, 2023
1 parent 261162f commit 8e128ac
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
16 changes: 8 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,17 @@ fun getVersionString(baseVersion: String): String {
if (System.getenv("PUBLISH_EAP") != "1" &&
tag.isNotEmpty() && tag.contains(baseVersion)) return baseVersion

val branch = "git rev-parse --abbrev-ref HEAD".runCommand(workingDir = rootDir)
val numberOfCommits = if (branch == "main") {
val lastTag = "git describe --tags --abbrev=0 @^".runCommand(workingDir = rootDir)
"git rev-list ${lastTag}..HEAD --count".runCommand(workingDir = rootDir)
} else {
"git rev-list --count HEAD ^origin/main".runCommand(workingDir = rootDir)
}
val commitId = "git rev-parse --short=8 HEAD".runCommand(workingDir = rootDir)
return if (System.getenv("PUBLISH_EAP") == "1") {
"$baseVersion-eap-$commitId"
"$baseVersion.$numberOfCommits-eap-$commitId"
} else {
val branch = "git rev-parse --abbrev-ref HEAD".runCommand(workingDir = rootDir)
val numberOfCommits = if (branch == "main") {
val lastTag = "git describe --tags --abbrev=0 @^".runCommand(workingDir = rootDir)
"git rev-list ${lastTag}..HEAD --count".runCommand(workingDir = rootDir)
} else {
"git rev-list --count HEAD ^origin/main".runCommand(workingDir = rootDir)
}
"$baseVersion-$branch-$numberOfCommits-$commitId"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.smallcloud.refactai.struct.DeploymentMode
import java.awt.Component
import java.net.URLEncoder
import com.smallcloud.refactai.io.InferenceGlobalContext.Companion.instance as InferenceGlobalContext
import com.smallcloud.refactai.lsp.LSPProcessHolder.Companion.instance as LSPProcessHolder

private fun String.urlEncoded(): String = URLEncoder.encode(this, "UTF-8")

Expand Down Expand Up @@ -42,6 +43,7 @@ class PluginErrorReportSubmitter : ErrorReportSubmitter(), Disposable {
"; Vendor: " + properties.getProperty("java.vendor", "unknown")
val os = SystemInfo.getOsNameAndVersion()
val arch = SystemInfo.OS_ARCH
var buildInfo = LSPProcessHolder.buildInfo()
val issueBody = """
|An internal error happened in the IDE plugin.
|
Expand All @@ -59,6 +61,7 @@ class PluginErrorReportSubmitter : ErrorReportSubmitter(), Disposable {
|- OS: $os
|- ARCH: $arch
|- MODE: $mode
|- LSP BUILD INFO: $buildInfo
|
|### Additional information
|${additionalInfo.orEmpty()}
Expand Down
17 changes: 16 additions & 1 deletion src/main/kotlin/com/smallcloud/refactai/lsp/LSPProcessHolder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class LSPProcessHolder: Disposable {
address = address,
apiKey = AccountManager.apiKey,
port = (32000..32199).random(),
clientVersion = "${Resources.client}-${Resources.version}",
clientVersion = "${Resources.client}-${Resources.version}/${Resources.jbBuildVersion}",
useTelemetry = true,
deployment = InferenceGlobalContext.deploymentMode
)
Expand Down Expand Up @@ -226,6 +226,21 @@ class LSPProcessHolder: Disposable {
schedulerCaps.shutdown()
}

fun buildInfo(): String {
var res = ""
InferenceGlobalContext.connection.get(url.resolve("/build_info"),
dataReceiveEnded = {},
errorDataReceived = {}).also {
try {
res = it.get().get() as String
logger.debug("build_info request finished")
} catch (e: Exception) {
logger.debug("build_info ${e.message}")
}
}
return res
}

val url: URI
get() {
val port = xDebugLSPPort?: lastConfig?.port ?: return URI("")
Expand Down

0 comments on commit 8e128ac

Please sign in to comment.