(&self, conn: &Connection, repo: &mut GitRepo)
| 12 | } |
| 13 | |
| 14 | fn populate(&self, conn: &Connection, repo: &mut GitRepo) -> Result<()> { |
| 15 | let mut stmt = conn.prepare( |
| 16 | r#" |
| 17 | INSERT INTO diff_files ( |
| 18 | commit_id, parent_id, old_path, new_path, status, |
| 19 | insertions, deletions, is_binary, similarity, repo |
| 20 | ) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10) |
| 21 | "#, |
| 22 | )?; |
| 23 | |
| 24 | let repo_path = repo.path().to_string(); |
| 25 | let git_repo = repo.inner(); |
| 26 | |
| 27 | let mut diff_opts = DiffOptions::new(); |
| 28 | diff_opts.include_untracked(false); |
| 29 | |
| 30 | for commit_result in repo.walk_commits()? { |
| 31 | let commit = commit_result?; |
| 32 | let commit_id = commit.id().to_string(); |
| 33 | let tree = commit.tree()?; |
| 34 | |
| 35 | if commit.parent_count() == 0 { |
| 36 | // Root commit |
| 37 | let diff = git_repo.diff_tree_to_tree(None, Some(&tree), Some(&mut diff_opts))?; |
| 38 | insert_diff_files(&mut stmt, &diff, &commit_id, None, &repo_path)?; |
| 39 | } else { |
| 40 | for parent in commit.parents() { |
| 41 | let parent_id = parent.id().to_string(); |
| 42 | let parent_tree = parent.tree()?; |
| 43 | |
| 44 | let diff = git_repo.diff_tree_to_tree( |
| 45 | Some(&parent_tree), |
| 46 | Some(&tree), |
| 47 | Some(&mut diff_opts), |
| 48 | )?; |
| 49 | insert_diff_files(&mut stmt, &diff, &commit_id, Some(&parent_id), &repo_path)?; |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | Ok(()) |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | fn insert_diff_files( |
nothing calls this directly
no test coverage detected