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

Method print_forecast_recommendations

atomic-cli/src/commands/git/import.rs:697–790  ·  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

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