(source: &SourcePin, path: &Path)
| 5145 | } |
| 5146 | |
| 5147 | fn init_source_checkout(source: &SourcePin, path: &Path) -> Result<()> { |
| 5148 | if path.exists() && !path.join(".git").exists() { |
| 5149 | if path.read_dir()?.next().is_none() { |
| 5150 | fs::remove_dir_all(path) |
| 5151 | .with_context(|| format!("remove empty source placeholder {}", path.display()))?; |
| 5152 | } else { |
| 5153 | bail!( |
| 5154 | "source checkout path {} exists but is not a git checkout; remove it or move it aside", |
| 5155 | path.display() |
| 5156 | ); |
| 5157 | } |
| 5158 | } |
| 5159 | |
| 5160 | if let Some(parent) = path.parent() { |
| 5161 | fs::create_dir_all(parent).with_context(|| format!("create {}", parent.display()))?; |
| 5162 | } |
| 5163 | |
| 5164 | let mut command = Command::new("git"); |
| 5165 | command.arg("init").arg(path); |
| 5166 | run_command(&mut command) |
| 5167 | .with_context(|| format!("initialize source checkout {}", path.display()))?; |
| 5168 | ensure_source_remote(path, source) |
| 5169 | } |
| 5170 | |
| 5171 | fn ensure_source_remote(path: &Path, source: &SourcePin) -> Result<()> { |
| 5172 | let remotes = command_output("git", &["remote"], path) |
no test coverage detected