From eae9e3408d6a94ccfbc4d76356ab49c426ca78c4 Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Mon, 28 Aug 2023 22:59:58 -0700 Subject: [PATCH] demos: allow broken pipe when doing `jj | head`, fix opid `jj | head` exits with non-zero code since `head` breaks the pipe. Also, removed `--color=always` from that command as it will shortly become unnecessary. Previosly, this caused the script to stop since it's run with `set -o pipefail`. Also, the operation id recovery code stopped working. We can use `jj debug operation` for this purpose now. --- demos/demo_operation_log.sh | 4 ++-- demos/helpers.sh | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/demos/demo_operation_log.sh b/demos/demo_operation_log.sh index 6b23a88f5..6eb04388a 100755 --- a/demos/demo_operation_log.sh +++ b/demos/demo_operation_log.sh @@ -27,10 +27,10 @@ comment "The repo now looks like this:" run_command "jj log" comment "The most recent portion of the operation log is:" -run_command "jj op log --color=always | head" +run_command_allow_broken_pipe "jj op log | head" comment "Let's undo that rebase operation:" -rebase_op=$(jj --color=never op log | grep '^◉ ' | sed '2q;d' | cut -b4-15) +rebase_op=$(jj --color=never op log --no-graph -T 'id.short(5)' --limit 1 --at-op @--) run_command "jj undo $rebase_op" comment "Note that only the rebase was undone, and the diff --git a/demos/helpers.sh b/demos/helpers.sh index 8a3832aa6..3a35123a9 100644 --- a/demos/helpers.sh +++ b/demos/helpers.sh @@ -14,6 +14,21 @@ run_command() { eval "$@" } +run_command_allow_broken_pipe() { + run_command "$@" || { + EXITCODE="$?" + case $EXITCODE in + 3) + # `jj` exits with error coded 3 on broken pipe, + # which can happen simply because of running + # `jj|head`. + return 0;; + *) + return $EXITCODE;; + esac + } +} + blank() { echo "" }