| ... | ... |
@@ -29,6 +29,11 @@ effort to accomodate these (specifically, it copies standard in to all the |
| 29 | 29 |
scripts if it is not a terminal, simply lets standard out/error through, and |
| 30 | 30 |
returns with the first error code that is non-zero). |
| 31 | 31 |
|
| 32 |
+`git-multihook` can be run manually, in which case it parses `man githooks` and |
|
| 33 |
+creates the symlinks and directories mentioned above (you probably want to |
|
| 34 |
+place it in the [hooks path][] first). A list of hooks to skip can be given as |
|
| 35 |
+arguments. |
|
| 36 |
+ |
|
| 32 | 37 |
[githooks]: https://git-scm.com/docs/githooks |
| 33 | 38 |
[hooks path]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-corehooksPath |
| 34 | 39 |
[`$GIT_DIR`]: https://www.git-scm.com/docs/git#Documentation/git.txt-codeGITDIRcode |
| ... | ... |
@@ -2,7 +2,37 @@ |
| 2 | 2 |
|
| 3 | 3 |
Manage multiple [Git hooks][githooks] with ease. |
| 4 | 4 |
|
| 5 |
+Git doesn't allow you to use multiple scripts as hooks for a single action out |
|
| 6 |
+of the box. `git-multihook` is meant to be placed in the Git [hooks path][] |
|
| 7 |
+(which is [`$GIT_DIR`][]`/hooks` by default, but can be changed to a |
|
| 8 |
+centralized location with e.g. `git config --global core.hooksPath |
|
| 9 |
+'~/.githooks'`) and be the symlink target of (multiple) standard [Git |
|
| 10 |
+hooks][githooks] in that directory. When the hook is run it delegates to, |
|
| 11 |
+potentially multiple, (executable) scripts in subdirectories with names on the |
|
| 12 |
+form `${hook}.d`.
|
|
| 13 |
+ |
|
| 14 |
+For example, splitting the [`pre-commit.sample`][] that comes bundled with Git |
|
| 15 |
+into two scripts would look something like this: |
|
| 16 |
+ |
|
| 17 |
+``` |
|
| 18 |
+.git/hooks |
|
| 19 |
+├── git-multihook |
|
| 20 |
+├── pre-commit -> git-multihook |
|
| 21 |
+└── pre-commit.d |
|
| 22 |
+ ├── nonascii |
|
| 23 |
+ └── diffcheck |
|
| 24 |
+``` |
|
| 25 |
+ |
|
| 26 |
+Note that hooks have different interfaces (with regards to standard |
|
| 27 |
+in/out/error, return values, etc) and `git-multihook` only makes a general best |
|
| 28 |
+effort to accomodate these (specifically, it copies standard in to all the |
|
| 29 |
+scripts if it is not a terminal, simply lets standard out/error through, and |
|
| 30 |
+returns with the first error code that is non-zero). |
|
| 31 |
+ |
|
| 5 | 32 |
[githooks]: https://git-scm.com/docs/githooks |
| 33 |
+[hooks path]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-corehooksPath |
|
| 34 |
+[`$GIT_DIR`]: https://www.git-scm.com/docs/git#Documentation/git.txt-codeGITDIRcode |
|
| 35 |
+[`pre-commit.sample`]: https://github.com/git/git/blob/master/templates/hooks--pre-commit.sample |
|
| 6 | 36 |
|
| 7 | 37 |
## License |
| 8 | 38 |
|