jj/demos/demo_operation_log.sh
Ilya Grigoriev eae9e3408d 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.
2023-10-03 23:52:28 -07:00

55 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
. "$(dirname "$0")"/helpers.sh
new_tmp_dir
jj git clone https://github.com/octocat/Hello-World > /dev/null
cd Hello-World
comment "We are in the octocat/Hello-World repo.
The \"operation log\" shows the operations
so far:"
run_command "jj op log"
comment "We are going to make some changes to show
how the operation log works. Let's add a file, set
a description, and rebase onto the \"test\" branch:"
run_command "echo stuff > new-file"
run_command "jj describe -m stuff"
run_command "jj rebase -d test"
comment "We are now going to make another change off of
master:"
run_command "jj co master"
run_command "jj describe -m \"other stuff\""
comment "The repo now looks like this:"
run_command "jj log"
comment "The most recent portion of the operation log
is:"
run_command_allow_broken_pipe "jj op log | head"
comment "Let's undo that rebase operation:"
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
subsequent \"other stuff\" change was not undone:"
run_command "jj log"
comment "We can also see what the repo looked like
after the rebase operation:"
run_command "jj --at-op $rebase_op log"
comment "Let's say we instead want to go back to the
state of the repo right after the rebase:"
run_command "jj op restore $rebase_op"
# TODO: Explain and demo that undo and restore are also recorded? Remove demo
# of --at-op?
comment "We're now back to before the \"other stuff\"
change existed:"
run_command "jj log"
blank