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

Method count_commits

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

Count commits for dry-run mode.

(
        &self,
        git_repo: &GitRepository,
        head_oid: git2::Oid,
        imported_shas: &HashSet<String>,
        mainline_only: bool,
    )

Source from the content-addressed store, hash-verified

367
368 /// Count commits for dry-run mode.
369 fn count_commits(
370 &self,
371 git_repo: &GitRepository,
372 head_oid: git2::Oid,
373 imported_shas: &HashSet<String>,
374 mainline_only: bool,
375 ) -> CliResult<usize> {
376 let mut revwalk = git_repo.revwalk().map_err(|e| CliError::GitError {
377 message: format!("Failed to create revwalk: {}", e),
378 })?;
379
380 revwalk.push(head_oid).map_err(|e| CliError::GitError {
381 message: format!("Failed to push HEAD to revwalk: {}", e),
382 })?;
383
384 if mainline_only {
385 revwalk
386 .simplify_first_parent()
387 .map_err(|e| CliError::GitError {
388 message: format!("Failed to simplify revwalk to first-parent history: {}", e),
389 })?;
390 }
391
392 revwalk
393 .set_sorting(Sort::TOPOLOGICAL | Sort::REVERSE)
394 .map_err(|e| CliError::GitError {
395 message: format!("Failed to set sorting: {}", e),
396 })?;
397
398 let mut count = 0;
399 for oid_result in revwalk {
400 let oid = oid_result.map_err(|e| CliError::GitError {
401 message: format!("Revwalk error: {}", e),
402 })?;
403
404 if self.incremental && imported_shas.contains(&oid.to_string()) {
405 continue;
406 }
407
408 count += 1;
409 }
410
411 Ok(count)
412 }
413}
414
415impl Command for Import {

Callers 1

runMethod · 0.80

Calls 2

pushMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected