liboxen 0.53.0

Oxen is a fast data version control system, built with machine learning training data in mind. Designed to handle terabytes of data with ease, using a workflow similar to git. Version both structured and unstructured data of any modality: text, images, video, audio, CSV, Parquet, JSONL, model checkpoints, and more. liboxen is the embeddable core library behind the oxen CLI and server, which power fine tuning and inference pipelines for multimodal LLMs, image models, and video models on Oxen.ai.
//! # oxen config
//!
//! Configuration commands for Oxen
//!

use crate::error::OxenError;
use crate::model::{LocalRepository, Remote};

/// # Set the remote for a repository
/// Tells the CLI where to push the changes to
pub fn set_remote(repo: &mut LocalRepository, name: &str, url: &str) -> Result<Remote, OxenError> {
    if url::Url::parse(url).is_err() {
        return Err(OxenError::invalid_set_remote_url(url));
    }

    if repo.is_remote_mode() {
        return Err(OxenError::basic_str(
            "Error: Cannot change remote of remote-mode repos",
        ));
    }

    let remote = repo.set_remote(name, url);
    repo.save()?;
    Ok(remote)
}

/// # Remove the remote for a repository
/// If you added a remote you no longer want, can remove it by supplying the name
pub fn delete_remote(repo: &mut LocalRepository, name: &str) -> Result<(), OxenError> {
    if repo.is_remote_mode() {
        return Err(OxenError::basic_str(
            "Error: Cannot delete from remote of remote-mode repos",
        ));
    }

    repo.delete_remote(name);
    repo.save()?;
    Ok(())
}