修复右侧边栏“提交”区域在没有提交记录时显示错误

This commit is contained in:
xintaofei
2026-03-12 22:51:53 +08:00
parent 7a6ddb87ba
commit 080a969c1e
4 changed files with 14 additions and 4 deletions

View File

@@ -2475,6 +2475,13 @@ pub async fn git_log(
.map_err(AppCommandError::io)?;
if !output.status.success() {
// Empty repo (no commits yet) — return empty list instead of error
let stderr_str = String::from_utf8_lossy(&output.stderr);
if stderr_str.contains("does not have any commits yet")
|| stderr_str.contains("unknown revision or path not in the working tree")
{
return Ok(Vec::new());
}
return Err(git_command_error("log", &output.stderr));
}