Allow clients to run Zed tasks on remote projects (#12199)
Release Notes: - Enabled Zed tasks on remote projects with ssh connection string specified --------- Co-authored-by: Conrad Irwin <conrad@zed.dev>
This commit is contained in:
parent
df35fd0026
commit
055a13a9b6
16 changed files with 1250 additions and 600 deletions
|
@ -1,46 +1,9 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
use project::TaskSourceKind;
|
||||
use task::{ResolvedTask, TaskContext, TaskTemplate};
|
||||
use ui::{ViewContext, WindowContext};
|
||||
use ui::ViewContext;
|
||||
|
||||
use crate::Workspace;
|
||||
|
||||
pub fn task_cwd(workspace: &Workspace, cx: &mut WindowContext) -> anyhow::Result<Option<PathBuf>> {
|
||||
let project = workspace.project().read(cx);
|
||||
let available_worktrees = project
|
||||
.worktrees()
|
||||
.filter(|worktree| {
|
||||
let worktree = worktree.read(cx);
|
||||
worktree.is_visible()
|
||||
&& worktree.is_local()
|
||||
&& worktree.root_entry().map_or(false, |e| e.is_dir())
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let cwd = match available_worktrees.len() {
|
||||
0 => None,
|
||||
1 => Some(available_worktrees[0].read(cx).abs_path()),
|
||||
_ => {
|
||||
let cwd_for_active_entry = project.active_entry().and_then(|entry_id| {
|
||||
available_worktrees.into_iter().find_map(|worktree| {
|
||||
let worktree = worktree.read(cx);
|
||||
if worktree.contains_entry(entry_id) {
|
||||
Some(worktree.abs_path())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
});
|
||||
anyhow::ensure!(
|
||||
cwd_for_active_entry.is_some(),
|
||||
"Cannot determine task cwd for multiple worktrees"
|
||||
);
|
||||
cwd_for_active_entry
|
||||
}
|
||||
};
|
||||
Ok(cwd.map(|path| path.to_path_buf()))
|
||||
}
|
||||
|
||||
pub fn schedule_task(
|
||||
workspace: &Workspace,
|
||||
task_source_kind: TaskSourceKind,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue