MCPcopy Create free account
hub / github.com/AmrDeveloper/GQL / select_diffs_changes

Function select_diffs_changes

src/gitql/gitql_data_provider.rs:425–524  ·  view source on GitHub ↗
(
    repo: &gix::Repository,
    selected_columns: &[String],
)

Source from the content-addressed store, hash-verified

423}
424
425fn select_diffs_changes(
426 repo: &gix::Repository,
427 selected_columns: &[String],
428) -> Result<Vec<Row>, String> {
429 let repo = {
430 let mut repo = repo.clone();
431 repo.object_cache_size_if_unset(4 * 1024 * 1024);
432 repo
433 };
434
435 let mut rewrite_cache = repo
436 .diff_resource_cache(Mode::ToGit, Default::default())
437 .unwrap();
438
439 let mut diff_cache = rewrite_cache.clone();
440
441 let repo_path = repo.path().to_str().unwrap();
442 let walker = repo.head_id().unwrap().ancestors().all().unwrap();
443 let commits_info = walker.filter_map(Result::ok);
444
445 let mut rows: Vec<Row> = vec![];
446 let selected_columns_len = selected_columns.len();
447 for commit_info in commits_info.into_iter() {
448 let commit = commit_info.id().object().unwrap().into_commit();
449 let commit_ref = commit.decode().unwrap();
450
451 if let Some(parent) = commit_info
452 .parent_ids()
453 .next()
454 .map(|id| id.object().unwrap().into_commit().tree().unwrap())
455 {
456 let current = commit.tree().unwrap();
457 rewrite_cache.clear_resource_cache_keep_allocation();
458 diff_cache.clear_resource_cache_keep_allocation();
459
460 if let Ok(mut changes) = current.changes() {
461 let _ = changes.for_each_to_obtain_tree_with_cache(
462 &parent,
463 &mut rewrite_cache,
464 |change| {
465 let diff_change = DiffChange::new_without_content(&change, &mut diff_cache);
466
467 let mut values: Vec<Box<dyn Value>> =
468 Vec::with_capacity(selected_columns_len);
469 for column_name in selected_columns {
470 if column_name == "commit_id" {
471 values.push(Box::new(TextValue::new(commit_info.id.to_string())));
472 continue;
473 }
474
475 if column_name == "insertions" {
476 values.push(Box::new(IntValue::new(diff_change.insertions as i64)));
477 continue;
478 }
479
480 if column_name == "removals" {
481 values.push(Box::new(IntValue::new(diff_change.removals as i64)));
482 continue;

Callers 1

select_gql_objectsFunction · 0.85

Calls 2

modeMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…