Added tox support for testing pep8.

We'll process requirements.txt to install depends as needed.
Also include a hacking doc explaining what we expect.
Also, including argparse automatically breaks our automagic version
numbering, so import it in main() (slightly evil, but not terrible)

Change-Id: Ib3f65459fe2cd54ce531b7ae22935e24bd8f8920
This commit is contained in:
Monty Taylor 2012-01-26 18:33:11 -05:00
parent 0cbe5c8e91
commit 3cf55f98ac
6 changed files with 52 additions and 1 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ build
dist
git_review.egg-info
MANIFEST
.tox

16
HACKING Normal file
View File

@ -0,0 +1,16 @@
Development of git-review is managed by OpenStack's Gerrit, which can be
found at https://review.openstack.org
Instructions on submitting patches can be found at
http://wiki.openstack.org/GerritWorkflow
git-review should, in general, not depend on a huge number of external
libraries, so that installing it is a lightweight operation.
All code should be pep8-compliant. It won't merge otherwise.
A tox config file has been added for easy local testing. Just run:
tox
And it will check the code for you.

View File

@ -1,3 +1,4 @@
include requirements.txt
include README.md
include LICENSE
include AUTHORS

View File

@ -16,7 +16,6 @@ implied.
See the License for the specific language governing permissions and
limitations under the License."""
import argparse
import urllib
import json
@ -550,6 +549,8 @@ def main():
config = get_config()
usage = "git review [OPTIONS] ... [BRANCH]"
import argparse
parser = argparse.ArgumentParser(usage=usage, description=COPYRIGHT)
parser.add_argument("-t", "--topic", dest="topic",

View File

@ -33,6 +33,28 @@ class git_review_install(install):
git_review_cmdclass = {'install': git_review_install}
def parse_requirements(file_name):
requirements = []
for line in open(file_name, 'r').read().split('\n'):
if re.match(r'(\s*#)|(\s*$)', line):
continue
if re.match(r'\s*-e\s+', line):
requirements.append(re.sub(r'\s*-e\s+.*#egg=(.*)$', r'\1', line))
elif re.match(r'\s*-f\s+', line):
pass
else:
requirements.append(line)
return requirements
def parse_dependency_links(file_name):
dependency_links = []
for line in open(file_name, 'r').read().split('\n'):
if re.match(r'\s*-[ef]\s+', line):
dependency_links.append(re.sub(r'\s*-[ef]\s+', '', line))
return dependency_links
setup(
name='git-review',
version=version,
@ -46,4 +68,6 @@ setup(
url='https://launchpad.net/git-review',
scripts=['git-review'],
data_files=[('share/man/man1', ['git-review.1'])],
install_requires=parse_requirements('requirements.txt'),
dependency_links=parse_dependency_links('requirements.txt'),
)

8
tox.ini Normal file
View File

@ -0,0 +1,8 @@
[tox]
envlist = py26,py27
[testenv]
#deps = -r{toxinidir}/tools/pip-requires
deps = pep8
commands = pep8 git-review