Skip to content

Commit

Permalink
Merge 9ae33ba into be6ca9f
Browse files Browse the repository at this point in the history
  • Loading branch information
lovato committed Jul 11, 2018
2 parents be6ca9f + 9ae33ba commit ba74b24
Show file tree
Hide file tree
Showing 22 changed files with 242 additions and 101 deletions.
9 changes: 9 additions & 0 deletions .hooks4git.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[scripts]
flake8 = flake8 --max-line-length=120 --exclude .git,build,dist,.env,.venv
nosetests = nosetests --with-coverage

[hooks.pre-commit.scripts]
check.py = flake8

[hooks.pre-push.scripts]
tests.py = nosetests
1 change: 0 additions & 1 deletion .hooks4git.yml

This file was deleted.

2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include LICENSE
include requirements.txt
include hooks4git/build.info
include hooks4git/.hooks4git.yml
include hooks4git/.hooks4git.ini
include LICENSE
include README.md

Expand Down
45 changes: 26 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

# hooks4git

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Build Status](https://travis-ci.org/lovato/hooks4git.svg?branch=master)](https://travis-ci.org/lovato/hooks4git)
[![Coverage Status](https://coveralls.io/repos/github/lovato/hooks4git/badge.svg?branch=master)](https://coveralls.io/github/lovato/hooks4git?branch=master)
[![PyPI version](https://badge.fury.io/py/hooks4git.svg)](https://badge.fury.io/py/hooks4git)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Fully configurable language agnostic git hooks.
Fully configurable language-agnostic git hooks.

Auto checks your code before you ship it. Works with any programmning language.
Auto checks your code before you ship it. Works with any programmning language. If not, let me know.

## Availability

Production module is available from https://test.pypi.org/project/hooks4git/, and development branch is also published by Travis-CI to https://test.pypi.org/project/hooks4git/. Both are provided as EGG packages, since there is a Post Install section which creates the hook files on your local directory. Wheel packaging is not intented to do that.
Production module is available from https://pypi.org/project/hooks4git/, and development branch is also published by Travis-CI to https://test.pypi.org/project/hooks4git/. Both are provided as EGG packages, since there is a Post Install section which creates the hook files on your local directory. Wheel packaging is not intented to do that.

Both can be downloaded and installed via the pip command.

Expand Down Expand Up @@ -48,30 +48,32 @@ If by any reason you already have any of the target files on your harddrive, thi

### Usage

After activation, your repo is hooked for all events.
After execution or installation, your repo is hooked for all events. Prior version used YAML for configuration management, but that caused PyYAML to be a dependency, and things went a little wrong when running it as a tool. So I choose .ini files over .json files (both have Python native parsers) because it looked less ugly.

You just need to open <a href="./.hooks4git.yml">.hooks4git.yml</a> file on the root of your project and configure it the way you want.
Example section is meant for Python, but you can use any tool you want, at any given git hook event.
You just need to open <a href="./.hooks4git.ini">.hooks4git.ini</a> file on the root of your project and configure it the way you want.
This first example section is meant for Python, but you can use any tool you want, at any given git hook event.

Example section for pre-commit, for Python:

```
hooks:
pre-commit:
scripts:
# - echo Running "pre-commit" hook
- flake8 --max-line-length=120 --exclude .git,__pycache__,build,dist
[scripts]
flake8 = flake8 --max-line-length=120 --exclude .git,build,dist,.env,.venv
nosetests = nosetests --with-coverage
[hooks.pre-commit.scripts]
check = flake8
```

But it could be for NodeJS:
It also could be for NodeJS:

```
hooks:
pre-commit:
scripts:
# - echo Running "pre-commit" hook
- eslint server.js
- jshint *.js
[scripts]
eslint = eslint -f checkstyle index.js > checkstyle-result.xml
jshint = jshint *.js
[hooks.pre-commit.scripts]
check_a = eslint
check_b = jslint
```

Note: All scripts you add here need to be available on your PATH for execution. So you need to make all of them depedencies on your current project, no matter the language it is written with. Per default, the available hooks are only `echo` commands, which will always pass!
Expand All @@ -92,6 +94,11 @@ TIME | Execution took 0:00:00.684762
PASS | All green! Good!
```

## Final Notes

This is supposed to run fine on Windows too, BUT windows has no native support for GIT, and this is a GIT tool, not a Python tool.
So, make sure you run this on the same command prompt you use to perform your git commands. Do not use it on `cmd.exe`.

## License

This project is licensed under MIT license. See the <a href="./LICENSE">LICENSE</a> file for details
Expand Down
2 changes: 1 addition & 1 deletion hooks4git/.codacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ engines:
exclude_paths:
- config/engines.yml
exclude_paths:
- tests/**
- '**/tests/**'
32 changes: 32 additions & 0 deletions hooks4git/.hooks4git.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[scripts]
echo = echo Wheeee! Running a hook!
flake8 = flake8 --max-line-length=120 --exclude .git,build,dist,.env,.venv
nosetests = nosetests --with-coverage
eslint = eslint -f checkstyle index.js > checkstyle-result.xml

[hooks.pre-commit.scripts]
msg = echo
# check.py = flake8

[hooks.pre-push.scripts]
msg = echo
# check.py = flake8
# tests.py = nosetests

[hooks.applypatch-msg]

[hooks.commit-msg]

[hooks.fsmonitor-watchman]

[hooks.post-update]

[hooks.pre-applypatch]

[hooks.prepare-commit-msg]

[hooks.pre-rebase]

[hooks.pre-receive]

[hooks.update]
38 changes: 0 additions & 38 deletions hooks4git/.hooks4git.yml

This file was deleted.

2 changes: 1 addition & 1 deletion hooks4git/git/hooks/applypatch-msg
2 changes: 1 addition & 1 deletion hooks4git/git/hooks/commit-msg
1 change: 1 addition & 0 deletions hooks4git/git/hooks/fsmonitor-watchman
2 changes: 1 addition & 1 deletion hooks4git/git/hooks/post-update
2 changes: 1 addition & 1 deletion hooks4git/git/hooks/pre-applypatch
2 changes: 1 addition & 1 deletion hooks4git/git/hooks/pre-commit
2 changes: 1 addition & 1 deletion hooks4git/git/hooks/pre-push
2 changes: 1 addition & 1 deletion hooks4git/git/hooks/pre-rebase
1 change: 1 addition & 0 deletions hooks4git/git/hooks/pre-receive
2 changes: 1 addition & 1 deletion hooks4git/git/hooks/prepare-commit-msg
2 changes: 1 addition & 1 deletion hooks4git/git/hooks/update
Loading

0 comments on commit ba74b24

Please sign in to comment.