Commit graph

35 commits

Author SHA1 Message Date
extrawurst
1c118d75f3
proper pre-push hook implementation (#2811) 2026-01-18 17:37:45 +01:00
xlai89
cb17cfe105
feat: support pre-push hooks (#2737)
Co-authored-by: extrawurst <776816+extrawurst@users.noreply.github.com>
2025-10-31 08:57:27 +01:00
Johannes Agricola
7f88934d05
Bump msrv to 1.81 (#2613)
Co-authored-by: Naseschwarz <naseschwarz@0x53a.de>
2025-04-16 09:21:06 +02:00
Joshix-1
711210b97b
Run git-hooks more correctly (#2483) 2025-04-15 15:01:39 +02:00
Johannes Agricola
7f75307f6e
Resolve core.hooksPath relative to GIT_WORK_TREE (#2571)
* Resolve core.hooksPath relative to GIT_WORK_TREE

git supports relative values in core.hooksPath.

`man git-config`:

> A relative path is taken as relative to the directory where the hooks are
> run (see the "DESCRIPTION" section of githooks[5]).

`man githooks`:

> Before Git invokes a hook, it changes its working directory to either
> $GIT_DIR in a bare repository or the root of the working tree in a >
> non-bare repository.

I.e. relative paths in core.hooksPath in non-bare repositories are always
relative to GIT_WORK_TREE.

There is a further exception; I believe this is not considered for path
resolution:

> An exception are hooks triggered during a push (pre-receive, update,
> post-receive, post-update, push-to-checkout) which are always executed
> in $GIT_DIR.

* Favor Repository::workdir() over path().parent()

This more clearly errors in case of bare repositories instead of using
the parent directory of the bare repository.

---------

Co-authored-by: Naseschwarz <naseschwarz@0x53a.de>
Co-authored-by: extrawurst <776816+extrawurst@users.noreply.github.com>
2025-04-04 15:28:44 +02:00
extrawurst
d7765c4239 fix doc comments to please new rust version lints 2024-10-18 18:02:02 +02:00
extrawurst
e7c61ffc89
Support prepare commit hook (#1978) 2023-12-16 00:07:54 +01:00
extrawurst
521ab91309
git2-hooks: allows customizing what places to look for hooks (#1975)
* allows customizing what places to look for hooks
2023-12-08 14:33:22 +01:00
extrawurst
d4dd58f6ca
move git hooks support into separate crate (#1971)
* unique error type name
* git2 dependency future 
* return hook out/err separately
2023-12-07 16:28:52 +01:00
extrawurst
83df6ddbc8 test that proved hook has access to PATH (#1967) 2023-12-02 13:21:33 +01:00
hamflx
5411397f9a
Fix commit hooks error and "no such file" error on Windows with wsl2 installed. (#1532)
* use git bash instead of wsl bash
* add unittest for some simple shell commands.
* fix incompatible unitest with macOS
2023-02-02 10:33:57 +01:00
Alexandru Macovei
6b5745f6c2
Fix Clippy Lints (#1390)
* apply latest nigtly clippy lints
* temporarily disable const fn lints due to nigh false positive count on nightly
2022-10-19 13:45:12 +02:00
extrawurst
c1cb868c4b fix nightly clippy 2022-07-02 08:17:15 +02:00
Stephan Dilly
435de9cda3
support hookspath (#1054) 2022-01-17 15:06:54 +01:00
Stephan Dilly
10b4704662
run hooks in correct pwd (#1049)
see #1046
2021-12-17 00:46:08 +01:00
Stephan Dilly
55b9877e93 use .git path instead of workdir finding hooks
fixes #1046
2021-12-15 15:33:09 +01:00
Stephan Dilly
006cdd6373
support bare repos (#1028) 2021-12-05 00:35:45 +01:00
Stephan Dilly
dad8e8d43d cargo fmt: use hardtabs
since it does not support hard-whitespaces its the only way to make whitespaces consisitent and checked
2021-08-17 14:24:25 +02:00
Stephan Dilly
f0a367c3f5
more linting (#647) 2021-04-17 23:17:19 +02:00
Stephan Dilly
53b2c79877
even more clippy restrtictions (#646)
* even more clippy restrtictions
2021-04-17 18:55:59 +02:00
Stephan Dilly
00073cbdd7 fix hook panicking (#393) 2020-11-01 12:46:59 +01:00
Stephan Dilly
632f255548 cleanup some more expects 2020-11-01 02:11:55 +01:00
pm100
99c3277e94
adding pre-commit hook (#386)
see #313
2020-11-01 01:06:48 +01:00
Stephan Dilly
4f2e20ea1b changelog update 2020-08-18 21:48:59 +02:00
dr-BEat
ce8d79855d Fix Command::new behaviour on windows 2020-08-18 21:28:55 +02:00
Stephan
4a442f3829 cleanup use 2020-06-29 12:30:10 +02:00
Stephan Dilly
97560564c9 run hooks from workdir and not from current dir (closes #151) 2020-06-25 08:14:43 +02:00
Stephan Dilly
b66d385a8f sort order 2020-06-25 07:47:10 +02:00
Stephan Dilly
1c03458de7 merge uses 2020-05-19 23:11:28 +02:00
Mehran Kordi
19a0cb2db6
Implement git hook support on windows
closes #14
2020-05-16 19:08:44 +02:00
Mehran Kordi
03505b9eb6
Replace unwrap calls in asyncgit with error handling - closes #53 2020-05-15 15:15:26 +02:00
Stephan Dilly
d2d69063e3 cleanup 2020-04-09 12:05:42 +02:00
Stephan Dilly
b9ac1865db support altering commit-msg on ok hook 2020-04-09 11:13:02 +02:00
Stephan Dilly
f144d97e0c fix debug state ment leftover 2020-04-09 09:36:10 +02:00
Stephan Dilly
36ff0be9d1
support hooks: post-commit,commit-msg (#15)
* support hooks: post-commit and commit-msg
* some unittests
* exclude tests on windows for now
2020-04-09 09:23:59 +02:00