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
use crate::fs::fields as f;
use crate::output::cell::TextCell;
use crate::theme::Theme;
impl f::VcsRepoStatus {
pub fn render(&self, theme: &Theme) -> TextCell {
let vcs = &theme.ui.vcs;
match self {
Self::None => TextCell::paint(theme.ui.punctuation, "-".to_string()),
Self::Repo {
backend,
clean,
branch,
} => {
let is_jj = *backend == "jj";
let indicator = if is_jj {
"J"
} else if *backend == "git" {
"G"
} else {
"?"
};
let status = if is_jj {
// jj uses the green "new" colour as a neutral indicator.
vcs.new
} else if *clean {
vcs.new
} else {
vcs.modified
};
if let Some(name) = branch {
TextCell::paint(status, format!("{indicator} {name}"))
} else {
TextCell::paint(status, indicator.to_string())
}
}
}
}
}