pub fn crev_new_version(filter: ReviewFilterData) -> anyhow::Result<ProofCrevForReview> {
    let new_filter = ReviewFilterData {
        crate_name: filter.crate_name.clone(),
        crate_version: None,
        old_crate_version: None,
    };
    let vec_of_reviews = crev_list_my_reviews(&Some(new_filter))?;
    if vec_of_reviews.is_empty() {
        anyhow::bail!("Crate reviews for {} not found in my reviews!", filter.crate_name.as_str());
    }
    let max_version = crate::cargo_registry_mod::max_version_from_registry_index(filter.crate_name.as_str())?;

    if let Some(version) = filter.crate_version.as_ref() {
        if version == max_version.as_str() {
            anyhow::bail!("Max version {} is already reviewed!", &max_version);
        }
        let path_dir = crate::cargo_registry_mod::cargo_registry_src_dir_for_crate(&filter.crate_name, &max_version)?;
        if !path_dir.exists() {
            anyhow::bail!("Max version {} src is not cached on your system. It means you don't have a dependency on it in your projects. You cannot review a crate version that you don't use.", &max_version);
        }
        for x in vec_of_reviews.iter() {
            if x.package.version.as_str() == version {
                let mut review = x.clone();
                review.package.version = max_version;
                return Ok(review);
            }
        }
    }

    // return last review, or default
    anyhow::bail!("Cannot add new version for {}!", &filter.crate_name);
}
/// list the user-selected crate+version
/// then find the newest version in cargo registry index and change the version field
/// all the rest stays the same
list the user-selected crate+version
then find the newest version in cargo registry index and change the version field
all the rest stays the same
list the user - selected crate + version then find the newest version in cargo registry index and change the version field all the rest stays the same
pub fn crev_new_version(filter: ReviewFilterData) -> anyhow::Result<ProofCrevForReview> {
    let new_filter = ReviewFilterData {
        crate_name: filter.crate_name.clone(),
        crate_version: None,
        old_crate_version: None,
    };
    let vec_of_reviews = crev_list_my_reviews(&Some(new_filter))?;
    if vec_of_reviews.is_empty() {
        anyhow::bail!("Crate reviews for {} not found in my reviews!", filter.crate_name.as_str());
    }
    let max_version = crate::cargo_registry_mod::max_version_from_registry_index(filter.crate_name.as_str())?;
    if let Some(version) = filter.crate_version.as_ref() {
        if version == max_version.as_str() {
            anyhow::bail!("Max version {} is already reviewed!", &max_version);
        }
        let path_dir = crate::cargo_registry_mod::cargo_registry_src_dir_for_crate(&filter.crate_name, &max_version)?;
        if !path_dir.exists() {
            anyhow::bail!("Max version {} src is not cached on your system. It means you don't have a dependency on it in your projects. You cannot review a crate version that you don't use.", &max_version);
        }
        for x in vec_of_reviews.iter() {
            if x.package.version.as_str() == version {
                let mut review = x.clone();
                review.package.version = max_version;
                return Ok(review);
            }
        }
    }
    // return last review, or default
    anyhow::bail!("Cannot add new version for {}!", &filter.crate_name);
}
pub fn crev_new_version ( filter : ReviewFilterData ) -> anyhow :: Result < ProofCrevForReview > { let new_filter = ReviewFilterData { crate_name : filter . crate_name . clone ( ) , crate_version : None , old_crate_version : None , } ; let vec_of_reviews = crev_list_my_reviews ( & Some ( new_filter ) ) ? ; if vec_of_reviews . is_empty ( ) { anyhow :: bail ! ( " " filter crate_name as_str ( ) ) ; } let max_version = crate :: cargo_registry_mod :: max_version_from_registry_index ( filter . crate_name . as_str ( ) ) ? ; if let Some ( version ) = filter . crate_version . as_ref ( ) { if version == max_version . as_str ( ) { anyhow :: bail ! ( " " max_version ) ; } let path_dir = crate :: cargo_registry_mod :: cargo_registry_src_dir_for_crate ( & filter . crate_name , & max_version ) ? ; if ! path_dir . exists ( ) { anyhow :: bail ! ( " " max_version ) ; } for x in vec_of_reviews . iter ( ) { if x . package . version . as_str ( ) == version { let mut review = x . clone ( ) ; review . package . version = max_version ; return Ok ( review ) ; } } } // return last review, or default anyhow :: bail ! ( " " filter crate_name ) ; }
list the user-selected crate+version
then find the newest version in cargo registry index and change the version field
all the rest stays the same
list the user - selected crate + version then find the newest version in cargo registry index and change the version field all the rest stays the same
filter
ReviewFilterData