Skip to content

Commit

Permalink
Add e2e test for nested commits
Browse files Browse the repository at this point in the history
  • Loading branch information
acamadeo committed Feb 10, 2024
1 parent abdd5ac commit ffe468e
Show file tree
Hide file tree
Showing 2 changed files with 261 additions and 0 deletions.
113 changes: 113 additions & 0 deletions e2e/evolve/nested/evolve_commit.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Evolve works in nested tree after for upstream 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'

# 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] ─┬─ [turtwig]
# ├─ [chimchar]
# └─ [piplup]
#
# Action:
# - Add more commits onto [treecko]
#
# Result:
# - Same tree but extending from new [treecko] branch

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

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

# Add commits to an upstream branch
exec git checkout treecko

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


# --- 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/golden-log --
* 2387908 (chimchar) Add chimchar.txt
| * 63c6bf9 (piplup) Add piplup.txt
|/
| * 68f964b (turtwig) Add turtwig.txt
|/
* 689eb6b (HEAD -> treecko) Add sceptile.txt
* 64f5fcb Add grovyle.txt
* 68f0d35 Add treecko.txt
* a7c56ea (master) Add dummy.txt
* cbfe4ef initial commit
148 changes: 148 additions & 0 deletions e2e/evolve/nested/evolve_commit_deep.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# Evolve works for nested amends
# ==============================

# --- 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'

# 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] ─── [mew] ─┬─ [ralts] ───── [kirlia] ─┬─ [gardevoir]
# | └─ [gallade]
# └─ [snorunt] ─┬─ [glalie]
# └─ [froslass]
#
# Action:
# - Add more commits onto [mew]
#
# Result:
# - Same tree but extending from amended commit

# Add commits to first branch
exec git checkout -b mew

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


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

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


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

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


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

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


# Add commits to gallade branch
exec git checkout kirlia
exec git checkout -b gallade

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


# Add commits to snorunt branch
exec git checkout mew
exec git checkout -b snorunt

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


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

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


# Add commits to froslass branch
exec git checkout snorunt
exec git checkout -b froslass

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


# Initialize git-tree
exec git-tree init

# Add commits to an upstream branch
exec git checkout mew

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


# --- 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/golden-log --
* 2cda882 (froslass) Add froslass.txt
| * e33e632 (gallade) Add gallade.txt
| | * 1d52672 (gardevoir) Add gardevoir.txt
| |/
| * 4f56859 (kirlia) Add kirlia.txt
| * 6c10ec4 (ralts) Add ralts.txt
| | * c922eef (glalie) Add glalie.txt
| |/
|/|
* | d31da57 (snorunt) Add snorunt.txt
|/
* f6e69a0 (HEAD -> mew) Add mewtwo.txt
* 17925b0 Add mew.txt
* a7c56ea (master) Add dummy.txt
* cbfe4ef initial commit

0 comments on commit ffe468e

Please sign in to comment.