MCPcopy Index your code
hub / github.com/AI45Lab/Code / get_status

Function get_status

core/src/git.rs:422–447  ·  view source on GitHub ↗

Get repository status.

(repo_path: &Path)

Source from the content-addressed store, hash-verified

420
421/// Get repository status.
422pub fn get_status(repo_path: &Path) -> Result<RepoStatus> {
423 let (success, stdout, _) = run_git(repo_path, &["rev-parse", "--abbrev-ref", "HEAD"])?;
424 let branch = if success {
425 stdout.trim().to_string()
426 } else {
427 "(detached)".to_string()
428 };
429
430 let (_, commit, _) = run_git(repo_path, &["log", "--oneline", "-1", "--no-decorate"])?;
431 let commit = commit.trim().to_string();
432
433 let (_, git_dir, _) = run_git(repo_path, &["rev-parse", "--git-dir"])?;
434 let is_worktree = git_dir.trim().contains(".git/worktrees");
435
436 let (_, status_output, _) = run_git(repo_path, &["status", "--porcelain", "--short"])?;
437 let dirty_count = status_output.lines().filter(|l| !l.is_empty()).count();
438 let is_dirty = dirty_count > 0;
439
440 Ok(RepoStatus {
441 branch,
442 commit,
443 is_worktree,
444 is_dirty,
445 dirty_count,
446 })
447}
448
449/// Commit information for log display.
450#[derive(Debug, Clone)]

Callers 1

statusMethod · 0.85

Calls 3

run_gitFunction · 0.85
containsMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected