(manifest: &SourcesManifest)
| 5110 | } |
| 5111 | |
| 5112 | fn fetch_pinned_sources(manifest: &SourcesManifest) -> Result<()> { |
| 5113 | for source in &manifest.sources { |
| 5114 | let Some(path) = source_checkout_path(source.name.as_str()) else { |
| 5115 | eprintln!( |
| 5116 | "warning: source '{}' has no configured checkout path; skipping fetch", |
| 5117 | source.name |
| 5118 | ); |
| 5119 | continue; |
| 5120 | }; |
| 5121 | if !path.exists() || !path.join(".git").exists() { |
| 5122 | init_source_checkout(source, path)?; |
| 5123 | } |
| 5124 | ensure_clean_checkout(source, path)?; |
| 5125 | ensure_source_remote(path, source)?; |
| 5126 | let mut fetch = Command::new("git"); |
| 5127 | fetch |
| 5128 | .args(["fetch", "--depth", "1", "origin", &source.commit]) |
| 5129 | .current_dir(path); |
| 5130 | run_command(&mut fetch).with_context(|| format!("fetch {}", source.name))?; |
| 5131 | let mut checkout = Command::new("git"); |
| 5132 | checkout |
| 5133 | .args(["checkout", "-B", &source.branch, &source.commit]) |
| 5134 | .current_dir(path); |
| 5135 | run_command(&mut checkout).with_context(|| { |
| 5136 | format!( |
| 5137 | "checkout {} at {} in {}", |
| 5138 | source.name, |
| 5139 | source.commit, |
| 5140 | path.display() |
| 5141 | ) |
| 5142 | })?; |
| 5143 | } |
| 5144 | check_source_spine(manifest, true, false) |
| 5145 | } |
| 5146 | |
| 5147 | fn init_source_checkout(source: &SourcePin, path: &Path) -> Result<()> { |
| 5148 | if path.exists() && !path.join(".git").exists() { |
no test coverage detected