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

Method populate

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

Source from the content-addressed store, hash-verified

11 }
12
13 fn populate(&self, conn: &Connection, repo: &mut GitRepo) -> Result<()> {
14 let mut stmt = conn.prepare(
15 r#"
16 INSERT INTO config (
17 level, section, subsection, key, name, value, repo
18 ) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7)
19 "#,
20 )?;
21
22 let repo_path = repo.path().to_string();
23 let git_repo = repo.inner();
24
25 // Get repository config (includes local, global, system)
26 if let Ok(config) = git_repo.config() {
27 if let Ok(mut entries) = config.entries(None) {
28 while let Some(entry) = entries.next() {
29 if let Ok(entry) = entry {
30 if let (Some(name), Some(value)) = (entry.name(), entry.value()) {
31 let level = match entry.level() {
32 git2::ConfigLevel::ProgramData => "programdata",
33 git2::ConfigLevel::System => "system",
34 git2::ConfigLevel::XDG => "xdg",
35 git2::ConfigLevel::Global => "global",
36 git2::ConfigLevel::Local => "local",
37 git2::ConfigLevel::Worktree => "worktree",
38 git2::ConfigLevel::App => "app",
39 git2::ConfigLevel::Highest => "highest",
40 };
41
42 let (section, subsection, key) = parse_config_name(name);
43
44 stmt.execute((
45 level,
46 &section,
47 &subsection,
48 &key,
49 name,
50 value,
51 &repo_path,
52 ))?;
53 }
54 }
55 }
56 }
57 }
58
59 Ok(())
60 }
61}
62
63fn parse_config_name(name: &str) -> (String, Option<String>, String) {

Callers

nothing calls this directly

Calls 4

parse_config_nameFunction · 0.85
pathMethod · 0.80
innerMethod · 0.80
executeMethod · 0.45

Tested by

no test coverage detected