-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Fix remote turn diff display roots #23261
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,23 @@ pub fn get_git_repo_root(base_dir: &Path) -> Option<PathBuf> { | |
| find_ancestor_git_entry(base).map(|(repo_root, _)| repo_root) | ||
| } | ||
|
|
||
| /// Return the repository root for `cwd` using the provided filesystem. | ||
| /// | ||
| /// This mirrors [`get_git_repo_root`] for local paths, but works when `cwd` | ||
| /// only exists inside a selected remote environment. | ||
| pub async fn get_git_repo_root_with_fs( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we convert the original and pass LOCAL_FS where needed?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we would need to convert existing callers to be async which blows this up a bit. im just fixing tests here, can do the LOCAL_FS conversion in a separate PR |
||
| fs: &dyn ExecutorFileSystem, | ||
| cwd: &AbsolutePathBuf, | ||
| ) -> Option<AbsolutePathBuf> { | ||
| let base = match fs.get_metadata(cwd, /*sandbox*/ None).await { | ||
| Ok(metadata) if metadata.is_directory => cwd.clone(), | ||
| _ => cwd.parent()?, | ||
| }; | ||
| find_ancestor_git_entry_with_fs(fs, &base) | ||
| .await | ||
| .map(|(repo_root, _)| repo_root) | ||
| } | ||
|
|
||
| /// Timeout for git commands to prevent freezing on large repositories | ||
| const GIT_COMMAND_TIMEOUT: TokioDuration = TokioDuration::from_secs(5); | ||
| const DISABLED_HOOKS_PATH: &str = if cfg!(windows) { "NUL" } else { "/dev/null" }; | ||
|
|
@@ -729,11 +746,8 @@ pub async fn resolve_root_git_project_for_trust( | |
| fs: &dyn ExecutorFileSystem, | ||
| cwd: &AbsolutePathBuf, | ||
| ) -> Option<AbsolutePathBuf> { | ||
| let base = match fs.get_metadata(cwd, /*sandbox*/ None).await { | ||
| Ok(metadata) if metadata.is_directory => cwd.clone(), | ||
| _ => cwd.parent()?, | ||
| }; | ||
| let (repo_root, dot_git) = find_ancestor_git_entry_with_fs(fs, &base).await?; | ||
| let repo_root = get_git_repo_root_with_fs(fs, cwd).await?; | ||
| let dot_git = repo_root.join(".git"); | ||
| if fs | ||
| .get_metadata(&dot_git, /*sandbox*/ None) | ||
| .await | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need the fallback?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.primary() returns Option - so either we need a fallback or should throw