liboxen 0.50.6

Oxen is a fast, unstructured data version control, to help version large machine learning datasets written in Rust.
use crate::config::RepositoryConfig;
use crate::constants;
use crate::error::OxenError;
use crate::model::LocalRepository;
use crate::util;
use std::path::Path;

pub mod commit;
pub mod data_frames;
pub mod diff;
pub mod files;
pub mod status;

pub fn init_workspace_repo(
    repo: &LocalRepository,
    workspace_dir: impl AsRef<Path>,
) -> Result<LocalRepository, OxenError> {
    let workspace_dir = workspace_dir.as_ref();
    let oxen_hidden_dir = repo.path.join(constants::OXEN_HIDDEN_DIR);
    let workspace_hidden_dir = workspace_dir.join(constants::OXEN_HIDDEN_DIR);
    log::debug!("init_workspace_repo {workspace_hidden_dir:?}");
    util::fs::create_dir_all(&workspace_hidden_dir)?;

    // Copy the config file
    let config_file = oxen_hidden_dir.join(constants::REPO_CONFIG_FILENAME);
    let target_config_file = workspace_hidden_dir.join(constants::REPO_CONFIG_FILENAME);
    util::fs::copy(config_file, &target_config_file)?;

    // Workspace inherits the parent repo's full config — min_version, vfs, and storage — plus its
    // server S3 opts so a workspace built from a VFS/S3 repo lands on the same backends.
    let config = RepositoryConfig::from_file(&target_config_file)?;
    LocalRepository::new_with_server_opts(workspace_dir, config, repo.server_s3_opts())
}