From 2190c1f365691b659ae1293ad537680daa86f257 Mon Sep 17 00:00:00 2001 From: Meng Zhang Date: Thu, 24 Oct 2024 20:39:57 -0700 Subject: [PATCH] fix(tabby-git): normalize path separators for platform compatibility related: https://github.com/TabbyML/tabby/issues/3314 --- crates/tabby-git/src/serve_git.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/tabby-git/src/serve_git.rs b/crates/tabby-git/src/serve_git.rs index 70b2fc6557c9..1c7ed9fa8d2e 100644 --- a/crates/tabby-git/src/serve_git.rs +++ b/crates/tabby-git/src/serve_git.rs @@ -19,10 +19,13 @@ fn resolve<'a>( rev: Option<&str>, relpath_str: Option<&str>, ) -> anyhow::Result> { + // relpath_str is always separated by `/`, need to process it into platform specific path (e.g `\` on windows). + let relpath_str = relpath_str.map(|s| s.replace('/', std::path::MAIN_SEPARATOR_STR)); + let commit = rev_to_commit(repository, rev)?; let tree = commit.tree()?; - let relpath = Path::new(relpath_str.unwrap_or("")); + let relpath = Path::new(relpath_str.as_deref().unwrap_or("")); let object = if relpath_str.is_some() { tree.get_path(relpath)?.to_object(repository)? } else {