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

Method find_git_files_recursive

src/git.rs:747–784  ·  view source on GitHub ↗

Recursively search for .git files (submodule indicators) in a directory.

(
        &self,
        base_path: &Path,
        current_path: &Path,
        result: &mut Vec<PathBuf>,
    )

Source from the content-addressed store, hash-verified

745
746 /// Recursively search for .git files (submodule indicators) in a directory.
747 async fn find_git_files_recursive(
748 &self,
749 base_path: &Path,
750 current_path: &Path,
751 result: &mut Vec<PathBuf>,
752 ) {
753 let Ok(mut entries) = tokio::fs::read_dir(current_path).await else {
754 return;
755 };
756
757 while let Ok(Some(entry)) = entries.next_entry().await {
758 let path = entry.path();
759 let file_name = path.file_name().unwrap_or_default();
760
761 // Skip the .git directory itself (the main repo's git directory)
762 if file_name == ".git" {
763 // Check if it's a file (submodule indicator) or directory (main repo)
764 // If it's a file with gitdir: prefix, add it to results
765 if let Ok(meta) = tokio::fs::symlink_metadata(&path).await
766 && meta.is_file()
767 && let Ok(content) = tokio::fs::read_to_string(&path).await
768 && content.starts_with("gitdir:")
769 {
770 result.push(path);
771 }
772 // If it's a directory, skip it (main repo's .git)
773 continue;
774 }
775
776 // Recurse into directories (but not symlinks)
777 if let Ok(meta) = tokio::fs::symlink_metadata(&path).await
778 && meta.is_dir()
779 && !meta.file_type().is_symlink()
780 {
781 Box::pin(self.find_git_files_recursive(base_path, &path, result)).await;
782 }
783 }
784 }
785
786 /// Fix the gitdir path in a submodule .git file if it uses an absolute path.
787 async fn fix_submodule_gitdir_path(

Callers 1

Calls 1

pathMethod · 0.80

Tested by

no test coverage detected