mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-30 14:34:22 +01:00
Merge 'Fix git directory resolution in simulator to support worktrees' from Jussi Saurio
sim cannot be run in a git worktree on main Closes #3794
This commit is contained in:
@@ -470,12 +470,18 @@ impl BugBase {
|
||||
}
|
||||
|
||||
fn find_git_dir(start_path: impl AsRef<Path>) -> Option<PathBuf> {
|
||||
// HACK ignores stuff like bare repo, worktree, etc.
|
||||
let mut current = start_path.as_ref().to_path_buf();
|
||||
loop {
|
||||
let git_path = current.join(".git");
|
||||
if git_path.is_dir() {
|
||||
return Some(git_path);
|
||||
} else if git_path.is_file() {
|
||||
// Handle git worktrees - .git is a file containing "gitdir: <path>"
|
||||
if let Ok(contents) = read_to_string(&git_path) {
|
||||
if let Some(gitdir) = contents.strip_prefix("gitdir: ") {
|
||||
return Some(PathBuf::from(gitdir));
|
||||
}
|
||||
}
|
||||
}
|
||||
if !current.pop() {
|
||||
return None;
|
||||
|
||||
Reference in New Issue
Block a user