lethe is a Python module for git-based snapshotting.
lethe is intended as a mechanism for creating commits outside
the standard git branching/tagging workflows. It is meant to enable
additional use-cases without disrupting the standard workflows.
Use cases include:
- On-disk undo log
- Syncing work-in-progress between computers before it's ready
- lab notebook: Recording the code / configuration state that resulted in a given output
- incremental backup: Space-efficient time-based backups of a codebase
Creating a commit from the command line
$ cd path/to/repo $ lethe 122d058e375274a186c407f28602c3b14a2cab95
This effectively snapshots the current state of the repository (as would be seen by
git add --all) and creates a new commit (
which points to it. The current branch and index are not changed.
-p my_parent_refis used to provide "parent" refs which become the parents of the created commit. If a parent ref is a symbolic ref, both the provided ref and the ref it points to are used as parents. If not present, defaults to
-t ref/lethe/my_target_refis used to provide "target" refs which will be created/updated to point to the created commit. If not present, defaults to adding an entry of the form
-t refs/lethe/my_branchfor each parent ref of the form
-t refs/lethe/my/refpathfor non-head refs of the form
refs/my/refpath. All provided parent refs and any dereferenced parent refs are used to generate default target refs. If any of the target refs already exist, the commits they point to become parents of the created commit.
-m "my message"sets the commit message for the snapshot. By default, "snapshot <current datetime>" is used.
-r path/to/repocan be provided to specify a repository outside of the current working directory.
$ cd path/to/repo $ git branch * master $ lethe
is equivalent to
lethe -r path/to/repo -p HEAD
lethe -r path/to/repo -p HEAD -p refs/heads/master -t refs/lethe/HEAD -t refs/lethe/master
Creating a commit programmatically
import lethe REPO = '/path/to/repo' commit_sha = lethe.snap(cwd=REPO) tree_sha = lethe.get_tree(commit_sha, cwd=REPO) print('Created new commit with hash ' + commit_sha + ' aka refs/lethe/HEAD') print('Code (tree) state is ' + tree_sha)
- python 3 (written and tested with 3.6)
- git (accessible on the system
Install with pip:
pip install lethe
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size lethe-0.7-py3-none-any.whl (17.4 kB)||File type Wheel||Python version py3||Upload date||Hashes View hashes|
|Filename, size lethe-0.7.tar.gz (5.0 kB)||File type Source||Python version None||Upload date||Hashes View hashes|