Permalink
Browse files

init contribute and githooks

  • Loading branch information...
1 parent bc86cd5 commit 7b77a62bffa4f503672dbfdb73a10de2ec1b7daf Hsiaoming Yang committed Jan 4, 2013
Showing with 117 additions and 19 deletions.
  1. +37 −0 CONTRIBUTING.md
  2. +24 −17 Makefile
  3. +5 −2 dev-requirements.txt → dev-reqs.txt
  4. +3 −0 scripts/githooks/post-merge
  5. +48 −0 scripts/githooks/pre-commit
View
@@ -0,0 +1,37 @@
+# Contributing
+
+First, please do contribute! There are three ways to contribute:
+
+1. introduce june to your friends
+2. discuss june, and submit bugs with github issues
+3. send patch with github pull request
+
+
+## Codebase
+
+You should follow the code style
+
+A little hint to make things simple:
+
+- when you cloned this repo, run `make`, it will prepare everything for you
+- check the code style with `make lint`
+- check the test case with `make testing`
+
+
+## Git Help
+
+Something you should know about git.
+
+- don't add any code on the master branch, create a new one
+- don't add too many code in on pull request
+
+Hint of git:
+
+```
+$ git branch [feature-name]
+$ git checkout [feature-name]
+```
+
+## Checklist
+
+We are still on development, and this is a total rewrite of june in flask.
View
@@ -1,55 +1,62 @@
# Makefile for project June
-
.PHONY: clean-pyc clean-build docs
+all: install
+ @cp scripts/githooks/* .git/hooks/
+ @chmod -R +x .git/hooks/
+
# Development
install:
- pip install -r dev-requirements.txt
+ @pip install -r dev-reqs.txt
server:
- python june/app.py
+ @python june/app.py
database:
- python syncdb.py
+ @python syncdb.py
# translate
babel-extract:
- pybabel extract -F babel.cfg -o messages.pot .
+ @pybabel extract -F babel.cfg -o messages.pot .
babel-init:
- pybabel init -i messages.pot -d june/translations -l zh
+ @pybabel init -i messages.pot -d june/translations -l zh
babel-compile:
- pybabel compile -d june/translations
+ @pybabel compile -d june/translations
babel-update: babel-extract
- pybabel update -i messages.pot -d june/translations
+ @pybabel update -i messages.pot -d june/translations
# Common Task
clean: clean-build clean-pyc
clean-build:
- rm -fr build/
- rm -fr dist/
- rm -fr *.egg-info
+ @rm -fr build/
+ @rm -fr dist/
+ @rm -fr *.egg-info
clean-pyc:
- find . -name '*.pyc' -exec rm -f {} +
- find . -name '*.pyo' -exec rm -f {} +
- find . -name '*~' -exec rm -f {} +
+ @find . -name '*.pyc' -exec rm -f {} +
+ @find . -name '*.pyo' -exec rm -f {} +
+ @find . -name '*~' -exec rm -f {} +
+
+files := $(shell find . -name '*.py' ! -path "*docs/*")
+lint:
+ @flake8 ${files}
# Sphinx Documentation
docs:
- $(MAKE) -C docs html
+ @$(MAKE) -C docs html
# Deployment
# Git
github:
- git push origin flask
+ @git push origin flask
testing:
- nosetests -v
+ @nosetests -v
@@ -6,7 +6,7 @@ pygments
# database
Flask-SQLAlchemy
-#MySQL-python
+MySQL-python
# cache support
Flask-Cache
@@ -17,11 +17,14 @@ Flask-Babel
# form support
#Flask-WTF
--e hg+https://bitbucket.org/simplecodes/wtforms#egg=WTForms
+WTForms
-e git+git://github.com/lepture/flask-wtf.git#egg=Flask-WTF
# mail support
Flask-Mail
# testing
nose
+
+# lint
+flake8
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+make
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+function failCommit() {
+ tput setaf 1
+ echo "----------------------------------------"
+ echo "FATAL ERROR: $1"
+ echo "----------------------------------------"
+ tput sgr0
+ exit 1
+}
+
+
+if git-rev-parse --verify HEAD >/dev/null 2>&1 ; then
+ against=HEAD
+else
+ # Initial commit: diff against an empty tree object
+ against=bbd0d0446c4c4c97f2a72406d9540ca1e2d68c3f
+fi
+
+# Remove all of the trailing whitespace in this commit
+for FILE in `exec git diff-index --check --cached $against -- | sed '/^[+-]/d' | sed -E 's/:[0-9]+:.*//' | uniq` ; do
+ sed -i '' -E 's/[[:space:]]*$//' "$FILE"
+ git add $FILE
+done
+
+echo 'Running flake8...'
+result=$(make lint)
+if [ $? != 0 ]; then
+ echo "$result"
+ echo ''
+ echo 'lint fail'
+ lintFailed=1
+ failCommit "Lint Errors"
+fi
+
+echo 'Running Tests...'
+result=$(make testing)
+if [ $? != 0 ]; then
+ echo "$result"
+ echo ''
+ echo 'Tests fail'
+ testsFailed=1
+ failCommit "Test Errors"
+fi
+
+if [[ $testsFailed || $lintFailed ]]; then
+ failCommit "Unable To Commit"
+fi

0 comments on commit 7b77a62

Please sign in to comment.