MCPcopy Create free account
hub / github.com/f0rr0/oliphaunt / ensure_source_remote

Function ensure_source_remote

xtask/src/main.rs:5171–5188  ·  view source on GitHub ↗
(path: &Path, source: &SourcePin)

Source from the content-addressed store, hash-verified

5169}
5170
5171fn 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
5190fn source_checkout_path(name: &str) -> Option<&'static Path> {
5191 match name {

Callers 2

fetch_pinned_sourcesFunction · 0.85
init_source_checkoutFunction · 0.85

Calls 3

command_outputFunction · 0.85
run_commandFunction · 0.85
argsMethod · 0.80

Tested by

no test coverage detected