Open savchenko opened 4 months ago
It seems your repro steps are not correct:
you say you create mkdir .githooks
but then you create ./githooks/pre-commit
(which is a subtle but very different folder name). if I fix this and create the pre-commit hook inside the path you configure: .githooks/pre-commit
then gitui correct blocks the commit.
why in your case git rejects and gitui does not is beyond me
@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 gitui
correctly triggers the hook only when launched from the root folder (git rev-parse --show-toplevel
).
Corresponding log record:
12:16:35 [TRACE] (1) git2_hooks::hookspath: [git2-hooks/src/hookspath.rs:114] run hook '".githooks/pre-commit"' in '"/home/user/foo/"'
And here is the successful attempt to commit the same file from one of the subfolders (e.g. /home/user/foo/src
)
12:22:10 [ERROR] theme error ["/home/user/.config/gitui/theme.ron"]: 24:35: Failed to parse Colors: data did not match any variant of untagged enum ColorFormat
12:22:10 [TRACE] (1) gitui::app: [src/app.rs:154] open repo at: RefCell { value: Path(".") }
12:22:10 [TRACE] (6) mio::poll: [/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/poll.rs:551] registering event source with poller: token=Token(0), interests=READABLE
12:22:10 [TRACE] (6) mio::poll: [/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/poll.rs:551] registering event source with poller: token=Token(1), interests=READABLE
12:22:10 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:102] request: [hash: 5275764462638972305] (type: WorkingDir)
12:22:10 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:102] request: [hash: 4542120333235219920] (type: Stage)
12:22:10 [TRACE] (2) asyncgit::status: [asyncgit/src/status.rs:160] status fetched: 5275764462638972305 (type: WorkingDir)
12:22:10 [TRACE] (4) asyncgit::status: [asyncgit/src/status.rs:160] status fetched: 4542120333235219920 (type: Stage)
12:22:10 [TRACE] (1) gitui: [src/main.rs:215] app start: 21 ms
12:22:10 [TRACE] (1) gitui::app: [src/app.rs:375] update
12:22:10 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:102] request: [hash: 7094696850961575051] (type: WorkingDir)
12:22:10 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:102] request: [hash: 12783852074258472187] (type: Stage)
12:22:10 [TRACE] (2) asyncgit::status: [asyncgit/src/status.rs:160] status fetched: 7094696850961575051 (type: WorkingDir)
12:22:10 [TRACE] (4) asyncgit::status: [asyncgit/src/status.rs:160] status fetched: 12783852074258472187 (type: Stage)
12:22:10 [TRACE] (1) gitui::app: [src/app.rs:395] update_async: Git(Status)
12:22:10 [TRACE] (1) gitui::app: [src/app.rs:395] update_async: Git(Status)
12:22:10 [TRACE] (1) gitui::app: [src/app.rs:395] update_async: Git(Status)
12:22:10 [TRACE] (1) gitui::app: [src/app.rs:395] update_async: Git(Status)
12:22:11 [TRACE] (1) gitui::app: [src/app.rs:278] event: Input(Key(KeyEvent { code: Char('w'), modifiers: KeyModifiers(0x0), kind: Press, state: KeyEventState(0x0) }))
12:22:11 [TRACE] (1) asyncgit::diff: [asyncgit/src/diff.rs:101] request DiffParams { path: "foo.py", diff_type: Stage, options: DiffOptions { ignore_whitespace: false, context: 3, interhunk_lines: 0 } }
12:22:11 [TRACE] (1) gitui::app: [src/app.rs:395] update_async: Git(Diff)
12:22:11 [TRACE] (1) asyncgit::diff: [asyncgit/src/diff.rs:101] request DiffParams { path: "foo.py", diff_type: Stage, options: DiffOptions { ignore_whitespace: false, context: 3, interhunk_lines: 0 } }
12:22:11 [TRACE] (1) gitui::app: [src/app.rs:278] event: Input(Key(KeyEvent { code: Char('c'), modifiers: KeyModifiers(0x0), kind: Press, state: KeyEventState(0x0) }))
12:22:11 [TRACE] (1) gitui::app: [src/app.rs:278] event: Input(Key(KeyEvent { code: Char('R'), modifiers: KeyModifiers(SHIFT), kind: Press, state: KeyEventState(0x0) }))
12:22:12 [TRACE] (1) gitui::app: [src/app.rs:278] event: Input(Key(KeyEvent { code: Char('o'), modifiers: KeyModifiers(0x0), kind: Press, state: KeyEventState(0x0) }))
12:22:12 [TRACE] (1) gitui::app: [src/app.rs:278] event: Input(Key(KeyEvent { code: Char('g'), modifiers: KeyModifiers(0x0), kind: Press, state: KeyEventState(0x0) }))
12:22:12 [TRACE] (1) gitui::app: [src/app.rs:278] event: Input(Key(KeyEvent { code: Char('u'), modifiers: KeyModifiers(0x0), kind: Press, state: KeyEventState(0x0) }))
12:22:12 [TRACE] (1) gitui::app: [src/app.rs:278] event: Input(Key(KeyEvent { code: Char('e'), modifiers: KeyModifiers(0x0), kind: Press, state: KeyEventState(0x0) }))
12:22:12 [TRACE] (1) gitui::app: [src/app.rs:278] event: Input(Key(KeyEvent { code: Char('!'), modifiers: KeyModifiers(0x0), kind: Press, state: KeyEventState(0x0) }))
12:22:14 [TRACE] (1) gitui::app: [src/app.rs:278] event: Input(Key(KeyEvent { code: Char('d'), modifiers: KeyModifiers(CONTROL), kind: Press, state: KeyEventState(0x0) }))
12:22:14 [TRACE] (1) gitui::app: [src/app.rs:375] update
12:22:14 [TRACE] (1) asyncgit::diff: [asyncgit/src/diff.rs:101] request DiffParams { path: "foo.py", diff_type: Stage, options: DiffOptions { ignore_whitespace: false, context: 3, interhunk_lines: 0 } }
12:22:14 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:102] request: [hash: 17309038260000894423] (type: WorkingDir)
12:22:14 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:102] request: [hash: 9501808690652183810] (type: Stage)
12:22:14 [TRACE] (4) asyncgit::status: [asyncgit/src/status.rs:160] status fetched: 9501808690652183810 (type: Stage)
12:22:14 [TRACE] (5) asyncgit::status: [asyncgit/src/status.rs:160] status fetched: 17309038260000894423 (type: WorkingDir)
12:22:14 [TRACE] (1) gitui::app: [src/app.rs:395] update_async: Git(Diff)
12:22:14 [TRACE] (1) gitui::app: [src/app.rs:395] update_async: Git(Status)
12:22:14 [TRACE] (1) gitui::app: [src/app.rs:395] update_async: Git(Status)
12:22:14 [TRACE] (1) gitui::app: [src/app.rs:278] event: Input(Key(KeyEvent { code: Char('c'), modifiers: KeyModifiers(CONTROL), kind: Press, state: KeyEventState(0x0) }))
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: