mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-27 06:27:43 +00:00
cleanup: fix bad formatting of commands.rs
This commit is contained in:
parent
42090c8078
commit
aba0d200e2
1 changed files with 39 additions and 34 deletions
|
@ -2114,39 +2114,40 @@ fn cmd_branches(
|
|||
let repo_command = command.repo_helper(ui)?;
|
||||
let repo = repo_command.repo();
|
||||
|
||||
let print_branch_target = |ui: &mut Ui, target: Option<&RefTarget>| -> Result<(), CommandError> {
|
||||
match target {
|
||||
Some(RefTarget::Normal(id)) => {
|
||||
write!(ui, ": ")?;
|
||||
let commit = repo.store().get_commit(id)?;
|
||||
ui.write_commit_summary(repo.as_repo_ref(), &commit)?;
|
||||
writeln!(ui)?;
|
||||
}
|
||||
Some(RefTarget::Conflict { adds, removes }) => {
|
||||
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 print_branch_target =
|
||||
|ui: &mut Ui, target: Option<&RefTarget>| -> Result<(), CommandError> {
|
||||
match target {
|
||||
Some(RefTarget::Normal(id)) => {
|
||||
write!(ui, ": ")?;
|
||||
let commit = repo.store().get_commit(id)?;
|
||||
write!(ui, " - ")?;
|
||||
ui.write_commit_summary(repo.as_repo_ref(), &commit)?;
|
||||
writeln!(ui)?;
|
||||
}
|
||||
for id in adds {
|
||||
let commit = repo.store().get_commit(id)?;
|
||||
write!(ui, " + ")?;
|
||||
ui.write_commit_summary(repo.as_repo_ref(), &commit)?;
|
||||
writeln!(ui)?;
|
||||
Some(RefTarget::Conflict { adds, removes }) => {
|
||||
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, " - ")?;
|
||||
ui.write_commit_summary(repo.as_repo_ref(), &commit)?;
|
||||
writeln!(ui)?;
|
||||
}
|
||||
for id in adds {
|
||||
let commit = repo.store().get_commit(id)?;
|
||||
write!(ui, " + ")?;
|
||||
ui.write_commit_summary(repo.as_repo_ref(), &commit)?;
|
||||
writeln!(ui)?;
|
||||
}
|
||||
}
|
||||
None => {
|
||||
writeln!(ui, " (deleted)")?;
|
||||
}
|
||||
}
|
||||
None => {
|
||||
writeln!(ui, " (deleted)")?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
};
|
||||
Ok(())
|
||||
};
|
||||
|
||||
for (name, branch_target) in repo.view().branches() {
|
||||
ui.stdout_formatter().add_label("branch".to_string())?;
|
||||
|
@ -2154,7 +2155,11 @@ fn cmd_branches(
|
|||
ui.stdout_formatter().remove_label()?;
|
||||
print_branch_target(ui, branch_target.local_target.as_ref())?;
|
||||
|
||||
for (remote, remote_target) in branch_target.remote_targets.iter().sorted_by_key(|(name, _target)| name.to_owned()) {
|
||||
for (remote, remote_target) in branch_target
|
||||
.remote_targets
|
||||
.iter()
|
||||
.sorted_by_key(|(name, _target)| name.to_owned())
|
||||
{
|
||||
if Some(remote_target) == branch_target.local_target.as_ref() {
|
||||
continue;
|
||||
}
|
||||
|
@ -2162,10 +2167,10 @@ fn cmd_branches(
|
|||
write!(ui, "{}@{}", name, remote)?;
|
||||
ui.stdout_formatter().remove_label()?;
|
||||
print_branch_target(ui, Some(remote_target))?;
|
||||
// TODO: Display information about remote branches, but probably only
|
||||
// those that have different targets than the local branch.
|
||||
// Maybe indicate how much the remotes are ahead/behind/
|
||||
// diverged.
|
||||
// TODO: Display information about remote branches, but probably
|
||||
// only those that have different targets than the local
|
||||
// branch. Maybe indicate how much the remotes are
|
||||
// ahead/behind/ diverged.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue