Skip to content
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

Run git-hooks more correctly #2483

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Joshix-1
Copy link
Contributor

@Joshix-1 Joshix-1 commented Jan 15, 2025

This Pull Request fixes #2482.

It changes the following:

  • Improve how git-hooks get run

I followed the checklist:

  • I added unittests
  • I ran make check without errors
  • I tested the overall application
  • I added an appropriate item to the changelog

Didn't test this on Windows

@Joshix-1 Joshix-1 force-pushed the git-hooks-shell-fix branch from 859aa5a to 2d90eb5 Compare January 15, 2025 19:11
@extrawurst
Copy link
Owner

Is there any way to write a test for this?

@Joshix-1
Copy link
Contributor Author

Joshix-1 commented Jan 15, 2025

In GitoxideLabs/gitoxide@51bbb86#diff-b1f4fc8d8a8a51923a922a937745a1f5665443821b5c4df58efa44c7c4515216 there is a check if the file returned by path() exists. But that isn't really a useful test.

Maybe there could be some sort of integration test that creates a git-repo with hooks that then runs run_hook. But that wouldn't really help as that would only test one setup and this is about making it work on as many setups as possible.

@extrawurst
Copy link
Owner

Maybe there could be some sort of integration test that creates a git-repo with hooks that then runs run_hook

we do exactly that in the hooks unittests

@Joshix-1
Copy link
Contributor Author

running the tests with SHELL=false or something like that, would check that the SHELL variable is ignored, but I'm not sure if that's helpful

@Joshix-1
Copy link
Contributor Author

Why is -l added to the shell args?

git only adds -c /~https://github.com/git/git/blob/757161efcca150a9a96b312d9e780a071e601a03/run-command.c#L294-L306 and if i see that correctly it doesn't use string concatenation to provide arguments to the script.

@Joshix-1 Joshix-1 marked this pull request as draft January 15, 2025 20:52
@Joshix-1 Joshix-1 changed the title use /bin/sh for git-hooks Run git-hooks more correctly Jan 15, 2025
@Joshix-1 Joshix-1 marked this pull request as ready for review January 15, 2025 21:47
@Joshix-1
Copy link
Contributor Author

I think on non-Windows platforms it's best to just execute the hooks directly. I don't see a reason to use a shell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

git-hooks fail
2 participants