Skip to content

Commit

Permalink
git-push: skip print-changes loop if --quiet
Browse files Browse the repository at this point in the history
  • Loading branch information
yuja committed Sep 14, 2024
1 parent 42f7908 commit 2f78c25
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions cli/src/commands/git/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ use crate::command_error::user_error_with_hint;
use crate::command_error::CommandError;
use crate::commands::git::get_single_remote;
use crate::commands::git::map_git_error;
use crate::formatter::Formatter;
use crate::git_util::get_git_repo;
use crate::git_util::with_remote_git_callbacks;
use crate::git_util::GitSidebandProgressMessageWriter;
Expand Down Expand Up @@ -265,9 +266,10 @@ pub fn cmd_git_push(
}

validate_commits_ready_to_push(&bookmark_updates, &remote, &tx, command, args)?;

writeln!(ui.status(), "Bookmark changes to push to {}:", &remote)?;
print_commits_ready_to_push(ui, repo.as_ref(), &bookmark_updates)?;
if let Some(mut formatter) = ui.status_formatter() {
writeln!(formatter, "Bookmark changes to push to {remote}:")?;
print_commits_ready_to_push(formatter.as_mut(), repo.as_ref(), &bookmark_updates)?;
}

if args.dry_run {
writeln!(ui.status(), "Dry-run requested, not pushing.")?;
Expand Down Expand Up @@ -378,7 +380,7 @@ fn validate_commits_ready_to_push(
}

fn print_commits_ready_to_push(
ui: &Ui,
formatter: &mut dyn Formatter,
repo: &dyn Repo,
bookmark_updates: &[(String, BookmarkPushUpdate)],
) -> io::Result<()> {
Expand Down Expand Up @@ -426,18 +428,18 @@ fn print_commits_ready_to_push(
format!("Move sideways bookmark {bookmark_name} from {old} to {new}")
}
};
writeln!(ui.status(), " {msg}")?;
writeln!(formatter, " {msg}")?;
}
(Some(old_target), None) => {
writeln!(
ui.status(),
formatter,
" Delete bookmark {bookmark_name} from {}",
short_commit_hash(old_target)
)?;
}
(None, Some(new_target)) => {
writeln!(
ui.status(),
formatter,
" Add bookmark {bookmark_name} to {}",
short_commit_hash(new_target)
)?;
Expand Down

0 comments on commit 2f78c25

Please sign in to comment.