Skip to content

Commit

Permalink
SLI-1381 Error when a background task has no ProgressIndicator or Job
Browse files Browse the repository at this point in the history
  • Loading branch information
nquinquenel committed Oct 17, 2024
1 parent 4dbe93e commit fc46144
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion git/src/main/kotlin/org/sonarlint/intellij/git/GitRepo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,13 @@ class GitRepo(private val repo: GitRepository, private val project: Project) : V
}

private fun distance(project: Project, repository: GitRepository, from: String, to: String): Int? {
val mergeBase = GitHistoryUtils.getMergeBase(project, repository.root, from, to) ?: return null
val mergeBase = try {
GitHistoryUtils.getMergeBase(project, repository.root, from, to) ?: return null
} catch (e: IllegalStateException) {
// SLI-1381: "There is no ProgressIndicator or Job in this thread" should simply be a loud error
SonarLintConsole.get(project).debug("Couldn't compute the git distance, reason: ${e.message}")
return null
}
val aheadCount = getNumberOfCommitsBetween(repository, from, mergeBase.asString()) ?: return null
val behindCount = getNumberOfCommitsBetween(repository, to, mergeBase.asString()) ?: return null
return aheadCount + behindCount
Expand Down

0 comments on commit fc46144

Please sign in to comment.