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

Method load_branches

crates/devsql/src/engine.rs:646–683  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

644 }
645
646 fn load_branches(&mut self) -> Result<()> {
647 self.conn.execute(
648 "CREATE TABLE IF NOT EXISTS branches (
649 name TEXT PRIMARY KEY,
650 target TEXT,
651 is_head INTEGER,
652 is_remote INTEGER
653 )",
654 [],
655 )?;
656
657 if let Ok(repo) = git2::Repository::open(&self.git_repo_path) {
658 if let Ok(branches) = repo.branches(None) {
659 for branch in branches.filter_map(|b| b.ok()) {
660 let (branch, branch_type) = branch;
661 let name = branch.name().ok().flatten().unwrap_or("");
662 let target = branch
663 .get()
664 .target()
665 .map(|t| t.to_string())
666 .unwrap_or_default();
667 let is_head = if branch.is_head() { 1 } else { 0 };
668 let is_remote = if branch_type == git2::BranchType::Remote {
669 1
670 } else {
671 0
672 };
673
674 self.conn.execute(
675 "INSERT OR IGNORE INTO branches VALUES (?1, ?2, ?3, ?4)",
676 params![name, target, is_head, is_remote],
677 )?;
678 }
679 }
680 }
681
682 Ok(())
683 }
684}
685
686/// Normalize dates from various formats to YYYY-MM-DD

Callers 1

load_git_tablesMethod · 0.80

Calls 2

branchesMethod · 0.80
executeMethod · 0.45

Tested by

no test coverage detected