Skip to content

Commit

Permalink
Merge pull request #8 from moremoban/dev
Browse files Browse the repository at this point in the history
🥚 🎡 release 0.0.3
  • Loading branch information
chfw authored Dec 11, 2019
2 parents 00da96b + a0dea03 commit b5d6056
Show file tree
Hide file tree
Showing 19 changed files with 168 additions and 34 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Upload Python Package

on:
release:
types: [created]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
8 changes: 6 additions & 2 deletions .moban.d/CUSTOM_README.rst.jj2
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,14 @@ Checkout submodules recursively
Does it write?
--------------------------------------------------------------------------------

Yes locally, it will write as you can do so without using gitfs2. And no, it does help
commit and push the changes for you.
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.

License
--------------------------------------------------------------------------------

MIT

{% endblock %}
21 changes: 21 additions & 0 deletions .moban.d/mit_license.jj2
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) {{copyright_year}} {{company}}

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 1 addition & 1 deletion .moban.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ targets:
- setup.py: custom_setup.py.jj2
- requirements.txt: requirements.txt.jj2
- "tests/requirements.txt": "tests/custom_requirements.txt.jj2"
- "docs/source/conf.py": "docs/conf.py_t"
- "gitfs2/_version.py": "_version.py.jj2"
- .gitignore: gitignore.jj2
- .travis.yml: travis.yml.jj2
Expand All @@ -17,3 +16,4 @@ targets:
configuration: changelog.yml
template: CHANGELOG.rst.jj2
- lint.sh: lint.script.jj2
- LICENSE: mit_license.jj2
14 changes: 10 additions & 4 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
Change log
================================================================================

0.0.3 - 11.12.2019
--------------------------------------------------------------------------------

**Added**

#. `#5 <https://github.com/moremoban/gitfs2/issues/5>`_: support offline
#. `#7 <https://github.com/moremoban/gitfs2/issues/7>`_: add license text

0.0.2 - 2.10.2019
--------------------------------------------------------------------------------

Fix
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
**Fixed**

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

0.0.1 - 19.08.2019
--------------------------------------------------------------------------------

first release
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
**first release**

#. what a feat!
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2019 moban dev team

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
include README.rst
include CHANGELOG.rst
include LICENSE

18 changes: 14 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ gitfs2
.. image:: https://codecov.io/github/moremoban/gitfs2/coverage.png
:target: https://codecov.io/github/moremoban/gitfs2

.. image:: https://badge.fury.io/py/gitfs2.svg
:target: https://pypi.org/project/gitfs2

.. image:: https://pepy.tech/badge/gitfs2/month
:target: https://pepy.tech/project/gitfs2/month


.. image:: https://dev.azure.com/moremoban/gitfs2/_apis/build/status/moremoban.gitfs2?branchName=master
:target: https://dev.azure.com/moremoban/gitfs2/_build/latest?definitionId=2&branchName=master
Expand All @@ -28,7 +34,7 @@ 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.2"\n__author__ = "C.W."\n'
'__version__ = "0.0.3"\n__author__ = "C.W."\n'
Get from a different branch
Expand All @@ -39,7 +45,7 @@ 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.2"\n__author__ = "C.W."\n'
'__version__ = "0.0.3"\n__author__ = "C.W."\n'
Checkout submodules recursively
Expand All @@ -53,11 +59,15 @@ Checkout submodules recursively
Does it write?
--------------------------------------------------------------------------------

Yes locally, it will write as you can do so without using gitfs2. And no, it does help
commit and push the changes for you.
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.

License
--------------------------------------------------------------------------------

MIT


Installation
Expand Down
9 changes: 8 additions & 1 deletion changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ name: gitfs2
organisation: moremoban
releases:
- changes:
- action: Fix
- action: Added
details:
- "`#5`: support offline"
- "`#7`: add license text"
version: 0.0.3
date: 11.12.2019
- changes:
- action: Fixed
details:
- "`#4`: failed to checkout more than one git repo."
version: 0.0.2
Expand Down
6 changes: 3 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

Expand All @@ -20,9 +20,9 @@
copyright = ''
author = 'C.W.'
# The short X.Y version
version = '0.0.2'
version = '0.0.3'
# The full version, including alpha/beta/rc tags
release = '0.0.2'
release = '0.0.3'

# -- General configuration ---------------------------------------------------

Expand Down
6 changes: 3 additions & 3 deletions gitfs2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ organisation: "moremoban"
author: "C.W."
contact: "wangc_2011@hotmail.com"
company: "moban dev team"
version: "0.0.2"
current_version: "0.0.2"
release: "0.0.2"
version: "0.0.3"
current_version: "0.0.3"
release: "0.0.3"
copyright_year: 2019
license: MIT
dependencies:
Expand Down
2 changes: 1 addition & 1 deletion gitfs2/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "0.0.2"
__version__ = "0.0.3"
__author__ = "C.W."
7 changes: 6 additions & 1 deletion gitfs2/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
PROGRAM_NAME = "gitfs2"
REPOS_DIR_NAME = "repos"

MESSAGE_INVALID_GIT_URL = 'An invalid git url: "%s" in mobanfile'
MESSAGE_INVALID_GIT_URL_FMT = 'An invalid git url: "%s" in mobanfile'
MESSAGE_GIT_COMMAND_PROBLEM = "Unable to run git commands. Offline?"
MESSAGE_FOUND_REPO_FMT = "Found local checkout in %s"
MESSAGE_UPDATE_SUBMODULE = "updating submodule"
MESSAGE_CHECKOUT_SUBMODULE = "checking out submodule"
MESSAGE_GIT_CLONE_FMT = "git clone %s"
DEFAULT_CLONE_DEPTH = 2
4 changes: 3 additions & 1 deletion gitfs2/opener.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ def open_fs(self, fs_url, parse_result, writeable, create, cwd):
submodule=parse_result.params.get("submodule"),
reference=parse_result.params.get("reference"),
)

local_folder = repo.git_clone(
require, action_required=GitFSOpener.update_registry.get(git_url, True)
require,
action_required=GitFSOpener.update_registry.get(git_url, True),
)
if GitFSOpener.update_registry.get(git_url, True):
GitFSOpener.update_registry[git_url] = False
Expand Down
18 changes: 13 additions & 5 deletions gitfs2/repo.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import os
import sys
import errno
import logging
import subprocess

import fs
import fs.path
import fs.errors
from gitfs2 import reporter, constants

LOG = logging.getLogger(__name__)


class GitRequire(object):
def __init__(
Expand Down Expand Up @@ -49,6 +52,7 @@ def convert_submodule(submodule_string):

def git_clone(require, action_required=True):
from git import Repo
from git.exc import GitCommandError

if sys.platform != "win32":
# Unfortunately for windows user, the following function
Expand All @@ -65,24 +69,28 @@ def git_clone(require, action_required=True):
if action_required:
try:
fs.open_fs(local_repo_folder)
reporter.info("Found repo in %s" % local_repo_folder)
reporter.info(constants.MESSAGE_FOUND_REPO_FMT % local_repo_folder)
repo = Repo(local_repo_folder)
repo.git.pull()
if require.reference:
repo.git.checkout(require.reference)
elif require.branch:
repo.git.checkout(require.branch)
if require.submodule:
reporter.info("updating submodule")
reporter.info(constants.MESSAGE_UPDATE_SUBMODULE)
repo.git.submodule("update")
except fs.errors.CreateFailed:
reporter.info("git clone %s" % require.git_url)
reporter.info(constants.MESSAGE_GIT_CLONE_FMT % require.git_url)
repo = Repo.clone_from(
require.git_url, local_repo_folder, **require.clone_params()
)
if require.submodule:
reporter.info("checking out submodule")
reporter.info(constants.MESSAGE_CHECKOUT_SUBMODULE)
repo.git.submodule("update", "--init")
except GitCommandError as e:
reporter.warn(constants.MESSAGE_GIT_COMMAND_PROBLEM)
LOG.warn(e)
return local_repo_folder

return local_repo_folder

Expand All @@ -95,7 +103,7 @@ def get_repo_name(repo_url):
repo = giturlparse.parse(repo_url.rstrip("/"))
return repo.name
except ParserError:
reporter.error(constants.MESSAGE_INVALID_GIT_URL % repo_url)
reporter.error(constants.MESSAGE_INVALID_GIT_URL_FMT % repo_url)
raise


Expand Down
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

NAME = "gitfs2"
AUTHOR = "C.W."
VERSION = "0.0.2"
VERSION = "0.0.3"
EMAIL = "wangc_2011@hotmail.com"
LICENSE = "MIT"
ENTRY_POINTS = {
Expand All @@ -41,7 +41,7 @@
"Python file system 2 over GitPython"
)
URL = "https://github.com/moremoban/gitfs2"
DOWNLOAD_URL = "%s/archive/0.0.2.tar.gz" % URL
DOWNLOAD_URL = "%s/archive/0.0.3.tar.gz" % URL
FILES = ["README.rst", "CHANGELOG.rst"]
KEYWORDS = [
"python",
Expand Down Expand Up @@ -78,8 +78,8 @@
}
# You do not need to read beyond this line
PUBLISH_COMMAND = "{0} setup.py sdist bdist_wheel upload -r pypi".format(sys.executable)
GS_COMMAND = ("gs gitfs2 v0.0.2 " +
"Find 0.0.2 in changelog for more details")
GS_COMMAND = ("gs gitfs2 v0.0.3 " +
"Find 0.0.3 in changelog for more details")
NO_GS_MESSAGE = ("Automatic github release is disabled. " +
"Please install gease to enable it.")
UPLOAD_FAILED_MSG = (
Expand Down Expand Up @@ -121,7 +121,7 @@ def run(self):
self.status(NO_GS_MESSAGE)
if run_status:
if os.system(PUBLISH_COMMAND) != 0:
self.status(UPLOAD_FAILED_MSG % PUBLISH_COMMAND)
self.status(UPLOAD_FAILED_MSG)

sys.exit()

Expand Down
2 changes: 1 addition & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
nose
mock
mock;python_version<"3"
codecov
coverage
flake8
Expand Down
6 changes: 5 additions & 1 deletion tests/test_gitfs_opener.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import fs
from mock import patch
from nose.tools import ok_
from gitfs2.repo import GitRequire

try:
from mock import patch
except ImportError:
from unittest.mock import patch


@patch("gitfs2.repo.git_clone")
def test_opener(fake_clone):
Expand Down
Loading

0 comments on commit b5d6056

Please sign in to comment.