Murmele / Gittyup

Understand your Git history!
https://murmele.github.io/Gittyup
MIT License
1.49k stars 110 forks source link

Support more Git hooks #261

Open alex-ball opened 2 years ago

alex-ball commented 2 years ago

I am running Gittyup v1.1.2 on Ubuntu 20.04 via flatpak.

Expected behaviour: In a Git repo with executable files at .git/hooks/pre-commit and .git/hooks/post-commit, committing some changes should run those two scripts immediately before and after the commit, respectively.

Actual behaviour: The commit succeeds but the two files do not execute.

I'm afraid I don't know enough about these things to know if

  1. this is a security limitation of flatpaks and can only be solved by installing some other way;
  2. this can be solved by editing the app permissions;
  3. this is a bug in the code;
  4. this would be an enhancement.

I have not tested whether the other Git hooks are triggered (by push, receive, etc.).

exactly-one-kas commented 2 years ago

Currently, only the pre-push hook is supported, although I'm not sure if this works with flatpak. @Murmele do you know if flatpak needs additional permissions to execute programs outside its sandbox even if they're within opened directories?

exactly-one-kas commented 2 years ago

Also, the pre-push requires bash for some reason? I think this restriction should be lifted

Murmele commented 2 years ago

currently for the merge commands we are leaving the flatpak sandbox. there we are using flatpak-spawn --host sh -c "<command>" to execute a command on the host system. It works withouth any additional permissions

Murmele commented 2 years ago

It depends on what is written in the script. If some host commands are used then it will not work (or only if executed from host). If just common commands are used I have to check

Murmele commented 2 years ago

@exactly-one-kas how it behaves without sandbox? Do I have to do chmod +x first on those files, or is git able to execute them without?

exactly-one-kas commented 2 years ago

Git calls them as executables and requires the executable bit to be set, so I'd say we should use flatpack-spawn --host "<path to hook>"

Murmele commented 2 years ago

Git calls them as executables and requires the executable bit to be set, so I'd say we should use flatpack-spawn --host "<path to hook>"

yes I think that makes it easier. The question is are we then going around some sandboxing features?

exactly-one-kas commented 2 years ago

Since we're running arbitrary scripts on the host, I'd say yes. Can we run them inside the sandbox or is that prevented?

Murmele commented 2 years ago

I think that should be also possible.

lonix1 commented 3 months ago

For future consideration: I think .git/hooks/pre-commit is the most common/useful, so if there's much work to support each type of hook, it's best to start with the most important one.

schnedann commented 1 month ago

I just implemented a prepare-commit-hook and learned gittyup does not execute it. I see this functionality as very important, as the hooks are one of the few ways to mitigate some of the worst design fails of git...

So from me: please, hooks are important, please implement