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.
This commit is contained in:
Ilya Grigoriev 2023-08-28 22:59:58 -07:00
parent 68b8069c5e
commit eae9e3408d
2 changed files with 17 additions and 2 deletions

View File

@ -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

View File

@ -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 ""
}