pub fn assign_ids(repo_path: &Path, output_mode: OutputMode) {
    let db = rustsec::Database::open(repo_path).unwrap_or_else(|e| {
        status_err!(
            "couldn't open advisory DB repo from {}: {}",
            repo_path.display(),
            e
        );
        exit(1);
    });

    let advisories = db.iter();

    // Ensure we're parsing some advisories
    if advisories.len() == 0 {
        status_err!("no advisories found!");
        exit(1);
    }

    if output_mode == OutputMode::HumanReadable {
        status_ok!(
            "Loaded",
            "{} security advisories (from {})",
            advisories.len(),
            repo_path.display()
        );
    }

    let mut highest_id = Map::new();

    for advisory in advisories {
        let advisory_clone = advisory.clone();
        let metadata = advisory_clone.metadata;
        let id = metadata.id;
        let year = metadata.date.year();

        if let Kind::RustSec = id.kind() {
            let id_num = id.numerical_part().unwrap();

            if let Some(&number) = highest_id.get(&year) {
                if number < id_num {
                    highest_id.insert(year, id_num);
                }
            } else {
                highest_id.insert(year, id_num);
            }
        }
    }

    let mut collection_strs = vec![];
    let crates_str = Collection::Crates.to_string();
    let rust_str = Collection::Rust.to_string();
    collection_strs.push(crates_str);
    collection_strs.push(rust_str);

    let mut assignments = vec![];
    for collection_str in collection_strs {
        assign_ids_across_directory(
            collection_str,
            repo_path,
            &mut highest_id,
            output_mode,
            &mut assignments,
        );
    }

    if output_mode == OutputMode::GithubAction {
        println!("Assigned {}", assignments.join(", "));
    }
}
/// assign ids to advisories in a particular repo_path
assign ids to advisories in a particular repo_path
assign ids to advisories in a particular repo_path
pub fn assign_ids(repo_path: &Path, output_mode: OutputMode) {
    let db = rustsec::Database::open(repo_path).unwrap_or_else(|e| {
        status_err!(
            "couldn't open advisory DB repo from {}: {}",
            repo_path.display(),
            e
        );
        exit(1);
    });
    let advisories = db.iter();
    // Ensure we're parsing some advisories
    if advisories.len() == 0 {
        status_err!("no advisories found!");
        exit(1);
    }
    if output_mode == OutputMode::HumanReadable {
        status_ok!(
            "Loaded",
            "{} security advisories (from {})",
            advisories.len(),
            repo_path.display()
        );
    }
    let mut highest_id = Map::new();
    for advisory in advisories {
        let advisory_clone = advisory.clone();
        let metadata = advisory_clone.metadata;
        let id = metadata.id;
        let year = metadata.date.year();
        if let Kind::RustSec = id.kind() {
            let id_num = id.numerical_part().unwrap();
            if let Some(&number) = highest_id.get(&year) {
                if number < id_num {
                    highest_id.insert(year, id_num);
                }
            } else {
                highest_id.insert(year, id_num);
            }
        }
    }
    let mut collection_strs = vec![];
    let crates_str = Collection::Crates.to_string();
    let rust_str = Collection::Rust.to_string();
    collection_strs.push(crates_str);
    collection_strs.push(rust_str);
    let mut assignments = vec![];
    for collection_str in collection_strs {
        assign_ids_across_directory(
            collection_str,
            repo_path,
            &mut highest_id,
            output_mode,
            &mut assignments,
        );
    }
    if output_mode == OutputMode::GithubAction {
        println!("Assigned {}", assignments.join(", "));
    }
}
pub fn assign_ids ( repo_path : & Path , output_mode : OutputMode ) { let db = rustsec :: Database :: open ( repo_path ) . unwrap_or_else ( | e | { status_err ! ( " " repo_path display ( ) e ) ; exit ( 1 ) ; } ) ; let advisories = db . iter ( ) ; // Ensure we're parsing some advisories if advisories . len ( ) == 0 { status_err ! ( " " ) ; exit ( 1 ) ; } if output_mode == OutputMode :: HumanReadable { status_ok ! ( " " " " advisories len ( ) repo_path display ( ) ) ; } let mut highest_id = Map :: new ( ) ; for advisory in advisories { let advisory_clone = advisory . clone ( ) ; let metadata = advisory_clone . metadata ; let id = metadata . id ; let year = metadata . date . year ( ) ; if let Kind :: RustSec = id . kind ( ) { let id_num = id . numerical_part ( ) . unwrap ( ) ; if let Some ( & number ) = highest_id . get ( & year ) { if number < id_num { highest_id . insert ( year , id_num ) ; } } else { highest_id . insert ( year , id_num ) ; } } } let mut collection_strs = vec ! [ ] ; let crates_str = Collection :: Crates . to_string ( ) ; let rust_str = Collection :: Rust . to_string ( ) ; collection_strs . push ( crates_str ) ; collection_strs . push ( rust_str ) ; let mut assignments = vec ! [ ] ; for collection_str in collection_strs { assign_ids_across_directory ( collection_str , repo_path , & mut highest_id , output_mode , & mut assignments , ) ; } if output_mode == OutputMode :: GithubAction { println ! ( " " assignments join ( " " ) ) ; } }
assign ids to advisories in a particular repo_path
assign ids to advisories in a particular repo_path
repo_path
&Path
output_mode
OutputMode
repo_path
&Path
output_mode
OutputMode