commit 5fbd71374af6fcbdf415765ab7001f4a7a6d7322 from: ale date: Sat Jul 25 02:27:58 2026 UTC Resolver GOT_AUTHOR automáticamente desde git config si el repo no lo define got.conf de un repo recién clonado solo trae el remote, no un author, así que got commit fallaba con "GOT_AUTHOR environment variable is not set" en cualquier repo clonado sin configuración manual previa. Ahora se resuelve user.name/user.email vía git config como fallback -- got.conf y la config local del repo siguen ganando por precedencia, así que esto nunca pisa un author explícito. Confirmado en vivo contra un repo real. commit - d0d47588e6e7212652f98d758170e30ee404ed6d commit + 5fbd71374af6fcbdf415765ab7001f4a7a6d7322 blob - a6ed987a10b8e363ec14e65568d0c7a2070cb521 blob + c584da39d3036d8a88c6f29b6219b90d673833d7 --- src/main/kotlin/dev/nezzontli/gotvcs/cli/GotCommandLineWrapper.kt +++ src/main/kotlin/dev/nezzontli/gotvcs/cli/GotCommandLineWrapper.kt @@ -56,12 +56,32 @@ class GotCommandLineWrapper { return if (fallback.exists()) fallback.path else null } + /** + * A freshly `got clone`d repo's got.conf only stores the remote, so + * `got commit` fails with "GOT_AUTHOR environment variable is not set" + * until something provides an author. got.conf and repo-local git config + * both take precedence over this env var, so setting it is a safe + * fallback that never overrides an explicit per-repo author. + */ + private val gitAuthorFallback: String? by lazy { + fun gitConfigValue(key: String): String? = try { + val output = ExecUtil.execAndGetOutput(GeneralCommandLine("git", "config", "--get", key)) + output.stdout.trim().takeIf { output.exitCode == 0 && it.isNotEmpty() } + } catch (e: ExecutionException) { + null + } + val name = gitConfigValue("user.name") ?: return@lazy null + val email = gitConfigValue("user.email") ?: return@lazy null + "$name <$email>" + } + private fun run(workDir: File, vararg args: String): String { val commandLine = GeneralCommandLine(binaryPath(), *args) .withWorkDirectory(workDir) .withCharset(StandardCharsets.UTF_8) .withParentEnvironmentType(GeneralCommandLine.ParentEnvironmentType.SYSTEM) sshAuthSock()?.let { commandLine.environment["SSH_AUTH_SOCK"] = it } + gitAuthorFallback?.let { commandLine.environment["GOT_AUTHOR"] = it } val output = try { ExecUtil.execAndGetOutput(commandLine) } catch (e: ExecutionException) {