Skip to content

Latest commit

 

History

History
116 lines (73 loc) · 4.12 KB

README.rst

File metadata and controls

116 lines (73 loc) · 4.12 KB

gitfs2

https://codecov.io/github/moremoban/gitfs2/coverage.png https://pepy.tech/badge/gitfs2/month https://img.shields.io/github/stars/moremoban/gitfs2.svg?style=social&maxAge=3600&label=Star https://img.shields.io/static/v1?label=continuous%20templating&message=%E6%A8%A1%E7%89%88%E6%9B%B4%E6%96%B0&color=blue&style=flat-square https://img.shields.io/static/v1?label=coding%20style&message=black&color=black&style=flat-square https://dev.azure.com/moremoban/gitfs2/_apis/build/status/moremoban.gitfs2?branchName=master

It helps perform file operations over a git repository. It clones the git repository and returns python file system 2's OSFS instance.

The idea originates from moban, which uses git repositories as a vehicle to have versioned templates for the creation of a new python package. Surely, it can be implemented in any other ways but moban v0.6.0 mandates python file system 2 interface. Hence this library is written.

Get a file inside a python package

>>> import fs
>>> git_fs = fs.open_fs("git://github.com/moremobans/pypi-mobans.git!/templates")
>>> git_fs.readtext("_version.py.jj2")
'__version__ = "0.0.5"\n__author__ = "C.W."\n'

Get from a different branch

>>> import fs
>>> git_fs = fs.open_fs("git://github.com/moremobans/pypi-mobans.git?branch=master!/templates")
>>> git_fs.read("_version.py.jj2")
'__version__ = "0.0.5"\n__author__ = "C.W."\n'

Checkout submodules recursively

>>> git_fs = fs.open_fs("git://github.com/moremobans/pypi-mobans.git?branch=master&submodule=true!/templates")

Does it write?

Yes locally, it will write as you can do so without using gitfs2. And no, it does not help commit and push the changes for you.

Plus, the intention is never to write to a repository.

Primary use case

You can do the following with moban:

$ moban -t 'git://github.com/moremoban/pypi-mobans.git!/templates/_version.py.jj2' \
        -c 'git://github.com/moremoban/pypi-mobans.git!/config/data.yml' \
        -o _version.py
Info: Found repo in /Users/jaska/Library/Caches/gitfs2/repos/pypi-mobans
Templating git://github.com/moremoban/pypi-mobans.git!/templates/_version.py.jj2 to _version.py
Templated 1 file.
$ cat _version.py
__version__ = "0.1.1rc3"
__author__ = "C.W."

License

MIT

Installation

You can install gitfs2 via pip:

$ pip install gitfs2

or clone it and install it:

$ git clone https://github.com/moremoban/gitfs2.git
$ cd gitfs2
$ python setup.py install