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

JGit on Windows cannot use hooks that are exe files #128

Open
davidmichaelkarr opened this issue Jan 10, 2025 · 1 comment
Open

JGit on Windows cannot use hooks that are exe files #128

davidmichaelkarr opened this issue Jan 10, 2025 · 1 comment

Comments

@davidmichaelkarr
Copy link

Description

I need JGit to support git hooks on Windows that are exe files. Apparently hooks on Windows can only work in contrived situations, supposedly because the name of the file has to be exactly "commit-msg", but the name of the file will be "commit-msg.exe".

Motivation

I implemented a local git commit hook to validate commit messages, to ensure they cite a valid JIRA ticket. We are moving all of our git storage from BitBucket to Github. BitBucket has a server-side "pre-receive" hook for pushes that can be used to do this validation, but nothing like that exists for Github (Github Actions will not suffice). What I implemented works fine with command-line git, but then I discovered that it has no effect in Eclipse, and after filing an EGit ticket (eclipse-egit/egit#74), I realized that this is an issue in JGit, not EGit.

If we can't do client-side validation, we'll have to rely on a poorer choice of validating commits in builds, and if those find violations, will mean harder work for developers.

Alternatives considered

I did try storing an additional file in the hooks directory, called just "commit-msg" (empty file), thinking perhaps that would fool it, but that had no effect.

Additional context

No response

@Rossi1337
Copy link

Only indirectly by invoking your exe files from a bash script.
You can use hooks in Eclipse by doing the following.
Make sure jgit recognizes that it can run hooks. The easiest way for me was the following

  • Put C:\Program Files\Git\bin on your PATH if it is not already
  • Create an empty file C:\Program Files\Git\bin\cygpath.exe

This is needed to "trick" jgit to detect that it can run sh.exe and therefore hook scripts
That file must just be on the path. It is then not really used at all.

Now edit your commit-msg hook script and invoke your own commands in it. You need to write it as a valid shell script
You may need to put your own exe files into C:\Program Files\Git\mingw64\bin

Not tested but in theory this should work.

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

No branches or pull requests

2 participants