Skip to content

Commit

Permalink
Add e2e test for nested squashing commits
Browse files Browse the repository at this point in the history
  • Loading branch information
acamadeo committed Feb 10, 2024
1 parent 8728777 commit a8c0310
Showing 1 changed file with 135 additions and 0 deletions.
135 changes: 135 additions & 0 deletions e2e/evolve/nested/evolve_squash.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# Evolve resolves commit graph after squashing 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'

# Specify the test interactive editor program.
env GIT_EDITOR='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'

# The test interactive editor should use the contents in `EDITOR_INPUT`.
env EDITOR_INPUT='.git/tree/squashed-commit-name'

# 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] ─── (sceptile) ─── (grovyle) ─── [treecko] ─┬─ [turtwig]
# ├─ [chimchar]
# └─ [piplup]
#
#
# Action:
# - Squash [treecko] into a single commit
#
# Result:
#
# [master] ─── [treecko] ─┬─ [turtwig]
# ├─ [chimchar]
# └─ [piplup]

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

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

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

exec write_file treecko.txt treecko
exec git add .
exec git commit -m 'Add treecko.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 treecko
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 treecko
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

# Squash some commits in the graph.
exec git checkout treecko
exec git rebase -i HEAD~3


# --- 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 --
pick f2649a5 Add sceptile.txt
squash 2e38457 Add grovyle.txt
squash 707b83d Add treecko.txt
-- .git/tree/squashed-commit-name --
Add treecko.txt
-- .git/golden-log --
* 2e7f178 (chimchar) Add chimchar.txt
| * 7693991 (piplup) Add piplup.txt
|/
| * 5dbe0f7 (turtwig) Add turtwig.txt
|/
* 8d819d7 (HEAD -> treecko) Add treecko.txt
* a7c56ea (master) Add dummy.txt
* cbfe4ef initial commit

0 comments on commit a8c0310

Please sign in to comment.