(path: &Path, source: &SourcePin)
| 5169 | } |
| 5170 | |
| 5171 | fn ensure_source_remote(path: &Path, source: &SourcePin) -> Result<()> { |
| 5172 | let remotes = command_output("git", &["remote"], path) |
| 5173 | .with_context(|| format!("read git remotes for {}", path.display()))?; |
| 5174 | let mut command = Command::new("git"); |
| 5175 | if remotes.lines().any(|remote| remote == "origin") { |
| 5176 | command.args(["remote", "set-url", "origin", &source.url]); |
| 5177 | } else { |
| 5178 | command.args(["remote", "add", "origin", &source.url]); |
| 5179 | } |
| 5180 | command.current_dir(path); |
| 5181 | run_command(&mut command).with_context(|| { |
| 5182 | format!( |
| 5183 | "configure origin remote for {} at {}", |
| 5184 | source.name, |
| 5185 | path.display() |
| 5186 | ) |
| 5187 | }) |
| 5188 | } |
| 5189 | |
| 5190 | fn source_checkout_path(name: &str) -> Option<&'static Path> { |
| 5191 | match name { |
no test coverage detected