Skip to content

Commit

Permalink
Merge pull request #22 from tony/click
Browse files Browse the repository at this point in the history
[wip] Switch CLI arguments parsing to click, refactor internals, tooling
  • Loading branch information
tony committed May 16, 2016
2 parents 31749e1 + 0cceaba commit 2dec2e9
Show file tree
Hide file tree
Showing 45 changed files with 811 additions and 696 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.venv
.venv3
*.lprof
*.pyc
*.tar.gz
*.egg-info
Expand Down
11 changes: 6 additions & 5 deletions .tmuxp.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
session_name: vcspull
before_script: ./bootstrap_env.py # ./ to load relative to project root
start_directory: ./ # load session relative to config location (project root).
before_script: ./bootstrap_env.py # ./ to load relative to project root.
windows:
- window_name: vcspull
focus: True
layout: main-horizontal
focus: true
options:
main-pane-height: 35
shell_command_before:
- '[ -d .venv -a -f .venv/bin/activate ] && source .venv/bin/activate'
panes:
- focus: true
- pane
- if command -v entr > /dev/null; then find . -type f -not -path '*/\.*' | grep -i '.*[.]py$' | entr -c ./run-tests.py; else ./run-tests.py; echo "\nInstall entr(1) to automatically run tests on file change.\n See http://entrproject.org/"; fi
- make watch_test

- window_name: docs
layout: main-horizontal
options:
Expand All @@ -23,5 +24,5 @@ windows:
panes:
- focus: true
- pane
- echo 'docs built to <http://0.0.0.0:8002/_build/html>'; python -m SimpleHTTPServer 8002
- if command -v entr > /dev/null; then find .. -print | grep -i '.*[.]rst' | entr -c make html; else make html; echo "\nInstall entr(1) to automatically rebuild documentation when files change. \nSee http://entrproject.org/"; fi
- make serve
- make watch
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
language: python
sudo: false
python:
- 2.6
- 2.7
- 3.3
- 3.4
- 3.5
before_install:
- export PIP_USE_MIRRORS=true
- pip install -U pip setuptools
- pip install coveralls
- git config --global user.name 'travis-ci'
- git config --global user.email 'travis@nowhere.edu'
Expand Down
29 changes: 28 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,39 @@ Here you can find the recent changes to vcspull
CURRENT
-------

Breaking Changes:

- [cli] [internal]: command line arg parsing now uses `click`_ library.
- [cli]: The command to update repositories is now ``vcspull u``,
``vcspull up`` or ``vcspull update``::

$ vcspull up neovim
$ vcspull up neovim vim django
- [cli] vcspull will use the beginning part of the argument to determine
if its searching by vcs URL, repository name or system path.
- [config] ``repo`` (the longform for the vcs url) is now ``url``.
- [config] [internal] repos are now passed around in a list of
:py:`dict`. :class:`vcspull.config.expand_config` has been
simplified.
- [internal] flake8 and sort imports
- [internal] [dev] Add ``Makefile`` for ``watch_test`` (re-running
tests on file change), ``watch_flake`` (re-running flake8 check
on changes)
- [internal] [dev] Move ``.tmuxp.yaml`` commands to use Makefile
- [internal] [dev] split up requirements into ``requirements/``
folder.
- Drop Python 2.6 support
- [internal] ``find_config`` renamed to ``find_config_files``.
- Rename ``get_repos`` to ``filter_repos``, simplify argument signature.
- [cli] Experimental support for concurrently synchroniznig repos via
:py:mod:`multiprocessing`.
- [api][internal]: Refactor :class:`vcspull.repo.Repo` factory class
into :func:`vcspull.repo.create_repo`.
- [internal]: major internal cleanup of dead code, pep8 style updates.
- [git] [ tests]: fix git+https remotes `#14`_, add regression tests.
- [git] [tests]: fix git+https remotes `#14`_, add regression tests.

.. _#14: https://github.com/tony/vcspull/issues/14
.. _click: https://github.com/pallets/click

0.2.2
-----
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include README.rst LICENSE CHANGES run-tests.py .tmuxp.yaml
include requirements.pip package_metadata.py
include requirements/*.txt package_metadata.py
recursive-include doc *.rst
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
test:
./run-tests.py

watch_test:
if command -v entr > /dev/null; then find . -type f -not -path '*/\.*' | grep -i '.*[.]py' | entr -c make test; else make test; echo "\nInstall entr(1) to automatically run tests on file change.\n See http://entrproject.org/"; fi

build_docs:
cd doc && $(MAKE) html

watch_docs:
cd doc && $(MAKE) watch_docs

flake8:
flake8 vcspull

watch_flake8:
if command -v entr > /dev/null; then find . -type f -not -path '*/\.*' | grep -i '.*[.][py]' | entr -c make flake8; else make flake8; echo "\nInstall entr(1) to automatically run tests on file change.\n See http://entrproject.org/"; fi


.PHONY: flake8
22 changes: 17 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Clone and update your repositories at any time:

.. code-block:: bash
$ vcspull
$ vcspull up
Have a lot of projects? Use arguments to clone / update what you need.

Expand All @@ -48,11 +48,23 @@ Use `fnmatch`_:
.. code-block:: bash
# any repo starting with "fla"
$ vcspull "fla*"
# inside of a directory with "co" anywhere, on github.
$ vcspull -d "*co*" -r "*github.com*" "fla*"
$ vcspull up "fla*"
# any repo with django in the name
$ vcspull up "*django*"
# search by vcs + url
# since urls are in this format <vcs>+<protocol>://<url>
$ vcspull up "git+*"
# any git repo with python in the vcspull
$ vcspull up "git+*python*
# any git repo with django in the vcs url
$ vcspull up "git+*django*
# all repositories in your ~/code directory
vcspull up "$HOME/code/*"
Python API Usage
----------------

Expand Down
52 changes: 40 additions & 12 deletions bootstrap_env.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#!/usr/bin/env python

from __future__ import (
absolute_import, division, print_function, with_statement, unicode_literals
)
from __future__ import (absolute_import, division, print_function,
unicode_literals, with_statement)

import os
import sys
import subprocess
import platform
import sys


def warning(*objs):
Expand All @@ -22,7 +20,7 @@ def fail(message):
if PY2:
from urllib import urlretrieve
else:
from urllib.request import urlretrieve
from urllib.request import urlretrieve # noqa


def has_module(module_name):
Expand Down Expand Up @@ -81,11 +79,15 @@ def which(exe=None, throw=True):
virtualenv_bin = which('virtualenv', throw=False)
virtualenv_exists = os.path.exists(env_dir) and os.path.isfile(python_bin)
entr_bin = which('entr', throw=False)
sphinx_requirements_filepath = os.path.join(project_dir, 'doc', 'requirements.pip')
nvim_bin = which('nvim', throw=False)
dev_reqs_fpath = os.path.join(project_dir, 'requirements', 'dev.txt')
test_reqs_fpath = os.path.join(project_dir, 'requirements', 'test.txt')
test27_reqs_fpath = os.path.join(project_dir, 'requirements', 'test-py27.txt')
sphinx_reqs_fpath = os.path.join(project_dir, 'requirements', 'doc.txt')


try:
import virtualenv
import virtualenv # noqa
except ImportError:
message = (
'Virtualenv is required for this bootstrap to run.\n'
Expand All @@ -96,7 +98,7 @@ def which(exe=None, throw=True):


try:
import pip
import pip # noqa
except ImportError:
message = (
'pip is required for this bootstrap to run.\n'
Expand Down Expand Up @@ -127,18 +129,44 @@ def main():
)
print(message)

if not os.path.isfile(os.path.join(env_dir, 'bin', 'mock')):
# neovim requires this to be installed in the virtualenv 05/13/2016
if nvim_bin:
try:
import neovim # noqa
except ImportError:
subprocess.check_call(
[pip_bin, 'install', 'neovim']
)

try:
import testfixtures # noqa
import mock # noqa
except ImportError:
subprocess.check_call(
[pip_bin, 'install', '-r', test_reqs_fpath]
)

if sys.version_info < (2, 7):
try:
import unittest2 # noqa
except ImportError:
subprocess.check_call(
[pip_bin, 'install', '-r', test27_reqs_fpath]
)

if not os.path.isfile(os.path.join(env_dir, 'bin', 'flake8')):
subprocess.check_call(
[pip_bin, 'install', 'mock']
[pip_bin, 'install', '-r', dev_reqs_fpath]
)

if not os.path.isfile(os.path.join(env_dir, 'bin', 'sphinx-quickstart')):
subprocess.check_call(
[pip_bin, 'install', '-r', sphinx_requirements_filepath]
[pip_bin, 'install', '-r', sphinx_reqs_fpath]
)

if os.path.exists(os.path.join(env_dir, 'build')):
os.removedirs(os.path.join(env_dir, 'build'))

if __name__ == '__main__':
main()

10 changes: 10 additions & 0 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,13 @@ doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."

checkbuild:
rm -rf $(BUILDDIR)
$(SPHINXBUILD) -n -q ./ $(BUILDDIR)

watch:
if command -v entr > /dev/null; then find . -type f -not -path '*/\.*' | grep -i '.*[.]rst' | entr -c make html; else make html; echo "\nInstall entr(1) to automatically run tests on file change.\n See http://entrproject.org/"; fi

serve:
echo 'docs built to <http://0.0.0.0:8002/_build/html>'; python -m SimpleHTTPServer 8002
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys, os

import os
import sys

# Get the project root dir, which is the parent dir of this
cwd = os.getcwd()
Expand Down
32 changes: 15 additions & 17 deletions doc/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,46 +54,44 @@ Now run the command, to pull all the repositories in your

.. code-block:: bash
$ vcspull
$ vcspull up
You can also use `fnmatch`_ to pull repositories from your config in
various fashions, e.g.:

.. code-block:: bash
$ vcspull django
$ vcspull django\*
$ vcspull up django
$ vcspull up django\*
# or
$ vcspull "django*"
$ vcspull up "django*"
Filter by vcs URL:
Filter by vcs URL

Any repo beginning with ``http``, ``https`` or ``git`` will be look up
repos by the vcs url.

.. code-block:: bash
# pull / update repositories I have with github in the repo url
$ vcspull -r "*github*"
$ vcspull up "git+https://github.com/yourusername/*"
# pull / update repositories I have with bitbucket in the repo url
$ vcspull -r "*bitbucket*"
$ vcspull up "git+https://*bitbucket*"
Filter by the path of the repo on your local machine:

Any repo beginning with ``/``, ``./``, ``~`` or ``$HOME`` will scan
for patterns of where the project is on your system[

.. code-block:: bash
# pull all the repos I have inside of ~/study/python
$ vcspull -d "$HOME/study/python"
$ vcspull up "$HOME/study/python"
# pull all the repos I have in directories on my config with "python"
$ vcspull -d "*python*"
Mix them all:

.. code-block:: bash
$ vcspull up ~/*python*"
# Repos with "python" in the name of the directory, on github.com,
# with sql* in the name.
$ vcspull -d "*python*" -r "*github.com*" "sql*"
.. _pip vcs url: http://www.pip-installer.org/en/latest/logic.html#vcs-support
.. _flask: http://flask.pocoo.org/
.. _fnmatch: http://pubs.opengroup.org/onlinepubs/009695399/functions/fnmatch.html
1 change: 1 addition & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-r ../requirements/doc.txt
6 changes: 3 additions & 3 deletions examples/christmas-tree.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
docutils: svn+http://svn.code.sf.net/p/docutils/code/trunk
~/github_projects/:
kaptan:
repo: git+https://github.com/emre/kaptan
url: git+https://github.com/emre/kaptan
remotes:
upstream: git+https://github.com/emre/kaptan
marksteve: git+https://github.com/marksteve/kaptan.git
tony: git+git@github.com:tony/kaptan.git
~:
.vim:
repo: git+git@github.com:tony/vim-config.git
url: git+git@github.com:tony/vim-config.git
.tmux:
repo: git+git@github.com:tony/tmux-config.git
url: git+git@github.com:tony/tmux-config.git
2 changes: 1 addition & 1 deletion examples/remotes.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
~/workspace/:
kaptan:
repo: git+https://github.com/emre/kaptan
url: git+https://github.com/emre/kaptan
remotes:
upstream: git+https://github.com/emre/kaptan
marksteve: git+https://github.com/marksteve/kaptan.git
Expand Down
4 changes: 0 additions & 4 deletions requirements.pip

This file was deleted.

4 changes: 4 additions & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
kaptan==0.5.8
pyyaml==3.11
colorama==0.3.7
click==6.6 # Updated from 6.2
2 changes: 2 additions & 0 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
flake8==2.5.4
vulture==0.8.1
2 changes: 1 addition & 1 deletion doc/requirements.pip → requirements/doc.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-r ../requirements.pip
-r ./base.txt
sphinx
sphinx-argparse>=0.1.4
sphinx_rtd_theme
2 changes: 2 additions & 0 deletions requirements/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
testfixtures==4.9.1 # Updated from 4.7.0
mock==2.0.0
1 change: 1 addition & 0 deletions run-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
# -*- coding: utf-8 -*-

from vcspull.testsuite import main

main()
Loading

0 comments on commit 2dec2e9

Please sign in to comment.