1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone)]
pub struct RemoteBranchSpec {
pub remote: String,
pub branch: String,
}
#[derive(Debug, Clone)]
pub struct ForkBranchSpec {
pub owner: String,
pub branch: String,
}
/// Custom error type for worktree not found
#[derive(Debug, thiserror::Error)]
#[error("Worktree not found: {0}")]
pub struct WorktreeNotFound(pub String);
/// Git status information for a worktree
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct GitStatus {
/// Commits ahead of upstream
pub ahead: usize,
/// Commits behind upstream
pub behind: usize,
/// Branch has conflicts when merging with base
pub has_conflict: bool,
/// Has uncommitted changes (staged or unstaged)
pub is_dirty: bool,
/// Lines added in committed changes only (base...HEAD)
pub lines_added: usize,
/// Lines removed in committed changes only (base...HEAD)
pub lines_removed: usize,
/// Lines added in uncommitted changes only (working tree + untracked)
#[serde(default)]
pub uncommitted_added: usize,
/// Lines removed in uncommitted changes only (working tree)
#[serde(default)]
pub uncommitted_removed: usize,
/// Timestamp when this status was cached (UNIX seconds)
#[serde(default)]
pub cached_at: Option<u64>,
/// The base branch used for comparison (e.g., "main")
#[serde(default)]
pub base_branch: String,
/// The branch name for this worktree (None if detached HEAD)
#[serde(default)]
pub branch: Option<String>,
/// Whether the branch has an upstream tracking branch
#[serde(default)]
pub has_upstream: bool,
/// Whether a rebase is currently in progress
#[serde(default)]
pub is_rebasing: bool,
}