User:Victor Grousset - tuxayo/Git

From Koha Wiki
Jump to navigation Jump to search

Move tests to a separate commit

# context: A single commit with a new test in t/db_dependent/HoldsQueue.t
# and the implementation in Koha/Hold.pm
# But we want to run the tests separately to check that they
# fail without the implementation.
# And keep the original commit author and commit message.

git bz apply 35997

# Create the opposite diff of changes to the tests and the program. (and it's staged)
# Now we remove the changes for the tests. Because we want to keep them.
# So we get rid of their opposite version.
# Do this for each test file changed. 

git revert --no-commit HEAD
git status
git restore --staged t/db_dependent/HoldsQueue.t
git restore t/db_dependent/HoldsQueue.t

# Now we amend the commit to include the change that will remove the implementation.
# It's like colliding matter and antimatter. Only for the implementation.
# And we change the commit message to reflect it's the tests.
# And confirm that the diff only includes the test.
git commit --amend -v

# Apply patch again, to get the implementation this time and with it message and author.
# The tests at already applied so the new commit will only contain the implementation.
git bz apply 35997

# review the whole result (diffs, author, commit messages, order of commits)
git log -p --pretty=fuller

# now you can attach the commits and the previous merged version on the ticket will
# be replaced because the implementation commit still have the same name