Skip to content

Rv crate #190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft

Rv crate #190

wants to merge 16 commits into from

Conversation

wes-a2ai
Copy link
Contributor

For other rv ecosystem tooling, elements of rv need to be made public

@wes-a2ai wes-a2ai requested a review from Keats March 31, 2025 16:35
src/add.rs Outdated
@@ -5,6 +5,7 @@ use toml_edit::{Array, DocumentMut, Formatted, Value};

use crate::{config::ConfigLoadError, Config};

/// Reads in the config to a toml_edit DocumentMut if it is a valid config file
pub fn read_and_verify_config(config_file: impl AsRef<Path>) -> Result<DocumentMut, AddError> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the kind of function that really should not be open public

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function was already pub-ed because its called from main. Should I move it to internal?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This leaks internal stuff (toml editing). You should have add_packages take the path to the config file and call this fn inside add_packages (or in practice you don't even really need that fn)

@@ -139,6 +142,7 @@ impl DiskCache {
self.root.join("urls").join(encoded)
}

/// Get the path to the cloned git repo
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the comment is redundant with the function name, you can #![allow(missing_docs)] rather than repetitive comments

@@ -168,6 +172,7 @@ impl DiskCache {
(path, false)
}

/// Get the paths to a package in the cache
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@@ -54,6 +55,7 @@ pub struct CacheInfo {
}

impl CacheInfo {
/// Create a new cache info object
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not useful either

pub lockfile: Option<Lockfile>,
/// the R command line, containing the path to the selected R version
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's exactly what we don't want in practice

}

pub fn add_packages(config_doc: &mut DocumentMut, packages: Vec<String>) -> Result<(), AddError> {
fn add_pkgs_to_config(config_doc: &mut DocumentMut, packages: Vec<String>) -> Result<(), AddError> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the read_and_verify_config was implemented from this convo #107 (comment).

I abstracted one level so that it keeps a fxn taking it a DocumentMut, but can change it to whatever you feel is best

#107 (comment)

@wes-a2ai wes-a2ai marked this pull request as draft May 14, 2025 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants