Debian Codegraph @

demos/demo_operation_log.sh

raw
1 #!/bin/bash
2 set -euo pipefail
3 . "$(dirname "$0")"/helpers.sh
4
5 new_tmp_dir
6 {
7 jj git clone https://github.com/octocat/Hello-World
8 cd Hello-World
9 jj abandon --ignore-immutable octocat-patch-1@origin
10 jj bookmark forget octocat-patch-1
11 jj bookmark track test@origin
12 } > /dev/null 2>&1
13
14 comment "We are in the octocat/Hello-World repo.
15 The \"operation log\" shows the operations
16 so far:"
17 run_command "jj op log"
18
19 comment "We are going to make some changes to show
20 how the operation log works. Let's add a file, set
21 a description, and rebase onto the \"test\" bookmark:"
22 run_command "echo stuff > new-file"
23 run_command "jj describe -m stuff"
24 run_command "jj rebase --onto test"
25
26 comment "We are now going to make another change off of
27 master:"
28 run_command "jj new master"
29 run_command "jj describe -m \"other stuff\""
30
31 comment "The repo now looks like this:"
32 run_command "jj log"
33 comment "The most recent portion of the operation log
34 is:"
35 run_command_allow_broken_pipe "jj op log --limit 4"
36
37 comment "Let's revert that rebase operation:"
38 rebase_op=$(jj --color=never op log --no-graph -T 'id.short(5)' --limit 1 --at-op @--)
39 run_command "jj op revert $rebase_op"
40
41 comment "Note that only the rebase was reverted, and the
42 subsequent \"other stuff\" change was not reverted:"
43 run_command "jj log"
44
45 comment "We can also see what the repo looked like
46 after the rebase operation:"
47 run_command "jj --at-op $rebase_op log"
48
49 comment "Let's say we instead want to go back to the
50 state of the repo right after the rebase:"
51 run_command "jj op restore $rebase_op"
52
53 # TODO: Explain and demo that revert and restore are also recorded? Remove demo
54 # of --at-op?
55 comment "We're now back to before the \"other stuff\"
56 change existed:"
57 run_command "jj log"
58
59 blank