Fix submodule paths after copying .git/modules to the destination. This finds all .git files (submodule indicators) and fixes their gitdir paths, then fixes worktree paths in .git/modules/*/config files. Returns any non-fatal warnings encountered during the fix.
(&self, repo_path: &Path)
| 706 | /// then fixes worktree paths in .git/modules/*/config files. |
| 707 | /// Returns any non-fatal warnings encountered during the fix. |
| 708 | async fn fix_submodule_paths(&self, repo_path: &Path) -> Vec<String> { |
| 709 | let mut warnings = Vec::new(); |
| 710 | |
| 711 | // Find all .git files that indicate submodules |
| 712 | let git_files = self.find_submodule_git_files(repo_path).await; |
| 713 | |
| 714 | for git_file in git_files { |
| 715 | if let Err(e) = self.fix_submodule_gitdir_path(&git_file, repo_path).await { |
| 716 | warnings.push(format!( |
| 717 | "Failed to fix gitdir path in {}: {}. Removing broken .git file.", |
| 718 | git_file.display(), |
| 719 | e |
| 720 | )); |
| 721 | // Remove the broken .git file so the submodule is treated as regular files |
| 722 | let _ = tokio::fs::remove_file(&git_file).await; |
| 723 | } |
| 724 | } |
| 725 | |
| 726 | // Fix worktree paths in .git/modules/*/config files |
| 727 | match self.fix_module_worktree_paths(repo_path).await { |
| 728 | Ok(w) => warnings.extend(w), |
| 729 | Err(e) => { |
| 730 | warnings.push(format!("Failed to fix module worktree paths: {e}")); |
| 731 | } |
| 732 | } |
| 733 | |
| 734 | warnings |
| 735 | } |
| 736 | |
| 737 | /// Find all .git files (not directories) in the repository that contain gitdir:. |
| 738 | /// These files indicate submodule directories. |
no test coverage detected