gitbutlerapp / gitbutler

The GitButler version control client, backed by Git, powered by Tauri/Rust/Svelte
https://gitbutler.com
Other
11.67k stars 463 forks source link

Question: Why are git hooks disabled by default? #2885

Open Timeraa opened 4 months ago

Timeraa commented 4 months ago

So far I really enjoy using GitButler but I do always find myself confused as to why git hooks are disabled by default as those ensure consistent stable/linted code.

Is there any reason behind this or am I just using it wrong?

schacon commented 4 months ago

Nope, I think it's reasonable that if the hooks exist and are executable, you expect them to be executed. I think we were hesitant to just run stuff without you knowing we would run stuff, but I think opt-out makes more sense in this case.

Timeraa commented 4 months ago

Maybe you guys should enable this setting in a future update and change it to be enabled by default and letting people know about this change? (Because it's really tedious to enable it for all my projects)

TGTGamer commented 4 months ago

I actually disagree with this change.

Take a tool like trunk.io, an amazing tool which can manage you git hooks, but it still explictictly asks to enable git hooks.

I think turning on by default in a Git Tool like this could lead to confusion with some users, leading to them blaming butler for not working when their hooks might be the thing which is incompatible. There should be an explicit understanding when the hooks are enabled which separates the hook problems from the client.

Timeraa commented 4 months ago

I don't think it would cause issues, I saw GitButler improved how it shows errors from git hooks, they only run if you set them up anyway but if your team uses git hooks and someone uses GitButler and doesn't know that they are off by default they end up committing broken code or unlinted code which in my opinion causes more issues.

I think when you first import it there should be an option which is checked by default giving the user the choice.

TGTGamer commented 4 months ago

If your team uses git hooks and someone uses GitButler and doesn't know that they are off by default

This is where my point about things breaking comes from though, I could say the reverse. Some of my team, don't understand how Git Hooks work - not fully at least - and on a few occasions when something has gone wrong, I've had users come to me with "My VSCode is broken" and it turns out to be a hook isn't playing nice and isn't well displayed to the user.


I think the key takeaway is:

Whichever way the default hooks toggle is set - it needs to be displayed to the user when initialising a project

So maybe the solution here is to add a UI element to the initialisation page asking if the user wants the hooks, then add option in a configuration file for centrally managing it.

Qix- commented 4 months ago

@schacon VSCode prompts "do you trust this repository" when you open it. We could replicate that, then store a local gitbutler.trusted=1 config value.

jhnns commented 3 months ago

I don't think that the user needs to be asked. If git is executing the hooks, I also expect GitButler to do so. I can't come up with a use case where you want regular git users to execute hooks but somehow GitButler users not.

Timeraa commented 3 months ago

I don't think that the user needs to be asked. If git is executing the hooks, I also expect GitButler to do so. I can't come up with a use case where you want regular git users to execute hooks but somehow GitButler users not.

Yeah, like why setup git hooks if you get the option to not run them by default? Like with normal git you can use --no-verify to disable them temporarily but they are on by default.