diff options
author | Joris Roovers <jroovers@cisco.com> | 2015-09-02 13:18:52 -0700 |
---|---|---|
committer | Joris Roovers <jroovers@cisco.com> | 2015-09-02 13:18:52 -0700 |
commit | ef164b13985a0dd134228e10d894817209575c99 (patch) | |
tree | ef08ca74fd359671e27e23c1e49ed5c58ec8af8c | |
parent | 765a4427f80ccdda61bc78e2680bda14787b2a4e (diff) |
Initial commit
- setup.py
- travis integration
- README
- Vagrantfile
- run_tests.sh
- gitignore
- requirements.txt
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | .travis.yml | 7 | ||||
-rw-r--r-- | MANIFEST.in | 6 | ||||
-rw-r--r-- | README.md | 50 | ||||
-rw-r--r-- | Vagrantfile | 24 | ||||
-rw-r--r-- | examples/commit-message-1 | 3 | ||||
-rw-r--r-- | gitlint/__init__.py | 1 | ||||
-rw-r--r-- | requirements.txt | 3 | ||||
-rwxr-xr-x | run_tests.sh | 71 | ||||
-rw-r--r-- | setup.py | 49 | ||||
-rw-r--r-- | test-requirements.txt | 3 |
11 files changed, 219 insertions, 0 deletions
@@ -55,3 +55,5 @@ docs/_build/ # PyBuilder target/ + +.venv/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..c0addcb --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: python +python: + - "2.7" +install: + - "pip install -r requirements.txt" + - "pip install -r test-requirements.txt" +script: "./run_tests.sh && ./run_tests.sh --pep8" diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..b893666 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,6 @@ +include README.md +include LICENSE +exclude Vagrantfile +exclude *.yml *.sh *.txt +recursive-exclude examples * +recursive-exclude gitlint/tests *
\ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..aaabfec --- /dev/null +++ b/README.md @@ -0,0 +1,50 @@ +# gitlint + +[![Build Status](https://travis-ci.org/jorisroovers/gitlint.svg?branch=master)] +(https://travis-ci.org/jorisroovers/gitlint) +[![PyPi Package](https://img.shields.io/pypi/v/gitlint.png)] +(https://pypi.python.org/pypi/gitlint) + +Git linter written in python. + +**NOTE: gitlint is still under active development and missing many core features** + +NOTE: The returned exit code equals the number of errors found. + +Other commands and variations: + +```bash +Usage: gitlint [OPTIONS] PATH + +Git lint tool, checks your git commit messsages for styling issues + +Options: + --config PATH Config file location (default: .markdownlint). + --ignore TEXT Ignore rules (comma-separated by id or name). + --version Show the version and exit. + --help Show this message and exit. +``` + +You can modify pymarkdownlint's behavior by specifying a config file like so: +```bash +markdownlint --config myconfigfile +``` +By default, markdownlint will look for an **optional** ```.markdownlint``` file for configuration. + +## Development ## + +To run tests: +```bash +./run_tests.sh # run unit tests and print test coverage +./run_tests.sh --no-coverage # run unit tests without test coverage +./run_tests.sh --pep8 # pep8 checks +./run_tests.sh --stats # print some code stats +``` + +There is a Vagrantfile in this repository that can be used for development. +```bash +vagrant up +vagrant ssh +``` + +## Wishlist ## diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..0ad753e --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,24 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +VAGRANTFILE_API_VERSION = "2" + +INSTALL_DEPS=<<EOF +sudo apt-get update +sudo apt-get install -y python-pip python-virtualenv git ipython +cd /vagrant +virtualenv .venv +source .venv/bin/active +pip install -r requirements.txt +pip install -r test-requirements.txt +EOF + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + + config.vm.box = "ubuntu/trusty64" + + config.vm.define "dev" do |dev| + dev.vm.provision "shell", inline: " echo 'cd /vagrant' >> /home/vagrant/.bashrc && #{INSTALL_DEPS}" + end + +end diff --git a/examples/commit-message-1 b/examples/commit-message-1 new file mode 100644 index 0000000..9f455a7 --- /dev/null +++ b/examples/commit-message-1 @@ -0,0 +1,3 @@ +WIP: This is the title of a commit message. +The second line should typically be empty +Lines typically need to have a max length, meaning that they can't exceed a preset number of characters, usually 80 or 120.
\ No newline at end of file diff --git a/gitlint/__init__.py b/gitlint/__init__.py new file mode 100644 index 0000000..b97eff9 --- /dev/null +++ b/gitlint/__init__.py @@ -0,0 +1 @@ +__version__ = "0.1.0dev"
\ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..bc36612 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +pip==7.1.0 +setuptools +Click==4.1
\ No newline at end of file diff --git a/run_tests.sh b/run_tests.sh new file mode 100755 index 0000000..c1daedb --- /dev/null +++ b/run_tests.sh @@ -0,0 +1,71 @@ +#!/bin/bash -e + + +help(){ + echo "Usage: $0 [OPTION]..." + echo "Run pymarkdownlint's test suite(s) or some convience commands" + echo " -h, --help Show this help output" + echo " -p, --pep8 Run pep8 checks" + echo " -l, --lint Run pylint checks" + echo " -s, --stats Show some project stats" + echo " --no-coverage Don't make a unit test coverage report" + echo "" + exit 0; +} + +run_pep8_check(){ + # FLAKE 8 + # H307: like imports should be grouped together + # H405: multi line docstring summary not separated with an empty line + # H803: git title must end with a period + # H904: Wrap long lines in parentheses instead of a backslash + # H802: git commit title should be under 50 chars + # H701: empty localization string + FLAKE8_IGNORE="H307,H405,H803,H904,H802,H701" + # exclude settings files and virtualenvs + FLAKE8_EXCLUDE="*settings.py,*.venv/*.py" + echo "Running flake8..." + flake8 --ignore=$FLAKE8_IGNORE --max-line-length=120 --exclude=$FLAKE8_EXCLUDE pymarkdownlint +} + +run_unit_tests(){ + OMIT=".venv/*" + coverage run --omit=$OMIT -m unittest discover -v + if [ $include_coverage -eq 1 ]; then + COVERAGE_REPORT=$(coverage report -m) + echo "$COVERAGE_REPORT" + fi +} + +run_stats(){ + echo "*** Code ***" + radon raw -s pymarkdownlint | tail -n 6 +} + +# default behavior +just_pep8=0 +just_lint=0 +just_stats=0 +include_coverage=1 + +while [ "$#" -gt 0 ]; do + case "$1" in + -h|--help) shift; help;; + -p|--pep8) shift; just_pep8=1;; + -l|--lint) shift; just_lint=1;; + -s|--stats) shift; just_stats=1;; + --no-coverage)shift; include_coverage=0;; + esac +done + +if [ $just_pep8 -eq 1 ]; then + run_pep8_check + exit $? +fi + +if [ $just_stats -eq 1 ]; then + run_stats + exit $? +fi + +run_unit_tests || exit diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..c62fb9a --- /dev/null +++ b/setup.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python +from setuptools import setup, find_packages +import re +import os + +# There is an issue with building python packages in a shared vagrant directory because of how setuptools works +# in python < 2.7.9. We solve this by deleting the filesystem hardlinking capability during build. +# See: http://stackoverflow.com/a/22147112/381010 +del os.link + +long_description = ( + "Linter for git repositories. Under active development." + "Source code: https://github.com/jorisroovers/gitlint" +) + +# shamelessly stolen from mkdocs' setup.py: https://github.com/mkdocs/mkdocs/blob/master/setup.py +def get_version(package): + """Return package version as listed in `__version__` in `init.py`.""" + init_py = open(os.path.join(package, '__init__.py')).read() + return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1) + + +setup( + name="gitlint", + version=get_version("gitlint"), + description="Linter for git repositories. Under active development.", + long_description=long_description, + classifiers=[ + "Development Status :: 3 - Alpha", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Environment :: Console", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License" + ], + install_requires=[ + 'Click==4.1', + ], + keywords='gitlint git lint', + author='Joris Roovers', + url='https://github.com/jorisroovers/gitlint', + license='MIT', + packages=find_packages(exclude=["examples"]), + entry_points={ + "console_scripts": [ + "gitlint = gitlint.cli:cli", + ], + }, +) diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 0000000..5d0f4cf --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,3 @@ +flake8==2.4.0 +coverage==3.7.1 +radon==1.2.1 |