Skip to content

Consolidate 5 direct git2 usages outside git/ module #593

@Wirasm

Description

@Wirasm

Problem

Five locations in kild-core use `git2` directly instead of going through the `git/` module's public API:

Location Direct git2 call What it needs
`forge/registry.rs:51` `Repository::open` → reads remote URL A `get_remote_url(path)` function
`sessions/destroy.rs:378` `Repository::open` → `repo.remotes()` A `has_remote_configured(path)` function
`sessions/info.rs:170` `Repository::open` → `repo.statuses()` Already exists: `get_worktree_status()`
`projects/types.rs:128` `Repository::discover` → presence check A `is_git_repo(path)` function
`cleanup/handler.rs` + `operations.rs` `Repository::discover`, branch iteration Functions for repo discovery and branch listing

These should be consolidated into the `git/` module's public API so that `git2` is only imported within `git/`.

Fix

  1. Add missing public functions to `git/` module:
    • `has_remote_configured(path: &Path) -> bool` — absorbs `destroy.rs:378`
    • `get_remote_url(path: &Path) -> Option` — absorbs `forge/registry.rs:51`
    • `is_git_repo(path: &Path) -> Result` — absorbs `projects/types.rs:128`
    • `discover_repo_and_branches(path: &Path) -> ...` — absorbs `cleanup/` calls
  2. Replace the 5 direct `git2::` usages with calls to these new functions
  3. Remove `git2` from the import lists of `forge/registry.rs`, `sessions/destroy.rs`, `sessions/info.rs`, `projects/types.rs`, `cleanup/handler.rs`, `cleanup/operations.rs`

After this, `git2` is only imported within `git/` files — a prerequisite for clean `kild-git` crate extraction.

References

Metadata

Metadata

Assignees

Labels

P2Medium priority - Backlog, when time permitsarchitectureArchitectural changes and designchoreMaintenance (refactoring, CI, dependencies)core.gitGit worktree operationseffort/mediumFew files, one domain or module, some coordination needed

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions