Skip to content

Commit

Permalink
demos: rearrange and reword portions of demos
Browse files Browse the repository at this point in the history
This is mainly to account for the fact that most commands now report
more information about the state of the repo.
  • Loading branch information
ilyagr committed Oct 2, 2023
1 parent 7acb046 commit 854876b
Show file tree
Hide file tree
Showing 11 changed files with 365 additions and 375 deletions.
1 change: 1 addition & 0 deletions demos/demo_git_compat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ run_command "cd Hello-World"

comment "Inspect it:"
run_command "jj log -r 'all()'"
blank
run_command "jj diff -r b1"

comment "The repo is backed by the actual Git repo:"
Expand Down
10 changes: 4 additions & 6 deletions demos/demo_juggle_conflicts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@ comment "Let's reorder the second and third commits:"
run_command "jj rebase -s third -d first"
run_command "jj rebase -s second -d third"
run_command "jj log"
comment "The commit labeled \"third\" has a conflict,
as expected. What's more interesting is
that the top commit has no conflict! That's
because it has the changes from all three
commits applied to it."
comment "The commit labeled \"third\" has a conflict, as expected. What's more
interesting is that the top commit has no conflict! That's because it
has the changes from all three commits applied to it.
comment "Let's verify that by looking at its contents:"
Let's verify that by looking at its contents:"
run_command "jj co second"
run_command "cat file"

Expand Down
8 changes: 6 additions & 2 deletions demos/demo_operation_log.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ set -euo pipefail
. "$(dirname "$0")"/helpers.sh

new_tmp_dir
jj git clone https://github.com/octocat/Hello-World > /dev/null
cd Hello-World
{
jj git clone https://github.com/octocat/Hello-World
cd Hello-World
jj abandon octocat-patch-1
jj branch forget octocat-patch-1
} > /dev/null

comment "We are in the octocat/Hello-World repo.
The \"operation log\" shows the operations
Expand Down
13 changes: 8 additions & 5 deletions demos/demo_resolve_conflicts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,24 @@ run_command "jj describe -m \"README: say which world\""
run_command "echo \"Hello Earth!\" > README"
run_command "jj diff"

# TODO(ilyagr): Get the real shortest prefix of the b1b commit using `jj log
# --no-graph` and the `.shortest()` template function.
#
# This could also be done in demo_git_compat.sh, but that might not be worth it.
comment "We're going to rebase it onto commit b1.
That commit looks like this:"
run_command "jj diff -r b1"

comment "Now rebase:"
run_command "jj rebase -d b1"

comment "Huh, that seemed to succeed. Let's take a
look at the repo:"
comment "That seemed to succeed but we are also told there is now a conflict.
Let's take a look at the repo:"
run_command "jj log -r 'all()'"
run_command "jj status"

comment "As you can see, the rebased commit has a
conflict. The file in the working copy looks
like this:"
comment "Indeed, the rebased commit has a conflict. The conflicted file
in the working copy looks like this:"
run_command "cat README"

comment "Now we will resolve the conflict:"
Expand Down
32 changes: 20 additions & 12 deletions demos/demo_working_copy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,27 @@ set -euo pipefail
. "$(dirname "$0")"/helpers.sh

new_tmp_dir
jj git clone https://github.com/octocat/Hello-World > /dev/null
cd Hello-World
{
jj git clone https://github.com/octocat/Hello-World
cd Hello-World
jj abandon test
jj branch forget test
jj abandon octocat-patch-1
jj branch forget octocat-patch-1
}> /dev/null

comment "We are in the octocat/Hello-World repo.
We have an empty working copy on top of master:"
run_command "jj status"
run_command "jj log"
run_command "jj status"

comment "Now make some changes in the working copy:"
run_command "echo \"Goodbye World!\" > README"
run_command "echo stuff > new-file"

comment "Our working copy's commit ID changed
because we made changes:"
comment "Because of these changes, our working copy is no longer marked as \"(empty)\".
Also, its commit ID (starting with a blue character) changed:"
run_command "jj status"
run_command "jj log"

comment "Add a branch so we can easily refer to this
commit:"
Expand All @@ -27,24 +32,27 @@ run_command "jj log"

comment "Start working on a new change off of master:"
run_command "jj co master"
run_command "jj log"

comment "Note that the working copy is now clean; the
comment "Note that we were told the working copy is now empty (AKA clean). The
\"goodbye\" change stayed in its own commit:"

run_command "jj log"
comment "Let's do a sanity check: 'jj status' should tell us that
the working copy is clean."
run_command "jj status"

comment "Modify a file in this new change:"
run_command "echo \"Hello everyone!\" > README"
run_command "jj status"

comment "The working copy is not special; we can, for
example, set the description of any commit.
First, set it on the working copy:"
run_command "jj describe -m everyone"
# The output with the description of the working copy messes up the parallel
# a bit, so we redact it.
run_command_output_redacted "jj describe -m everyone"

comment "Now set it on the change we worked on before:"
run_command "jj describe goodbye -m goodbye"

comment "Inspect the result:"
run_command "jj log"

blank
47 changes: 24 additions & 23 deletions demos/git_compat.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions demos/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ run_command() {
COLUMNS=${RUN_COMMAND_COLUMNS-${COLUMNS-80}} eval "$@"
}

run_command_output_redacted() {
echo "\$ $@"
# `bash` often resets $COLUMNS, so we also
# allow $RUN_COMMAND_COLUMNS
eval "$@" > /dev/null
echo -e "\033[0;90m... (output redacted) ...\033[0m"
}

run_command_allow_broken_pipe() {
run_command "$@" || {
EXITCODE="$?"
Expand Down
Loading

0 comments on commit 854876b

Please sign in to comment.