Skip to content

Commit

Permalink
Add e2e test for nested splitting commits
Browse files Browse the repository at this point in the history
  • Loading branch information
acamadeo committed Feb 10, 2024
1 parent fe856f9 commit 8728777
Showing 1 changed file with 131 additions and 0 deletions.
131 changes: 131 additions & 0 deletions e2e/evolve/nested/evolve_split.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# Evolve resolves commit graph after splitting commits
# =====================================================

# --- SETUP ---

# Add directory with `git` executable to PATH
env PATH=$PATH${:}/usr/bin/

# Specify commit timestamp so commit hashes are fixed.
env GIT_COMMITTER_DATE='01 Jan 2023 00:00:00 UTC'

# Specify the test interactive sequence editor program (used in `git rebase -i`).
env GIT_SEQUENCE_EDITOR='seq_editor'

# The test interactive editor should paste the instructions in `SEQ_EDITOR_INPUT`
# into Git's instruction sheet.
env SEQ_EDITOR_INPUT='.git/tree/rebase-instructs'

# Setup the Git repository
exec git init
exec git config user.email "[email protected]"
exec git config user.name "Test"
exec write_file README.txt readme
exec git add .
exec git commit -m 'initial commit' --date $GIT_COMMITTER_DATE

# BUG: This commit is needed to prevent a nil pointer dereference (getting the
# parent of an initial commit). Fix the algorithm and remove this extra commit.
exec write_file dummy.txt dummy
exec git add .
exec git commit -m 'Add dummy.txt' --date $GIT_COMMITTER_DATE


# Initial:
#
# [master] ─── (treecko) ─── [sceptile] ─┬─ [turtwig]
# ├─ [chimchar]
# └─ [piplup]
#
# Action:
# - Split [sceptile] into more commits
#
# Result:
#
# [master] ─── (treecko) ─── (grovyle) ─── [sceptile] ─┬─ [turtwig]
# ├─ [chimchar]
# └─ [piplup]

# Add commits to sceptile branch
exec git checkout -b sceptile

exec write_file treecko.txt treecko
exec git add .
exec git commit -m 'Add treecko.txt' --date $GIT_COMMITTER_DATE

exec write_file sceptile.txt sceptile
exec git add .
exec git commit -m 'Add sceptile.txt' --date $GIT_COMMITTER_DATE


# Add commits to turtwig branch
exec git checkout -b turtwig

exec write_file turtwig.txt turtwig
exec git add .
exec git commit -m 'Add turtwig.txt' --date $GIT_COMMITTER_DATE


# Add commits to chimchar branch
exec git checkout sceptile
exec git checkout -b chimchar

exec write_file chimchar.txt chimchar
exec git add .
exec git commit -m 'Add chimchar.txt' --date $GIT_COMMITTER_DATE


# Add commits to piplup branch
exec git checkout sceptile
exec git checkout -b piplup

exec write_file piplup.txt piplup
exec git add .
exec git commit -m 'Add piplup.txt' --date $GIT_COMMITTER_DATE


# Initialize git-tree
exec git-tree init

# Split the commits in the graph.
exec git checkout sceptile
exec git rebase -i HEAD~2

# Add the new commits.
exec write_file grovyle.txt grovyle
exec git add .
exec git commit -m 'Add grovyle.txt' --date $GIT_COMMITTER_DATE

# Continue the rebase.
exec git rebase --continue


# --- TEST ---

# Run evolve
exec git-tree evolve

# BUG: The old commit still exists in the repository, since it's pointed to by
# branch `git-tree-root`. Fix `git-tree-root` target instead of dropping git-tree.
exec git-tree drop

# Compare the git log
exec git log --oneline --graph --all --decorate
cp stdout .git/actual-log
exec compare .git/actual-log .git/golden-log


-- .git/tree/rebase-instructs --
edit 68f0d35 Add treecko.txt
pick 46904f9 Add sceptile.txt
-- .git/golden-log --
* 2387908 (chimchar) Add chimchar.txt
| * 63c6bf9 (piplup) Add piplup.txt
|/
| * 68f964b (turtwig) Add turtwig.txt
|/
* 689eb6b (HEAD -> sceptile) Add sceptile.txt
* 64f5fcb Add grovyle.txt
* 68f0d35 Add treecko.txt
* a7c56ea (master) Add dummy.txt
* cbfe4ef initial commit

0 comments on commit 8728777

Please sign in to comment.