Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/cli/src/cmd/branch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ impl BranchCmd {
) -> Result<(), OxenError> {
let (scheme, host) = get_scheme_and_host_from_repo(repo)?;

check_remote_version_blocking(scheme.clone(), host.clone()).await?;
check_remote_version(scheme, host).await?;
check_remote_version_blocking(&scheme, &host).await?;
check_remote_version(&scheme, &host).await?;

let remote = repo
.get_remote(remote_name)
Expand All @@ -219,7 +219,7 @@ impl BranchCmd {
) -> Result<(), OxenError> {
let (scheme, host) = get_scheme_and_host_from_repo(repo)?;

check_remote_version(scheme, host).await?;
check_remote_version(&scheme, &host).await?;

api::client::branches::delete_remote(repo, remote_name, branch_name).await?;
Ok(())
Expand Down
5 changes: 3 additions & 2 deletions crates/cli/src/cmd/checkout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use clap::{Arg, Command};
use liboxen::error::OxenError;
use liboxen::model::LocalRepository;
use liboxen::repositories;
use std::path::Path;

use crate::cmd::RunCmd;
pub const NAME: &str = "checkout";
Expand Down Expand Up @@ -96,12 +97,12 @@ impl CheckoutCmd {
repo: &LocalRepository,
path: &str,
) -> Result<(), OxenError> {
repositories::checkout::checkout_theirs(repo, path).await?;
repositories::checkout::checkout_theirs(repo, Path::new(path)).await?;
Ok(())
}

pub async fn checkout_ours(&self, repo: &LocalRepository, path: &str) -> Result<(), OxenError> {
repositories::checkout::checkout_ours(repo, path).await?;
repositories::checkout::checkout_ours(repo, Path::new(path)).await?;
Ok(())
}

Expand Down
6 changes: 3 additions & 3 deletions crates/cli/src/cmd/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl RunCmd for CloneCmd {
StorageOpts::default()
}
unsupported_backend => {
return Err(OxenError::basic_str(format!(
return Err(OxenError::basic_str(&format!(
"Unsupported async storage type: {unsupported_backend}"
)));
}
Expand All @@ -171,8 +171,8 @@ impl RunCmd for CloneCmd {
let (scheme, host) = api::client::get_scheme_and_host_from_url(&opts.url)?;

// TODO: Do I need to worry about this for remote repo?
check_remote_version_blocking(scheme.clone(), host.clone()).await?;
check_remote_version(scheme, host).await?;
check_remote_version_blocking(&scheme, &host).await?;
check_remote_version(&scheme, &host).await?;

repositories::clone(&opts).await?;

Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/cmd/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ fn get_message_from_editor(maybe_config: Option<&UserConfig>) -> Result<String,
.status()?;

if !status.success() {
return Err(OxenError::basic_str(format!(
return Err(OxenError::basic_str(&format!(
"Editor '{editor}' exited with non-zero status."
)));
}
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/cmd/db/count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl RunCmd for DbCountCmd {
return Err(OxenError::basic_str("Must supply path"));
};

let count = command::db::count(PathBuf::from(path))?;
let count = command::db::count(&PathBuf::from(path))?;

println!("There are {count} entries in the database");

Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/cmd/db/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl RunCmd for DbGetCmd {
};

let dtype = args.get_one::<String>("dtype").map(|x| x.as_str());
let value = command::db::get(path, key, dtype)?;
let value = command::db::get(std::path::Path::new(path), key, dtype)?;
println!("{value}");

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/cmd/db/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl RunCmd for DbListCmd {
.get_one::<String>("limit")
.map(|x| x.parse::<usize>().expect("limit must be valid size"));

command::db::list(PathBuf::from(path), limit)?;
command::db::list(&PathBuf::from(path), limit)?;

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/cmd/delete_remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl RunCmd for DeleteRemoteCmd {
return Ok(());
}
Err(e) => {
return Err(OxenError::basic_str(format!(
return Err(OxenError::basic_str(&format!(
"Error confirming deletion: {e}"
)));
}
Expand Down
8 changes: 4 additions & 4 deletions crates/cli/src/cmd/df.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::path::PathBuf;
use std::path::{Path, PathBuf};

use async_trait::async_trait;
use clap::{Arg, ArgMatches, Command, arg};
Expand Down Expand Up @@ -255,13 +255,13 @@ impl RunCmd for DFCmd {

if let Some(revision) = args.get_one::<String>("revision") {
let repo = LocalRepository::from_current_dir()?;
command::df::df_revision(&repo, path, revision, opts).await?;
command::df::df_revision(&repo, Path::new(path), revision, opts).await?;
} else if args.get_flag("schema") || args.get_flag("schema-flat") {
let flatten = args.get_flag("schema-flat");
let result = command::df::schema(path, flatten, opts)?;
let result = command::df::schema(Path::new(path), flatten, opts)?;
println!("{result}");
} else {
command::df(path, opts).await?;
command::df(Path::new(path), opts).await?;
}

Ok(())
Expand Down
6 changes: 3 additions & 3 deletions crates/cli/src/cmd/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ pub struct DiffCmd;

fn write_to_pager(output: &mut Pager, text: &str) -> Result<(), OxenError> {
write!(output, "{text}")
.map_err(|e| OxenError::basic_str(format!("Could not write to pager: {e}")))
.map_err(|e| OxenError::basic_str(&format!("Could not write to pager: {e}")))
}

fn writeln_to_pager(output: &mut Pager, text: &str) -> Result<(), OxenError> {
writeln!(output, "{text}")
.map_err(|e| OxenError::basic_str(format!("Could not write to pager: {e}")))
.map_err(|e| OxenError::basic_str(&format!("Could not write to pager: {e}")))
}

#[async_trait]
Expand Down Expand Up @@ -339,7 +339,7 @@ impl DiffCmd {
match result {
DiffResult::Tabular(result) => {
let mut df = result.contents.clone();
tabular::write_df(&mut df, file_path.clone())?;
tabular::write_df(&mut df, &file_path.clone())?;
}
DiffResult::Text(_) => {
println!("Saving to disk not supported for text output");
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/cmd/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl RunCmd for DownloadCmd {
.map(String::from)
.unwrap_or(DEFAULT_SCHEME.to_string());

check_remote_version_blocking(scheme.clone(), host.clone()).await?;
check_remote_version_blocking(&scheme, &host).await?;

// Check if the first path is a valid remote repo
let remote_repo =
Expand Down
11 changes: 7 additions & 4 deletions crates/cli/src/cmd/embeddings/index.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use async_trait::async_trait;
use clap::{Arg, Command, arg};
use std::path::Path;

use liboxen::error::OxenError;
use liboxen::model::LocalRepository;
Expand Down Expand Up @@ -56,18 +57,20 @@ impl RunCmd for EmbeddingsIndexCmd {
let commit = repositories::commits::head_commit(&repository)?;
if !repositories::workspaces::data_frames::is_queryable_data_frame_indexed(
&repository,
path,
Path::new(path),
&commit,
)? {
// If not, proceed to create a new workspace and index the data frame.
// create the workspace id from the file path + commit id
let workspace_id = format!("{}-{}", path, commit.id);
let workspace =
repositories::workspaces::create(&repository, &commit, workspace_id, false)?;
repositories::workspaces::data_frames::index(&repository, &workspace, path).await?;
repositories::workspaces::create(&repository, &commit, &workspace_id, false)?;
repositories::workspaces::data_frames::index(&repository, &workspace, Path::new(path))
.await?;

repositories::workspaces::data_frames::embeddings::index(
&workspace,
path,
Path::new(path),
column,
use_background_thread,
)
Expand Down
4 changes: 2 additions & 2 deletions crates/cli/src/cmd/embeddings/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl RunCmd for EmbeddingsQueryCmd {
let commit = repositories::commits::head_commit(&repository)?;
let workspace_id = format!("{}-{}", path, commit.id);
let Some(workspace) = repositories::workspaces::get(&repository, &workspace_id)? else {
return Err(OxenError::basic_str(format!(
return Err(OxenError::basic_str(&format!(
"Workspace not found: {workspace_id}"
)));
};
Expand All @@ -126,7 +126,7 @@ impl RunCmd for EmbeddingsQueryCmd {
};

println!("Writing to {output}");
tabular::write_df(&mut df, output)?;
tabular::write_df(&mut df, std::path::Path::new(output))?;

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/cmd/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl RunCmd for FetchCmd {
let (scheme, host) = get_scheme_and_host_from_repo(&repository)?;

check_repo_migration_needed(&repository)?;
check_remote_version_blocking(scheme.clone(), host.clone()).await?;
check_remote_version_blocking(&scheme, &host).await?;
let mut fetch_opts = FetchOpts::new();
let subtrees = repository.subtree_paths();
fetch_opts.subtree_paths = subtrees;
Expand Down
4 changes: 2 additions & 2 deletions crates/cli/src/cmd/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ impl RunCmd for InitCmd {
// Make sure the remote version is compatible
let (scheme, host) = get_scheme_and_host_or_default()?;

check_remote_version(scheme, host).await?;
check_remote_version(&scheme, &host).await?;

// Initialize the repository
let directory = util::fs::canonicalize(PathBuf::from(&path))?;
let directory = util::fs::canonicalize(&PathBuf::from(&path))?;
repositories::init::init_with_version_and_storage_opts(
&directory,
oxen_version,
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/cmd/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct LogCmd;

fn write_to_pager(output: &mut Pager, text: &str) -> Result<(), OxenError> {
writeln!(output, "{text}")
.map_err(|e| OxenError::basic_str(format!("Could not write to pager: {e}")))
.map_err(|e| OxenError::basic_str(&format!("Could not write to pager: {e}")))
}

#[async_trait]
Expand Down
4 changes: 2 additions & 2 deletions crates/cli/src/cmd/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl RunCmd for LsCmd {
repositories::commits::head_commit(&repo)?
} else {
let Some(commit) = repositories::commits::get_by_id(&repo, commit_id)? else {
return Err(OxenError::basic_str(format!(
return Err(OxenError::basic_str(&format!(
"Commit {commit_id} not found"
)));
};
Expand All @@ -78,7 +78,7 @@ impl RunCmd for LsCmd {
let remote_status = api::client::workspaces::changes::list(
&remote_repo,
workspace_identifier,
directory.clone(),
&directory.clone(),
page_num,
page_size,
)
Expand Down
4 changes: 2 additions & 2 deletions crates/cli/src/cmd/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl RunCmd for MigrateCmd {
{
let migration = migrations
.get(migration)
.ok_or(OxenError::basic_str(format!(
.ok_or(OxenError::basic_str(&format!(
"Unknown migration: {migration}"
)))?;
let path_str = sub_matches.get_one::<String>("PATH").expect("required");
Expand All @@ -82,7 +82,7 @@ impl RunCmd for MigrateCmd {
} else if direction == "down" {
migration.down(path, all)?;
} else {
return Err(OxenError::basic_str(format!(
return Err(OxenError::basic_str(&format!(
"Unknown direction: {direction}"
)));
}
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/cmd/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl RunCmd for NodeCmd {
} else if let Some(node_hash) = args.get_one::<String>("node") {
let node_hash = node_hash.parse()?;
let Some(node) = repositories::tree::get_node_by_id(&repository, &node_hash)? else {
return Err(OxenError::resource_not_found(format!(
return Err(OxenError::resource_not_found(&format!(
"Node {node_hash} not found in repo"
)));
};
Expand Down
4 changes: 2 additions & 2 deletions crates/cli/src/cmd/pull.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ impl RunCmd for PullCmd {
let (scheme, host) = get_scheme_and_host_from_repo(&repo)?;

check_repo_migration_needed(&repo)?;
check_remote_version_blocking(scheme.clone(), host.clone()).await?;
check_remote_version(scheme, host).await?;
check_remote_version_blocking(&scheme, &host).await?;
check_remote_version(&scheme, &host).await?;

let mut fetch_opts = FetchOpts::new();
fetch_opts.remote = remote.to_owned();
Expand Down
6 changes: 3 additions & 3 deletions crates/cli/src/cmd/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl RunCmd for PushCmd {
if opts.delete {
let (scheme, host) = get_scheme_and_host_from_repo(&repo)?;

check_remote_version(scheme, host).await?;
check_remote_version(&scheme, &host).await?;

api::client::branches::delete_remote(&repo, &opts.remote, &opts.branch).await?;
println!("Deleted remote branch: {}/{}", opts.remote, opts.branch);
Expand All @@ -111,8 +111,8 @@ impl RunCmd for PushCmd {
let (scheme, host) = get_scheme_and_host_from_repo(&repo)?;

check_repo_migration_needed(&repo)?;
check_remote_version_blocking(scheme.clone(), host.clone()).await?;
check_remote_version(scheme, host).await?;
check_remote_version_blocking(&scheme, &host).await?;
check_remote_version(&scheme, &host).await?;

repositories::push::push_remote_branch(&repo, &opts).await?;
Ok(())
Expand Down
4 changes: 2 additions & 2 deletions crates/cli/src/cmd/remote_mode/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ impl RunCmd for RemoteModeStatusCmd {

let (scheme, host) = get_scheme_and_host_from_repo(&repository)?;

check_remote_version_blocking(scheme.clone(), host.clone()).await?;
check_remote_version(scheme, host).await?;
check_remote_version_blocking(&scheme, &host).await?;
check_remote_version(&scheme, &host).await?;

// TODO: Implement path-based workspace status
let directory = PathBuf::from(".");
Expand Down
8 changes: 6 additions & 2 deletions crates/cli/src/cmd/schemas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,12 @@ impl RunCmd for SchemasCmd {
let repository = LocalRepository::from_current_dir()?;
let staged = args.get_flag("staged");
let verbose = !args.get_flag("flatten"); // default to verbose
let val =
repositories::data_frames::schemas::show(&repository, schema_ref, staged, verbose)?;
let val = repositories::data_frames::schemas::show(
&repository,
std::path::Path::new(schema_ref),
staged,
verbose,
)?;
println!("{val}");
} else {
// Fall back to list schemas
Expand Down
Loading
Loading