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

Function fetch_pinned_sources

xtask/src/main.rs:5112–5145  ·  view source on GitHub ↗
(manifest: &SourcesManifest)

Source from the content-addressed store, hash-verified

5110}
5111
5112fn 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
5147fn init_source_checkout(source: &SourcePin, path: &Path) -> Result<()> {
5148 if path.exists() && !path.join(".git").exists() {

Callers 2

assetsFunction · 0.85

Calls 8

source_checkout_pathFunction · 0.85
init_source_checkoutFunction · 0.85
ensure_clean_checkoutFunction · 0.85
ensure_source_remoteFunction · 0.85
run_commandFunction · 0.85
check_source_spineFunction · 0.85
argsMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected