in focus/operations/src/clone.rs [565:618]
fn set_up_sparse_repo(
sparse_repo_path: &Path,
projects_and_targets: Vec<String>,
template: Option<ClonedRepoTemplate>,
sync_mode: SyncMode,
app: Arc<App>,
) -> Result<()> {
{
let repo = Repo::open(sparse_repo_path, app.clone()).context("Failed to open repo")?;
// TODO: Parallelize these tree set up processes.
info!("Setting up the outlining tree");
repo.create_outlining_tree()
.context("Failed to create the outlining tree")?;
info!("Setting up the working tree");
repo.create_working_tree()
.context("Failed to create the working tree")?;
}
// N.B. we must re-open the repo because otherwise it has no trees...
let repo = Repo::open(sparse_repo_path, app.clone()).context("Failed to open repo")?;
// before running rest of setup config worktree view to be filtered
let working_tree = repo.working_tree()?;
working_tree.set_filter_config(true)?;
let head_commit = repo.get_head_commit().context("Resolving head commit")?;
let target_set = compute_and_store_initial_selection(&repo, projects_and_targets, template)?;
debug!(target_set = ?target_set, "Complete target set");
repo.set_bazel_oneshot_resolution(sync_mode == SyncMode::OneShot)?;
let odb = if repo.get_bazel_oneshot_resolution()? {
None
} else {
Some(RocksDBCache::new(repo.underlying()))
};
repo.sync(
head_commit.id(),
&target_set,
false,
app,
odb.as_ref(),
None,
)
.context("Sync failed")?;
repo.working_tree()?.write_sync_point_ref()?;
info!("Writing git config to support instrumentation");
repo.write_git_config_to_support_instrumentation()
.context("Could not write git config to support instrumentation")?;
set_up_bazel_preflight_script(sparse_repo_path)?;
Ok(())
}