-
-
Notifications
You must be signed in to change notification settings - Fork 609
Pre-commit hooks are executed only when launched from the git root #2281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@extrawurst , a typo, fixed the original message. Git picks it up as it is configured to do so, in the local config: [core]
hooksPath = .githooks/ Turns out Corresponding log record:
And here is the successful attempt to commit the same file from one of the subfolders (e.g.
|
+1, the pre-commit hooks are run only when |
I'd like to work on this if no one already is. |
I cannot reproduce this issue on my end, as gitui runs the Using the nightly 2025-01-14 build, macOS Sequoia, rustc 1.85.0. Is this still an issue for you @savchenko @saiabishek1? Am I following the reproduction steps correctly? |
@wessamfathi could you add a unit test for this in any case - we already have a few for hooks, should be easy to cover (in case we don’t have one maybe already for this subfolder thing) |
I checked the hook test and it appears that there is one that does that job already Let me know if you mean something else and I'll do it. I'll try to test on Windows as well, but I cannot get OpenSSL to build no matter what I do. |
Yeah I felt we had made a test for this already in the past. If you could get it tested on windows that would be awesome |
The test passes on Windows 👍 |
@savchenko ok will close it as non-reproducible for now. feel free to reopen if this is still a problem on the most recent release |
@extrawurst , I can reliably reproduce it with gitui v0.27 on Debian 13 (testing). What data would help you to pinpoint the issue? |
Hi @savchenko: I've just tried to reproduce this using a fresh debian 13 container from docker.io, gitui 0.27 downloaded from the releases and the steps to reproduce from your initial issue. My commit is rejected as expected: Could you potentially create a syscall trace for us?
... then try to commit in your test repo and upload In case you don't want to publish such a long log, I suggest you create a private repository, upload it there and invite me and anybody else who's interested. |
@naseschwarz , reproduction steps:
#!/bin/env bash
set -euo pipefail
cd "$(git rev-parse --show-toplevel)" || exit 1
file_types=("txt")
flag="foo"
staged_files=$(git diff --cached --name-only --diff-filter=ACM)
is_excluded() {
git check-ignore -q "$1"
return $?
}
if [ -n "$staged_files" ]; then
for type in "${file_types[@]}"; do
files=$(echo "$staged_files" | grep "\.$type$" || echo "")
if [ -z "$files" ]; then
continue
fi
for file in $files; do
if ! is_excluded "$file"; then
if ! head -n 5 "$file" | grep -q "$flag"; then
echo "[ERROR] $file is missing the flag."
exit 1
fi
fi
done
done
fi
The above will result in
The commit will succeed. Please find the |
Thanks, I can reproduce this now. |
@wessamfathi, do you still want to take care of this? I don't want to do a hostile takeover here. ;) However, I've put together a failing test: d59f168. The failure is due to a combination of two conditions, which was not obvious based on the original steps to reproduce, but is now:
|
@naseschwarz oh no worries! Feel free to take it. You're already on track, and now it feels a little bit over my head :) I'll find something else for sure. |
Describe the bug
Pre-commit hook is ignored.
To Reproduce
Steps to reproduce the behavior:
mkdir .githooks && git config --local core.hooksPath .githooks
.githooks/pre-commit
withecho "Hook triggered" && exit 1
andchmod +x
it.git commit
now fails, as expected.gitui
ignores the hook.Expected behavior
pre-commit
behaviour is the same when usinggit
CLI.Screenshots
N/A.
Context (please complete the following information):
Debian 12
gitui 0.25.2
rustc 1.76.0
Additional context
Relates to:
The text was updated successfully, but these errors were encountered: