Git-JSON-Tree.
Project description
Encode and decode JSON files as Git tree objects.
This is an experimental developer preview release.
Installation
The latest release is available on PyPI and can be installed using pip:
$ pip install git-json-tree
The development version can be installed directly from the Git repository:
$ pip install -e git+https://github.com/jirikuncar/git-json-tree.git#egg=git-json-tree
Integration with Git
Move to a repository where you would like to store JSON files and add following lines to files:
.git/config
[filter "git-json-tree"]
smudge = "git-json-tree smudge"
clean = "git-json-tree clean"
required # optional
.gitattributes
*.json filter=git-json-tree
Pointer file format
Git Git-JSON-Tree’s pointer file looks like this:
version https://github.com/jirikuncar/git-json-tree/tree/v1
oid sha1:2f769492d6b634b86b82e916630da8a693e9c20e
size 12345
It tracks the version of Git-JSON-Tree you’re using, followed by a unique identifier for the JSON file (oid). It also stores the size of the target JSON file.
- NOTE:
size is calculated from the encoded JSON string and it might differ depending on the version of serializer.
Use the command line
Interaction with the storage can also take place via the command-line interface (CLI).
First, you need to make sure that you are in a Git repository or you know its location. The example shows a case when you are in the directory with a Git repository.
$ echo '{"hello": "world", "version": 1}' | git-json-tree encode
7123db01ad8c75a8df3508305bd891317ea36feb
Following the above example you can create a first commit of your JSON object.
$ export FIRST=$(git commit-tree 7123db01 -m First)
It is quite impractical to remember tree or commit sha1, hence we can give it a reference name. The next steps uses the name master, but you can decide to use your own naming convention for tracking versions of your objects. Each file can have its own branch or just a single tag.
$ git update-ref refs/heads/master $FIRST # for new object
Storing a new version is very simple too.
$ export PARENT=$(git show-ref --hash refs/heads/master)
$ echo '{"hello": "world", "version": 2}' | git-json-tree encode
6f36c4272e88b14ab5e25a5419599534504c70fc
$ export SECOND=$(git commit-tree 6f36c4272e -m Second -p $PARENT)
$ git update-ref refs/heads/master $SECOND
Finally, you can retrive and decode a tree or commit.
$ git-json-tree decode # HEAD
$ git-json-tree decode $FIRST # commit
$ git-json-tree decode 7123db01 # tree id
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
Built Distribution
File details
Details for the file git-json-tree-0.1.0.dev20180216.tar.gz
.
File metadata
- Download URL: git-json-tree-0.1.0.dev20180216.tar.gz
- Upload date:
- Size: 30.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01bc2e170e0744162c611068e60d519870dc5f3435ea2e6563d605767ad09da1 |
|
MD5 | e81a708594619aba3e9ca5ea611dcaa8 |
|
BLAKE2b-256 | 2dab1be490fcec8ecdf9a33a852477fb2e8ae4ff94fd64a0a0a3728e4f948cb8 |
File details
Details for the file git_json_tree-0.1.0.dev20180216-py2.py3-none-any.whl
.
File metadata
- Download URL: git_json_tree-0.1.0.dev20180216-py2.py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97e56a1a54c1dd805352cf9408bafa0ea51447ee7aa777e3bb9abd089ef59bbc |
|
MD5 | 3802a3fd0f5d4fe262a7f46f894a478b |
|
BLAKE2b-256 | 4dbbaf8d9a2bd1b91776ce368a35ebf3280097d4699029d909d8669e3ec027b8 |