Skip to content
Merged
Show file tree
Hide file tree
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
59 changes: 59 additions & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ uuid = { version = "1", features = ["v4"] }
tauri-plugin-dialog = "2"
git2 = "0.20.3"
fix-path-env = { git = "https://github.com/tauri-apps/fix-path-env-rs" }
ignore = "0.4.25"

[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
tauri-plugin-updater = "2"
55 changes: 23 additions & 32 deletions src-tauri/src/workspaces.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::io::Write;
use std::path::PathBuf;

use ignore::WalkBuilder;
use tauri::{AppHandle, State};
use tokio::process::Command;
use uuid::Uuid;
Expand Down Expand Up @@ -30,44 +31,34 @@ fn sanitize_worktree_name(branch: &str) -> String {
}
}

fn should_skip_dir(name: &str) -> bool {
matches!(
name,
".git" | "node_modules" | "dist" | "target" | "release-artifacts"
)
}

fn list_workspace_files_inner(root: &PathBuf, max_files: usize) -> Vec<String> {
let mut results = Vec::new();
let mut stack = vec![root.clone()];

while let Some(dir) = stack.pop() {
let entries = match std::fs::read_dir(&dir) {
Ok(entries) => entries,
let walker = WalkBuilder::new(root)
// Allow hidden entries.
.hidden(false)
// Follow symlinks to search their contents.
.follow_links(true)
// Don't require git to be present to apply to apply git-related ignore rules.
.require_git(false)
.build();

for entry in walker {
let entry = match entry {
Ok(entry) => entry,
Err(_) => continue,
};
for entry in entries.flatten() {
let path = entry.path();
let file_name = entry.file_name().to_string_lossy().to_string();
if path.is_dir() {
if should_skip_dir(&file_name) {
continue;
}
stack.push(path);
continue;
}
if path.is_file() {
if let Ok(rel_path) = path.strip_prefix(root) {
let normalized = normalize_git_path(&rel_path.to_string_lossy());
if !normalized.is_empty() {
results.push(normalized);
}
}
}
if results.len() >= max_files {
return results;
if !entry.file_type().is_some_and(|ft| ft.is_file()) {
continue;
}
if let Ok(rel_path) = entry.path().strip_prefix(root) {
let normalized = normalize_git_path(&rel_path.to_string_lossy());
if !normalized.is_empty() {
results.push(normalized);
}
}
if results.len() >= max_files {
break;
}
}

results.sort();
Expand Down