MCPcopy Create free account
hub / github.com/douglance/devsql / populate

Method populate

crates/vcsql/src/providers/status.rs:14–76  ·  view source on GitHub ↗
(&self, conn: &Connection, repo: &mut GitRepo)

Source from the content-addressed store, hash-verified

12 }
13
14 fn populate(&self, conn: &Connection, repo: &mut GitRepo) -> Result<()> {
15 let mut stmt = conn.prepare(
16 r#"
17 INSERT INTO status (
18 path, status_code, head_status, index_status,
19 is_staged, is_modified, is_new, is_deleted,
20 is_renamed, is_copied, is_ignored, is_conflicted, repo
21 ) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13)
22 "#,
23 )?;
24
25 let repo_path = repo.path().to_string();
26 let git_repo = repo.inner();
27
28 let mut opts = StatusOptions::new();
29 opts.include_untracked(true)
30 .include_ignored(false)
31 .include_unmodified(false)
32 .recurse_untracked_dirs(true);
33
34 if let Ok(statuses) = git_repo.statuses(Some(&mut opts)) {
35 for entry in statuses.iter() {
36 let path = entry.path().unwrap_or("").to_string();
37 let status = entry.status();
38
39 let (status_code, head_status, index_status) = format_status(status);
40
41 let is_staged = status.intersects(
42 Status::INDEX_NEW
43 | Status::INDEX_MODIFIED
44 | Status::INDEX_DELETED
45 | Status::INDEX_RENAMED
46 | Status::INDEX_TYPECHANGE,
47 );
48
49 let is_modified = status.intersects(Status::WT_MODIFIED | Status::INDEX_MODIFIED);
50 let is_new = status.intersects(Status::WT_NEW | Status::INDEX_NEW);
51 let is_deleted = status.intersects(Status::WT_DELETED | Status::INDEX_DELETED);
52 let is_renamed = status.intersects(Status::WT_RENAMED | Status::INDEX_RENAMED);
53 let is_copied = status.intersects(Status::INDEX_TYPECHANGE | Status::WT_TYPECHANGE);
54 let is_ignored = status.intersects(Status::IGNORED);
55 let is_conflicted = status.intersects(Status::CONFLICTED);
56
57 stmt.execute((
58 &path,
59 &status_code,
60 &head_status,
61 &index_status,
62 if is_staged { 1 } else { 0 },
63 if is_modified { 1 } else { 0 },
64 if is_new { 1 } else { 0 },
65 if is_deleted { 1 } else { 0 },
66 if is_renamed { 1 } else { 0 },
67 if is_copied { 1 } else { 0 },
68 if is_ignored { 1 } else { 0 },
69 if is_conflicted { 1 } else { 0 },
70 &repo_path,
71 ))?;

Callers

nothing calls this directly

Calls 4

format_statusFunction · 0.85
pathMethod · 0.80
innerMethod · 0.80
executeMethod · 0.45

Tested by

no test coverage detected