mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-26 14:00:51 +00:00
cli: color branch name and conflict marker in jj branches
output
This commit is contained in:
parent
4594932fc0
commit
4878c94052
2 changed files with 11 additions and 3 deletions
|
@ -2114,16 +2114,23 @@ fn cmd_branches(
|
|||
let repo_command = command.repo_helper(ui)?;
|
||||
let repo = repo_command.repo();
|
||||
for (name, branch_target) in repo.view().branches() {
|
||||
ui.stdout_formatter().add_label("branch".to_string())?;
|
||||
write!(ui, "{}", name)?;
|
||||
ui.stdout_formatter().remove_label()?;
|
||||
if let Some(local_target) = &branch_target.local_target {
|
||||
match local_target {
|
||||
RefTarget::Normal(id) => {
|
||||
write!(ui, "{}: ", name)?;
|
||||
write!(ui, ": ")?;
|
||||
let commit = repo.store().get_commit(id)?;
|
||||
ui.write_commit_summary(repo.as_repo_ref(), &commit)?;
|
||||
writeln!(ui)?;
|
||||
}
|
||||
RefTarget::Conflict { adds, removes } => {
|
||||
writeln!(ui, "{} (conflicted):", name)?;
|
||||
write!(ui, " ")?;
|
||||
ui.stdout_formatter().add_label("conflict".to_string())?;
|
||||
write!(ui, "(conflicted)")?;
|
||||
ui.stdout_formatter().remove_label()?;
|
||||
writeln!(ui, ":")?;
|
||||
for id in removes {
|
||||
let commit = repo.store().get_commit(id)?;
|
||||
write!(ui, " - ")?;
|
||||
|
@ -2139,7 +2146,7 @@ fn cmd_branches(
|
|||
}
|
||||
}
|
||||
} else {
|
||||
writeln!(ui, "{} (deleted)", name)?;
|
||||
writeln!(ui, " (deleted)")?;
|
||||
}
|
||||
|
||||
// TODO: Display information about remote branches, but probably only
|
||||
|
|
|
@ -88,6 +88,7 @@ fn config_colors(user_settings: &UserSettings) -> HashMap<String, String> {
|
|||
result.insert(String::from("author timestamp"), String::from("cyan"));
|
||||
result.insert(String::from("committer"), String::from("yellow"));
|
||||
result.insert(String::from("committer timestamp"), String::from("cyan"));
|
||||
result.insert(String::from("branch"), String::from("magenta"));
|
||||
result.insert(String::from("branches"), String::from("magenta"));
|
||||
result.insert(String::from("tags"), String::from("magenta"));
|
||||
result.insert(String::from("git_refs"), String::from("magenta"));
|
||||
|
|
Loading…
Reference in a new issue