(&self, conn: &Connection, repo: &mut GitRepo)
| 13 | } |
| 14 | |
| 15 | fn populate(&self, conn: &Connection, repo: &mut GitRepo) -> Result<()> { |
| 16 | let mut stmt = conn.prepare( |
| 17 | r#" |
| 18 | INSERT INTO stashes ( |
| 19 | stash_index, commit_id, message, author_name, author_email, |
| 20 | created_at, branch, repo |
| 21 | ) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8) |
| 22 | "#, |
| 23 | )?; |
| 24 | |
| 25 | let repo_path = repo.path().to_string(); |
| 26 | |
| 27 | // First, collect all stash info |
| 28 | let mut stashes: Vec<(usize, String, Oid)> = Vec::new(); |
| 29 | { |
| 30 | let git_repo = repo.inner_mut(); |
| 31 | let mut stash_index = 0usize; |
| 32 | git_repo.stash_foreach(|_index, message, oid| { |
| 33 | stashes.push((stash_index, message.to_string(), *oid)); |
| 34 | stash_index += 1; |
| 35 | true |
| 36 | })?; |
| 37 | } |
| 38 | |
| 39 | // Now process each stash with immutable access |
| 40 | let git_repo = repo.inner(); |
| 41 | for (stash_index, msg, oid) in stashes { |
| 42 | if let Ok(commit) = git_repo.find_commit(oid) { |
| 43 | let commit_id = oid.to_string(); |
| 44 | |
| 45 | let author = commit.author(); |
| 46 | let author_name = author.name().unwrap_or("").to_string(); |
| 47 | let author_email = author.email().unwrap_or("").to_string(); |
| 48 | let created_at = format_git_time(author.when()); |
| 49 | |
| 50 | let branch = extract_branch_from_message(&msg); |
| 51 | |
| 52 | stmt.execute(( |
| 53 | stash_index as i64, |
| 54 | &commit_id, |
| 55 | &msg, |
| 56 | &author_name, |
| 57 | &author_email, |
| 58 | &created_at, |
| 59 | &branch, |
| 60 | &repo_path, |
| 61 | ))?; |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | Ok(()) |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | fn extract_branch_from_message(message: &str) -> String { |
nothing calls this directly
no test coverage detected