Skip to content

Commit b5d6056

Browse files
authored
Merge pull request #8 from moremoban/dev
🥚 🎡 release 0.0.3
2 parents 00da96b + a0dea03 commit b5d6056

19 files changed

+168
-34
lines changed

.github/workflows/pythonpublish.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Upload Python Package
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v1
12+
- name: Set up Python
13+
uses: actions/setup-python@v1
14+
with:
15+
python-version: '3.x'
16+
- name: Install dependencies
17+
run: |
18+
python -m pip install --upgrade pip
19+
pip install setuptools wheel twine
20+
- name: Build and publish
21+
env:
22+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
23+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
24+
run: |
25+
python setup.py sdist bdist_wheel
26+
twine upload dist/*

.moban.d/CUSTOM_README.rst.jj2

+6-2
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,14 @@ Checkout submodules recursively
4747
Does it write?
4848
--------------------------------------------------------------------------------
4949

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

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

55+
License
56+
--------------------------------------------------------------------------------
57+
58+
MIT
5559

5660
{% endblock %}

.moban.d/mit_license.jj2

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) {{copyright_year}} {{company}}
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

.moban.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ targets:
88
- setup.py: custom_setup.py.jj2
99
- requirements.txt: requirements.txt.jj2
1010
- "tests/requirements.txt": "tests/custom_requirements.txt.jj2"
11-
- "docs/source/conf.py": "docs/conf.py_t"
1211
- "gitfs2/_version.py": "_version.py.jj2"
1312
- .gitignore: gitignore.jj2
1413
- .travis.yml: travis.yml.jj2
@@ -17,3 +16,4 @@ targets:
1716
configuration: changelog.yml
1817
template: CHANGELOG.rst.jj2
1918
- lint.sh: lint.script.jj2
19+
- LICENSE: mit_license.jj2

CHANGELOG.rst

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
Change log
22
================================================================================
33

4+
0.0.3 - 11.12.2019
5+
--------------------------------------------------------------------------------
6+
7+
**Added**
8+
9+
#. `#5 <https://github.com/moremoban/gitfs2/issues/5>`_: support offline
10+
#. `#7 <https://github.com/moremoban/gitfs2/issues/7>`_: add license text
11+
412
0.0.2 - 2.10.2019
513
--------------------------------------------------------------------------------
614

7-
Fix
8-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15+
**Fixed**
916

1017
#. `#4 <https://github.com/moremoban/gitfs2/issues/4>`_: failed to checkout more
1118
than one git repo.
1219

1320
0.0.1 - 19.08.2019
1421
--------------------------------------------------------------------------------
1522

16-
first release
17-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
23+
**first release**
1824

1925
#. what a feat!

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2019 moban dev team
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

MANIFEST.in

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
include README.rst
22
include CHANGELOG.rst
3+
include LICENSE
4+

README.rst

+14-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ gitfs2
88
.. image:: https://codecov.io/github/moremoban/gitfs2/coverage.png
99
:target: https://codecov.io/github/moremoban/gitfs2
1010

11+
.. image:: https://badge.fury.io/py/gitfs2.svg
12+
:target: https://pypi.org/project/gitfs2
13+
14+
.. image:: https://pepy.tech/badge/gitfs2/month
15+
:target: https://pepy.tech/project/gitfs2/month
16+
1117

1218
.. image:: https://dev.azure.com/moremoban/gitfs2/_apis/build/status/moremoban.gitfs2?branchName=master
1319
:target: https://dev.azure.com/moremoban/gitfs2/_build/latest?definitionId=2&branchName=master
@@ -28,7 +34,7 @@ Get a file inside a python package
2834
>>> import fs
2935
>>> git_fs = fs.open_fs("git://github.com/moremobans/pypi-mobans.git!/templates")
3036
>>> git_fs.readtext("_version.py.jj2")
31-
'__version__ = "0.0.2"\n__author__ = "C.W."\n'
37+
'__version__ = "0.0.3"\n__author__ = "C.W."\n'
3238
3339
3440
Get from a different branch
@@ -39,7 +45,7 @@ Get from a different branch
3945
>>> import fs
4046
>>> git_fs = fs.open_fs("git://github.com/moremobans/pypi-mobans.git?branch=master!/templates")
4147
>>> git_fs.read("_version.py.jj2")
42-
'__version__ = "0.0.2"\n__author__ = "C.W."\n'
48+
'__version__ = "0.0.3"\n__author__ = "C.W."\n'
4349
4450
4551
Checkout submodules recursively
@@ -53,11 +59,15 @@ Checkout submodules recursively
5359
Does it write?
5460
--------------------------------------------------------------------------------
5561

56-
Yes locally, it will write as you can do so without using gitfs2. And no, it does help
57-
commit and push the changes for you.
62+
Yes locally, it will write as you can do so without using gitfs2. And no, it
63+
does not help commit and push the changes for you.
5864

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

67+
License
68+
--------------------------------------------------------------------------------
69+
70+
MIT
6171

6272

6373
Installation

changelog.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@ name: gitfs2
22
organisation: moremoban
33
releases:
44
- changes:
5-
- action: Fix
5+
- action: Added
6+
details:
7+
- "`#5`: support offline"
8+
- "`#7`: add license text"
9+
version: 0.0.3
10+
date: 11.12.2019
11+
- changes:
12+
- action: Fixed
613
details:
714
- "`#4`: failed to checkout more than one git repo."
815
version: 0.0.2

docs/source/conf.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# This file only contains a selection of the most common options. For a full
44
# list see the documentation:
5-
# http://www.sphinx-doc.org/en/master/config
5+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
66

77
# -- Path setup --------------------------------------------------------------
88

@@ -20,9 +20,9 @@
2020
copyright = ''
2121
author = 'C.W.'
2222
# The short X.Y version
23-
version = '0.0.2'
23+
version = '0.0.3'
2424
# The full version, including alpha/beta/rc tags
25-
release = '0.0.2'
25+
release = '0.0.3'
2626

2727
# -- General configuration ---------------------------------------------------
2828

gitfs2.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ organisation: "moremoban"
33
author: "C.W."
44
55
company: "moban dev team"
6-
version: "0.0.2"
7-
current_version: "0.0.2"
8-
release: "0.0.2"
6+
version: "0.0.3"
7+
current_version: "0.0.3"
8+
release: "0.0.3"
99
copyright_year: 2019
1010
license: MIT
1111
dependencies:

gitfs2/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = "0.0.2"
1+
__version__ = "0.0.3"
22
__author__ = "C.W."

gitfs2/constants.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
PROGRAM_NAME = "gitfs2"
22
REPOS_DIR_NAME = "repos"
33

4-
MESSAGE_INVALID_GIT_URL = 'An invalid git url: "%s" in mobanfile'
4+
MESSAGE_INVALID_GIT_URL_FMT = 'An invalid git url: "%s" in mobanfile'
5+
MESSAGE_GIT_COMMAND_PROBLEM = "Unable to run git commands. Offline?"
6+
MESSAGE_FOUND_REPO_FMT = "Found local checkout in %s"
7+
MESSAGE_UPDATE_SUBMODULE = "updating submodule"
8+
MESSAGE_CHECKOUT_SUBMODULE = "checking out submodule"
9+
MESSAGE_GIT_CLONE_FMT = "git clone %s"
510
DEFAULT_CLONE_DEPTH = 2

gitfs2/opener.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ def open_fs(self, fs_url, parse_result, writeable, create, cwd):
1818
submodule=parse_result.params.get("submodule"),
1919
reference=parse_result.params.get("reference"),
2020
)
21+
2122
local_folder = repo.git_clone(
22-
require, action_required=GitFSOpener.update_registry.get(git_url, True)
23+
require,
24+
action_required=GitFSOpener.update_registry.get(git_url, True),
2325
)
2426
if GitFSOpener.update_registry.get(git_url, True):
2527
GitFSOpener.update_registry[git_url] = False

gitfs2/repo.py

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import os
22
import sys
33
import errno
4+
import logging
45
import subprocess
56

67
import fs
78
import fs.path
89
import fs.errors
910
from gitfs2 import reporter, constants
1011

12+
LOG = logging.getLogger(__name__)
13+
1114

1215
class GitRequire(object):
1316
def __init__(
@@ -49,6 +52,7 @@ def convert_submodule(submodule_string):
4952

5053
def git_clone(require, action_required=True):
5154
from git import Repo
55+
from git.exc import GitCommandError
5256

5357
if sys.platform != "win32":
5458
# Unfortunately for windows user, the following function
@@ -65,24 +69,28 @@ def git_clone(require, action_required=True):
6569
if action_required:
6670
try:
6771
fs.open_fs(local_repo_folder)
68-
reporter.info("Found repo in %s" % local_repo_folder)
72+
reporter.info(constants.MESSAGE_FOUND_REPO_FMT % local_repo_folder)
6973
repo = Repo(local_repo_folder)
7074
repo.git.pull()
7175
if require.reference:
7276
repo.git.checkout(require.reference)
7377
elif require.branch:
7478
repo.git.checkout(require.branch)
7579
if require.submodule:
76-
reporter.info("updating submodule")
80+
reporter.info(constants.MESSAGE_UPDATE_SUBMODULE)
7781
repo.git.submodule("update")
7882
except fs.errors.CreateFailed:
79-
reporter.info("git clone %s" % require.git_url)
83+
reporter.info(constants.MESSAGE_GIT_CLONE_FMT % require.git_url)
8084
repo = Repo.clone_from(
8185
require.git_url, local_repo_folder, **require.clone_params()
8286
)
8387
if require.submodule:
84-
reporter.info("checking out submodule")
88+
reporter.info(constants.MESSAGE_CHECKOUT_SUBMODULE)
8589
repo.git.submodule("update", "--init")
90+
except GitCommandError as e:
91+
reporter.warn(constants.MESSAGE_GIT_COMMAND_PROBLEM)
92+
LOG.warn(e)
93+
return local_repo_folder
8694

8795
return local_repo_folder
8896

@@ -95,7 +103,7 @@ def get_repo_name(repo_url):
95103
repo = giturlparse.parse(repo_url.rstrip("/"))
96104
return repo.name
97105
except ParserError:
98-
reporter.error(constants.MESSAGE_INVALID_GIT_URL % repo_url)
106+
reporter.error(constants.MESSAGE_INVALID_GIT_URL_FMT % repo_url)
99107
raise
100108

101109

setup.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
NAME = "gitfs2"
3131
AUTHOR = "C.W."
32-
VERSION = "0.0.2"
32+
VERSION = "0.0.3"
3333
3434
LICENSE = "MIT"
3535
ENTRY_POINTS = {
@@ -41,7 +41,7 @@
4141
"Python file system 2 over GitPython"
4242
)
4343
URL = "https://github.com/moremoban/gitfs2"
44-
DOWNLOAD_URL = "%s/archive/0.0.2.tar.gz" % URL
44+
DOWNLOAD_URL = "%s/archive/0.0.3.tar.gz" % URL
4545
FILES = ["README.rst", "CHANGELOG.rst"]
4646
KEYWORDS = [
4747
"python",
@@ -78,8 +78,8 @@
7878
}
7979
# You do not need to read beyond this line
8080
PUBLISH_COMMAND = "{0} setup.py sdist bdist_wheel upload -r pypi".format(sys.executable)
81-
GS_COMMAND = ("gs gitfs2 v0.0.2 " +
82-
"Find 0.0.2 in changelog for more details")
81+
GS_COMMAND = ("gs gitfs2 v0.0.3 " +
82+
"Find 0.0.3 in changelog for more details")
8383
NO_GS_MESSAGE = ("Automatic github release is disabled. " +
8484
"Please install gease to enable it.")
8585
UPLOAD_FAILED_MSG = (
@@ -121,7 +121,7 @@ def run(self):
121121
self.status(NO_GS_MESSAGE)
122122
if run_status:
123123
if os.system(PUBLISH_COMMAND) != 0:
124-
self.status(UPLOAD_FAILED_MSG % PUBLISH_COMMAND)
124+
self.status(UPLOAD_FAILED_MSG)
125125

126126
sys.exit()
127127

tests/requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
nose
2-
mock
2+
mock;python_version<"3"
33
codecov
44
coverage
55
flake8

tests/test_gitfs_opener.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import fs
2-
from mock import patch
32
from nose.tools import ok_
43
from gitfs2.repo import GitRequire
54

5+
try:
6+
from mock import patch
7+
except ImportError:
8+
from unittest.mock import patch
9+
610

711
@patch("gitfs2.repo.git_clone")
812
def test_opener(fake_clone):

0 commit comments

Comments
 (0)