Only supports native file systems for now, will need to explore porting to using the VS Code API in order to properly support URIs.
SLTXBK5GTNH3PUZNA5VG7IDICV3NZPWSCTJSE4YPOQEDMWO67PIQC // TODO: multiple repositories per workspacelet repository_path = workspace_path.clone();
let (dot_directory_sender, mut dot_directory_receiver) = tokio::sync::mpsc::unbounded_channel();// TODO: better separate sync vs non-sync codestd::thread::spawn(move || {let walker = ignore::WalkBuilder::new(&ignore_root).current_dir(&ignore_root).build_parallel();
let repository_uri = match threadsafe_functions.uri_file(repository_path.to_string()).await{Ok(repository_uri) => repository_uri,Err(error) => {tracing::error!(message = "Failed to parse URI", ?repository_path, ?error);return;}};
Box::new(move |entry_result| {// TODO: handle errorsif let Ok(entry) = entry_result&& let Some(file_type) = entry.file_type()&& file_type.is_dir(){// Path: {ENTRY}/.pijul/let dot_directory_path = entry.path().join(libpijul::DOT_DIR);if dot_directory_path.is_dir() {path_sender.send(entry.into_path()).unwrap();// Don't traverse repositoriesreturn ignore::WalkState::Skip;}}ignore::WalkState::Continue})});});// TODO: debug assertion that no discovered repositories are nestedwhile let Some(os_repository_path) = dot_directory_receiver.recv().await {let repository_path = match Utf8PathBuf::from_path_buf(os_repository_path.to_path_buf()) {Ok(repository_path) => repository_path,Err(utf8_path_error) => {tracing::error!(message = "Failed to convert OS path to UTF-8 path",?os_repository_path,?utf8_path_error);continue;}};let std::collections::hash_map::Entry::Vacant(repository_entry) =repositories.entry(repository_path.clone())else {tracing::warn!(message = "Ignoring existing repository");continue;};let repository_uri = match threadsafe_functions.uri_file(repository_path.to_string()).await{Ok(repository_uri) => repository_uri,Err(error) => {tracing::error!(message = "Failed to parse URI", ?repository_path, ?error);continue;}};
let (source_control, unrecorded_changes, untracked_paths) = match threadsafe_functions.initialize_source_control(repository_uri,String::from("Pijul"),String::from("Changes"),String::from("Untracked"),).await{Ok(initialized_source_control) => initialized_source_control,Err(error) => {tracing::error!(message = "Unable to create source control", ?error);return;}};
let (source_control, unrecorded_changes, untracked_paths) = match threadsafe_functions.initialize_source_control(repository_uri,String::from("Pijul"),String::from("Changes"),String::from("Untracked"),).await{Ok(initialized_source_control) => initialized_source_control,Err(error) => {tracing::error!(message = "Unable to create source control", ?error);continue;}};
let file_system_repository = match pijul_extension::FileSystemRepository::new(&repository_path){Ok(repository) => repository,Err(error) => {tracing::error!(message = "Failed to open repository", ?error);return;}};
let file_system_repository =match pijul_extension::FileSystemRepository::new(&repository_path) {Ok(repository) => repository,Err(error) => {tracing::error!(message = "Failed to open repository", ?error);continue;}};
repository_entry.insert(Repository {repository: file_system_repository,source_control,open_editors: HashMap::new(),unrecorded_changes,untracked_paths,});
repository_entry.insert(Repository {repository: file_system_repository,source_control,open_editors: HashMap::new(),unrecorded_changes,untracked_paths,});