Windows Compatibility Fix for Git Pre-push Hook#2562
Merged
nedtwigg merged 6 commits intodiffplug:releasefrom Jul 21, 2025
Merged
Windows Compatibility Fix for Git Pre-push Hook#2562nedtwigg merged 6 commits intodiffplug:releasefrom
nedtwigg merged 6 commits intodiffplug:releasefrom
Conversation
cbe5b74 to
2ed283b
Compare
lazer-dev
commented
Jul 21, 2025
| } | ||
|
|
||
| @Test | ||
| public void should_execute_pre_push_script() throws Exception { |
Contributor
Author
There was a problem hiding this comment.
Not sure how to do the same test for Gradle. To properly validate that the script works, a real Gradle wrapper would need to be present in the temp folder to run the plugin with the new changes — which doesn’t seem easy to set up.
Do you think checking it with Maven is sufficient?
Member
There was a problem hiding this comment.
Yeah, I think just Maven is sufficient.
840f2d2 to
a4af9c5
Compare
a4af9c5 to
222085b
Compare
Member
|
Published in |
chaidat86
approved these changes
Aug 2, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes execution issues of the generated Git hook on Windows systems.
What's changed
System.getProperty("os.name").toLowerCase().startsWith("win")mvnw.cmd / gradlew.baton Windows instead of plainmvnw / gradlew./mvnw.cmd, ./gradlew.bat) for better portability and shell compatibilitymvnorgradleif wrapper is not foundFile.getAbsolutePath()returns backslashes () that are not valid in POSIX-compliant sh scripts used by Git hooksWhy
On Windows, Git hooks are executed via sh (e.g., Git Bash), which does not recognize
.cmdwithout an explicit extension and correct formatting.Additionally, absolute paths on Windows (e.g.,
D:\project\mvnw.cmd) use backslashes, which causeD:projectmvnw.cmd command not founderrors in shell scripts.These changes ensure consistent behavior across platforms and make the Git hook portable and reliable.