MCPcopy Create free account
hub / github.com/dtormoen/tsk-tsk / fix_worktree_recursive

Method fix_worktree_recursive

src/git.rs:853–904  ·  view source on GitHub ↗

Recursively fix worktree paths in module config files. Returns any warnings encountered during the fix.

(
        &self,
        modules_dir: &Path,
        repo_path: &Path,
    )

Source from the content-addressed store, hash-verified

851 /// Recursively fix worktree paths in module config files.
852 /// Returns any warnings encountered during the fix.
853 async fn fix_worktree_recursive(
854 &self,
855 modules_dir: &Path,
856 repo_path: &Path,
857 ) -> Result<Vec<String>, String> {
858 let mut entries = tokio::fs::read_dir(modules_dir)
859 .await
860 .map_err(|e| format!("Failed to read {}: {}", modules_dir.display(), e))?;
861
862 let mut warnings = Vec::new();
863
864 while let Ok(Some(entry)) = entries.next_entry().await {
865 let path = entry.path();
866
867 // Check metadata to see if it's a directory
868 let Ok(meta) = tokio::fs::symlink_metadata(&path).await else {
869 continue;
870 };
871
872 if !meta.is_dir() {
873 continue;
874 }
875
876 let config_path = path.join("config");
877 if config_path.exists() {
878 match self
879 .fix_single_worktree_config(&config_path, repo_path)
880 .await
881 {
882 Ok(w) => warnings.extend(w),
883 Err(e) => {
884 warnings.push(format!(
885 "Failed to fix worktree in {}: {}",
886 config_path.display(),
887 e
888 ));
889 }
890 }
891 }
892
893 // Handle nested modules (sub-submodules)
894 let nested_modules = path.join("modules");
895 if nested_modules.exists() {
896 // Use Box::pin for recursive async call
897 let nested_warnings =
898 Box::pin(self.fix_worktree_recursive(&nested_modules, repo_path)).await?;
899 warnings.extend(nested_warnings);
900 }
901 }
902
903 Ok(warnings)
904 }
905
906 /// Fix a single module config file's worktree path if it uses an absolute path.
907 /// Returns any warnings about absolute paths that could not be automatically fixed.

Callers 1

Calls 2

pathMethod · 0.80

Tested by

no test coverage detected