MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / print_forecast_recommendations

Method print_forecast_recommendations

atomic-cli/src/commands/git/import.rs:704–797  ·  view source on GitHub ↗

Classify the commits an incremental import would bring in and print a per-shape recommendation (SPEC §4.4). Purely advisory — writes nothing.

(
        &self,
        git_repo: &GitRepository,
        head_oid: git2::Oid,
        imported_shas: &HashSet<String>,
        known_states: &HashSet<atomic_core::types::Merkle>,
        target_view

Source from the content-addressed store, hash-verified

702 /// Classify the commits an incremental import would bring in and print a
703 /// per-shape recommendation (SPEC §4.4). Purely advisory — writes nothing.
704 fn print_forecast_recommendations(
705 &self,
706 git_repo: &GitRepository,
707 head_oid: git2::Oid,
708 imported_shas: &HashSet<String>,
709 known_states: &HashSet<atomic_core::types::Merkle>,
710 target_view: &str,
711 repo: Option<&Repository>,
712 ) -> CliResult<()> {
713 use atomic_core::types::{Base32, Hash};
714
715 let mut revwalk = git_repo.revwalk().map_err(|e| CliError::GitError {
716 message: format!("Failed to create revwalk: {}", e),
717 })?;
718 revwalk.push(head_oid).map_err(|e| CliError::GitError {
719 message: format!("Failed to push HEAD to revwalk: {}", e),
720 })?;
721 if !self.all_branches {
722 revwalk
723 .simplify_first_parent()
724 .map_err(|e| CliError::GitError {
725 message: format!("Failed to simplify revwalk: {}", e),
726 })?;
727 }
728 revwalk
729 .set_sorting(Sort::TOPOLOGICAL | Sort::REVERSE)
730 .map_err(|e| CliError::GitError {
731 message: format!("Failed to set sorting: {}", e),
732 })?;
733
734 let mut insertable = 0usize;
735 let mut missing = 0usize;
736 let mut merges = 0usize;
737 let mut normal = 0usize;
738
739 for oid_result in revwalk {
740 let oid = oid_result.map_err(|e| CliError::GitError {
741 message: format!("Revwalk error: {}", e),
742 })?;
743 let sha = oid.to_string();
744 let commit = git_repo.find_commit(oid).map_err(|e| CliError::GitError {
745 message: format!("Failed to load commit {}: {}", sha, e),
746 })?;
747 let message = commit.message().unwrap_or("");
748 if incremental_import_skips(&sha, message, imported_shas, target_view, known_states) {
749 continue;
750 }
751 let is_merge = commit.parent_count() > 1;
752 let records_present = |h: &str| {
753 repo.map(|r| {
754 Hash::from_base32(h.as_bytes())
755 .map(|hash| r.has_change(&hash))
756 .unwrap_or(false)
757 })
758 .unwrap_or(false)
759 };
760 match forecast_commit_kind(message, is_merge, records_present) {
761 ForecastKind::SquashInsertable { count, pr } => {

Callers 1

run_importMethod · 0.80

Calls 7

incremental_import_skipsFunction · 0.85
forecast_commit_kindFunction · 0.85
print_infoFunction · 0.85
pushMethod · 0.45
messageMethod · 0.45
as_bytesMethod · 0.45
has_changeMethod · 0.45

Tested by

no test coverage detected