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

Function init_submodules

src/git_operations.rs:523–544  ·  view source on GitHub ↗

Initializes and checks out all submodules recursively in a repository. Runs `git submodule update --init --recursive` with local file protocol enabled, which is needed because cloned repos have local file:// URLs for submodules.

(repo_path: &Path)

Source from the content-addressed store, hash-verified

521/// Runs `git submodule update --init --recursive` with local file protocol enabled,
522/// which is needed because cloned repos have local file:// URLs for submodules.
523pub async fn init_submodules(repo_path: &Path) -> Result<(), String> {
524 let output = tokio::process::Command::new("git")
525 .args([
526 "-c",
527 "protocol.file.allow=always",
528 "submodule",
529 "update",
530 "--init",
531 "--recursive",
532 ])
533 .current_dir(repo_path)
534 .output()
535 .await
536 .map_err(|e| format!("Failed to run git submodule update: {e}"))?;
537
538 if output.status.success() {
539 Ok(())
540 } else {
541 let stderr = String::from_utf8_lossy(&output.stderr);
542 Err(format!("git submodule update failed: {stderr}"))
543 }
544}
545
546/// Resolves a local branch name to its commit SHA.
547///

Callers 1

copy_repoMethod · 0.85

Calls 1

successMethod · 0.80

Tested by

no test coverage detected