time travel to a previous git commit
Project description
git-timewarp
Oftentimes it's neccessary to go back to a previous commit. Perhaps you broke sometime and want to see where, or perhaps you want to benchmark an old version of a function. It's easy to git checkout
, but what if you want to use two different versions of a function in the same script? Or use your latest testing/benchmarking code to run your old function? Fear not! git-timewarp
allows you to temporarily import modules from a specified commit, performing all the git magic under the hood.
Here's how you use it. First, import the GitTimeWarp
object. And the (current) version of a function you want to test.
from git_timewarp import GitTimeWarp
from test import test_func
Let's see the output of the current function
print(test_func())
new function output
Great. But what was the output of that function at an earlier commit? By entering a GitTimeWarp
object, we can time travel to discover what it was. All in the same script!
with GitTimeWarp("a704acc5f651331645ee5850ff1cda0539cc23df") as tw:
from test import test_func
print(test_func())
old function output
Zounds! A ghost has appeared!
How does this work, you ask? The GitTimeWarp
object simply checks out the old code in the timewarps/
folder (remember to add to your .gitignore
!). It then modifies sys.path
and does some more spicy python magic to ensure all imports in the block will reference the code in this other folder.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file git-timewarp-0.0.2.tar.gz
.
File metadata
- Download URL: git-timewarp-0.0.2.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93769d492dfd42d1f0306a35e7ad13fcaf21b87f0874c59eb4575d75fcde69e6 |
|
MD5 | a5b7cd25410184d64ba4c5dbbf91ad56 |
|
BLAKE2b-256 | 085abc1c0b2b4f308d7097234479572fac5b9a67f019cc32295e281031ad5d47 |