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

Function init_source_checkout

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

Source from the content-addressed store, hash-verified

5145}
5146
5147fn 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
5171fn ensure_source_remote(path: &Path, source: &SourcePin) -> Result<()> {
5172 let remotes = command_output("git", &["remote"], path)

Callers 1

fetch_pinned_sourcesFunction · 0.85

Calls 5

run_commandFunction · 0.85
ensure_source_remoteFunction · 0.85
argMethod · 0.80
joinMethod · 0.45
read_dirMethod · 0.45

Tested by

no test coverage detected