Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tabby-git): normalize path separators for platform compatibility #3320

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion crates/tabby-git/src/serve_git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ fn resolve<'a>(
rev: Option<&str>,
relpath_str: Option<&str>,
) -> anyhow::Result<Resolve<'a>> {
// 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 {
Expand Down
Loading