From 84f658d99294edb6314dac66192b90583c641164 Mon Sep 17 00:00:00 2001 From: Anthony Amadeo Date: Sun, 11 Feb 2024 20:40:56 +0000 Subject: [PATCH] Add e2e test for [reorder, amend] --- .../combinations/reorder_then_amend.txt | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 e2e/evolve/combinations/reorder_then_amend.txt diff --git a/e2e/evolve/combinations/reorder_then_amend.txt b/e2e/evolve/combinations/reorder_then_amend.txt new file mode 100644 index 0000000..787e238 --- /dev/null +++ b/e2e/evolve/combinations/reorder_then_amend.txt @@ -0,0 +1,107 @@ +# Evolve resolves commit graph after reorder + amend downstream +# ============================================================= + +# --- 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 "test@example.com" +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] ─── (grovyle) ─── (treecko) ─── [sceptile] ─── [turtwig] +# +# Action: +# 1. Reorder commits in [sceptile] +# 2. Amend [turtwig] +# +# Result: +# [master] ─── (treecko) ─── (grovyle) ─── [sceptile] ─── [turtwig] + +# Add commits to sceptile branch +exec git checkout -b sceptile + +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 + +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 + + +# Initialize git-tree +exec git-tree init + +# Reorder the commits in the graph. +exec git checkout sceptile +exec git rebase -i HEAD~3 + + +# Amend a downstream commit +exec git checkout turtwig +exec git commit --amend -m 'Amend turtwig.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/tree/rebase-instructs -- +pick 5f510c1 Add treecko.txt +pick 9793ef5 Add grovyle.txt +pick 286d656 Add sceptile.txt +-- .git/golden-log -- +* a71bab3 (HEAD -> turtwig) Amend turtwig.txt +* 689eb6b (sceptile) Add sceptile.txt +* 64f5fcb Add grovyle.txt +* 68f0d35 Add treecko.txt +* a7c56ea (master) Add dummy.txt +* cbfe4ef initial commit