commit ef703742ea3a2738787bec65d589b4cc7390a124 from: ale date: Thu Jul 23 21:20:21 2026 UTC Corrige commits duplicados en Show History y agrega logging real Reportado en vivo: cada commit aparecía duplicado en el panel de Show History. Causa: 'Show History' usa reportAppendableHistory(), no createSessionFor() -- pero reportAppendableHistory() llamaba a createSessionFor() para obtener una sesión YA POBLADA con todos los commits, se la pasaba a reportCreatedEmptySession() (que espera una sesión realmente vacía) y encima recorría cada revisión llamando acceptRevision() de nuevo: cada commit terminaba contado dos veces. Fix: reportAppendableHistory() ahora resuelve raíz/ruta con un helper compartido (resolveRootAndPath, antes duplicado con createSessionFor), construye la sesión con una lista vacía, y agrega cada revisión una sola vez vía session.appendRevision() + partner.acceptRevision(). Esto también explica por qué el 'Unknown error' de README.md nunca había quedado logueado: el logging que se agregó antes vivía en createSessionFor(), un método que este camino real (reportAppendableHistory) ni siquiera invocaba. Ahora tiene su propio logging con stack trace completo para diagnosticar si el fallo persiste. commit - 04a83492a79c046ffccb7e66432c2826f77894f3 commit + ef703742ea3a2738787bec65d589b4cc7390a124 blob - 83adda8dcd5a20b3bedf901e8f6830cd6c475514 blob + efda632ef746348220b4a1a99a564e390dfff8f4 --- src/main/kotlin/dev/nezzontli/gotvcs/GotVcsHistoryProvider.kt +++ src/main/kotlin/dev/nezzontli/gotvcs/GotVcsHistoryProvider.kt @@ -6,7 +6,6 @@ import com.intellij.openapi.vcs.FilePath import com.intellij.openapi.vcs.ProjectLevelVcsManager import com.intellij.openapi.vcs.VcsException import com.intellij.openapi.vcs.history.DiffFromHistoryHandler -import com.intellij.openapi.vcs.history.VcsAbstractHistorySession import com.intellij.openapi.vcs.history.VcsAppendableHistorySessionPartner import com.intellij.openapi.vcs.history.VcsDependentHistoryComponents import com.intellij.openapi.vcs.history.VcsFileRevision @@ -39,15 +38,22 @@ class GotVcsHistoryProvider( override fun canShowHistoryFor(virtualFile: com.intellij.openapi.vfs.VirtualFile): Boolean = true + private data class RootAndPath(val workDir: File, val relativePath: String) + @Throws(VcsException::class) + private fun resolveRootAndPath(filePath: FilePath): RootAndPath { + val vcsRoot = ProjectLevelVcsManager.getInstance(project).getVcsRootFor(filePath) + ?: throw VcsException("$filePath no pertenece a ningún work tree got") + val workDir = File(vcsRoot.path) + val relativePath = VfsUtilCore.getRelativePath(filePath.virtualFile ?: vcsRoot, vcsRoot) + ?: throw VcsException("No se pudo resolver la ruta relativa de $filePath en $workDir") + return RootAndPath(workDir, relativePath) + } + + @Throws(VcsException::class) override fun createSessionFor(filePath: FilePath): VcsHistorySession { try { - val vcsRoot = ProjectLevelVcsManager.getInstance(project).getVcsRootFor(filePath) - ?: throw VcsException("$filePath no pertenece a ningún work tree got") - val workDir = File(vcsRoot.path) - val relativePath = VfsUtilCore.getRelativePath(filePath.virtualFile ?: vcsRoot, vcsRoot) - ?: throw VcsException("No se pudo resolver la ruta relativa de $filePath en $workDir") - + val (workDir, relativePath) = resolveRootAndPath(filePath) val entries = commandLine.log(workDir, relativePath.ifEmpty { null }) val revisions: List = entries.map { GotFileRevision(workDir, relativePath, commandLine, it) } val baseRevision = GotRevisionNumber(commandLine.baseCommit(workDir)) @@ -66,11 +72,28 @@ class GotVcsHistoryProvider( @Throws(VcsException::class) override fun reportAppendableHistory(filePath: FilePath, partner: VcsAppendableHistorySessionPartner) { try { - val session = createSessionFor(filePath) as VcsAbstractHistorySession + val (workDir, relativePath) = resolveRootAndPath(filePath) + val baseRevision = GotRevisionNumber(commandLine.baseCommit(workDir)) + + // reportCreatedEmptySession espera una sesión REALMENTE vacía: el + // panel de "Show History" usa este camino (no createSessionFor), + // y pasarle una sesión ya poblada + acceptRevision() por cada + // entrada duplicaba cada commit (confirmado en vivo: cada fila + // aparecía dos veces). + val session = GotVcsHistorySession(emptyList(), baseRevision) partner.reportCreatedEmptySession(session) - session.revisionList.forEach { partner.acceptRevision(it) } + + val entries = commandLine.log(workDir, relativePath.ifEmpty { null }) + for (entry in entries) { + val revision = GotFileRevision(workDir, relativePath, commandLine, entry) + session.appendRevision(revision) + partner.acceptRevision(revision) + } } catch (e: VcsException) { partner.reportException(e) + } catch (e: Exception) { + LOG.warn("Fallo al construir el historial got (appendable) para $filePath", e) + partner.reportException(VcsException("${e.javaClass.simpleName}: ${e.message ?: "sin mensaje"}", e)) } } }