Skip to content

Commit da9ab4f

Browse files
committed
readme: add documentation + bump version
1 parent 932a9d6 commit da9ab4f

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ Save the following file under .git/hooks/pre-commit and make it executable to te
144144
runhooks('pre-commit', hooks=[validateunittestpass])
145145
```
146146

147+
147148
Installation
148149
-
149150
You can use pip:
@@ -159,6 +160,26 @@ sudo python setup.py install
159160
sudo pip install mercurial
160161
```
161162

163+
User Guide
164+
-
165+
166+
Once you have installed the library, you can start writing you first hook.
167+
You can start by taking one of the example as a template.
168+
Your hook's check function will get called with a log and a revdata object.
169+
The check function should return True if the hook passes and False otherwise.
170+
The log object can be used to send feedback to the user, for example, if your hook rejects a commit, you can explain what justifies the rejection.
171+
The revdata object allows you to get all the information that you need to make the decision of returning True or False from your hook. It contains different information based on what hook you are writing and it is based on what git or hg gives as argument and environment variable when calling the hook.
172+
For example, if you are writing a `commit-msg` hook, `revdata.messagefile` will be the filename of the file containing the commit message to validate.
173+
You can get the complete list of the accessible fields by looking at the documentation of the class for the hook in question.
174+
For example, if you want to know the field available in `revdata` for the `pre-commit` hook for git. Look into `hooklib_git.py`, find the class `gitprecommitinputparser` and look at its pydoc:
175+
176+
In a python shell:
177+
178+
```
179+
>>> from hooklib_git import *
180+
>>> help(gitprecommitinputparser)
181+
```
182+
162183
Contributing
163184
-
164185
Before sending a Pull-Request please run the tests:

hooklib_input.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
1-
from hooklib_git import gitpostupdateinputparser
2-
from hooklib_git import gitupdateinputparser
3-
from hooklib_git import gitprecommitinputparser
4-
from hooklib_git import gitpreapplypatchinputparser
5-
from hooklib_git import gitapplypatchmsginputparser
6-
from hooklib_git import gitpostapplypatchinputparser
7-
from hooklib_git import gitcommitmsginputparser
8-
from hooklib_git import gitpostcommitinputparser
9-
from hooklib_git import gitprepushinputparser
10-
from hooklib_git import gitprerebaseinputparser
11-
from hooklib_git import gitpreautogcinputparser
12-
from hooklib_git import gitprereceiveinputparser
13-
from hooklib_git import gitpostreceiveinputparser
14-
from hooklib_git import gitpreparecommitmsginputparser
15-
from hooklib_hg import hgupdateinputparser
1+
from hooklib_git import *
2+
from hooklib_hg import *
163
import os
174
import sys
185

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setup(
1010
name="hooklib",
11-
version="0.2",
11+
version="0.2.1",
1212
author="Laurent Charignon",
1313
author_email="l.charignon@gmail.com",
1414
description="Hook helper library in python",

0 commit comments

Comments
 (0)