Small worktree scan style fixes (#36104)

Part of https://github.com/zed-industries/zed/issues/35780

Release Notes:

- N/A
This commit is contained in:
Kirill Bulatov 2025-08-13 14:29:53 +03:00 committed by GitHub
parent 81474a3de0
commit 8d63312eca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 37 additions and 24 deletions

View file

@ -10,7 +10,7 @@ use git::{
}, },
status::{FileStatus, GitStatus, StatusCode, TrackedStatus, UnmergedStatus}, status::{FileStatus, GitStatus, StatusCode, TrackedStatus, UnmergedStatus},
}; };
use gpui::{AsyncApp, BackgroundExecutor, SharedString}; use gpui::{AsyncApp, BackgroundExecutor, SharedString, Task};
use ignore::gitignore::GitignoreBuilder; use ignore::gitignore::GitignoreBuilder;
use rope::Rope; use rope::Rope;
use smol::future::FutureExt as _; use smol::future::FutureExt as _;
@ -183,7 +183,7 @@ impl GitRepository for FakeGitRepository {
async move { None }.boxed() async move { None }.boxed()
} }
fn status(&self, path_prefixes: &[RepoPath]) -> BoxFuture<'_, Result<GitStatus>> { fn status(&self, path_prefixes: &[RepoPath]) -> Task<Result<GitStatus>> {
let workdir_path = self.dot_git_path.parent().unwrap(); let workdir_path = self.dot_git_path.parent().unwrap();
// Load gitignores // Load gitignores
@ -311,7 +311,10 @@ impl GitRepository for FakeGitRepository {
entries: entries.into(), entries: entries.into(),
}) })
}); });
async move { result? }.boxed() Task::ready(match result {
Ok(result) => result,
Err(e) => Err(e),
})
} }
fn branches(&self) -> BoxFuture<'_, Result<Vec<Branch>>> { fn branches(&self) -> BoxFuture<'_, Result<Vec<Branch>>> {

View file

@ -6,7 +6,7 @@ use collections::HashMap;
use futures::future::BoxFuture; use futures::future::BoxFuture;
use futures::{AsyncWriteExt, FutureExt as _, select_biased}; use futures::{AsyncWriteExt, FutureExt as _, select_biased};
use git2::BranchType; use git2::BranchType;
use gpui::{AppContext as _, AsyncApp, BackgroundExecutor, SharedString}; use gpui::{AppContext as _, AsyncApp, BackgroundExecutor, SharedString, Task};
use parking_lot::Mutex; use parking_lot::Mutex;
use rope::Rope; use rope::Rope;
use schemars::JsonSchema; use schemars::JsonSchema;
@ -338,7 +338,7 @@ pub trait GitRepository: Send + Sync {
fn merge_message(&self) -> BoxFuture<'_, Option<String>>; fn merge_message(&self) -> BoxFuture<'_, Option<String>>;
fn status(&self, path_prefixes: &[RepoPath]) -> BoxFuture<'_, Result<GitStatus>>; fn status(&self, path_prefixes: &[RepoPath]) -> Task<Result<GitStatus>>;
fn branches(&self) -> BoxFuture<'_, Result<Vec<Branch>>>; fn branches(&self) -> BoxFuture<'_, Result<Vec<Branch>>>;
@ -953,25 +953,27 @@ impl GitRepository for RealGitRepository {
.boxed() .boxed()
} }
fn status(&self, path_prefixes: &[RepoPath]) -> BoxFuture<'_, Result<GitStatus>> { fn status(&self, path_prefixes: &[RepoPath]) -> Task<Result<GitStatus>> {
let git_binary_path = self.git_binary_path.clone(); let git_binary_path = self.git_binary_path.clone();
let working_directory = self.working_directory(); let working_directory = match self.working_directory() {
let path_prefixes = path_prefixes.to_owned(); Ok(working_directory) => working_directory,
self.executor Err(e) => return Task::ready(Err(e)),
.spawn(async move { };
let output = new_std_command(&git_binary_path) let args = git_status_args(&path_prefixes);
.current_dir(working_directory?) log::debug!("Checking for git status in {path_prefixes:?}");
.args(git_status_args(&path_prefixes)) self.executor.spawn(async move {
.output()?; let output = new_std_command(&git_binary_path)
if output.status.success() { .current_dir(working_directory)
let stdout = String::from_utf8_lossy(&output.stdout); .args(args)
stdout.parse() .output()?;
} else { if output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr); let stdout = String::from_utf8_lossy(&output.stdout);
anyhow::bail!("git status failed: {stderr}"); stdout.parse()
} } else {
}) let stderr = String::from_utf8_lossy(&output.stderr);
.boxed() anyhow::bail!("git status failed: {stderr}");
}
})
} }
fn branches(&self) -> BoxFuture<'_, Result<Vec<Branch>>> { fn branches(&self) -> BoxFuture<'_, Result<Vec<Branch>>> {

View file

@ -251,7 +251,15 @@ pub fn main() {
return; return;
} }
log::info!("========== starting zed =========="); log::info!(
"========== starting zed version {}, sha {} ==========",
app_version,
app_commit_sha
.as_ref()
.map(|sha| sha.short())
.as_deref()
.unwrap_or("unknown"),
);
let app = Application::new().with_assets(Assets); let app = Application::new().with_assets(Assets);