-
Notifications
You must be signed in to change notification settings - Fork 39
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
Cannot apply HunkHeader on Windows #49
Comments
Failed to execute goal com.cosium.code:git-code-format-maven-plugin:2.1:on-pre-commit (default-cli) on project scaffold: org.eclipse.jgit.api.errors.PatchApplyException: Cannot apply: HunkHeader[11,7->11,6] -> [Help 1] plugin version: 2.4 I can run the manual command successful, but when i try to commit and the hook trigger the automatic formatting, it brakes with the above error. the same look like another issue #42 |
This is a long standing and hard to debug Windows specific issue. So I hope one of the impacted people will give it a shot. After all, the plugin is written in java and we are all java developers here :) |
I try to fix it, but it doesn't seem easy. As the author said, this is a problem caused by the combination of lf and CRLF , so change the IDE's line separator to lf. and set the git config below: git config --global core.autocrlf true
git config --global core.safecrlf true add git rm --cached -r .
git reset --hard it will update the repositroy files line separator to lf |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
I managed to resolve this in windows using this methods. Not sure why it works though. git stash push git stash pop Somehow the HunkHeader issue is gone for my case. |
Personnally I'm still struggle with this issue:
|
Using Git Bash / shopt -s globstar
unix2dos -v **/*.java |
I am getting the below error.
Failed to execute goal com.cosium.code:git-code-format-maven-plugin:2.4:on-pre-commit (default-cli) on project qe-jira-soap: org.eclipse.jgit.api.errors.PatchApplyException: Cannot ap
ply: HunkHeader[1,9->1,5] -
I have added -X to the pre-commit script and here is the error log.
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.cosium.code:git-code-format-maven-plugin:2.4:on-pre-commit (default-cli) on project qe-jira-soap: org.eclips
e.jgit.api.errors.PatchApplyException: Cannot apply: HunkHeader[1,9->1,5]
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: org.eclipse.jgit.api.errors.PatchApplyException: Cannot apply: HunkHeader[1,9->1,5]
at com.cosium.code.format.OnPreCommitMojo.doExecute(OnPreCommitMojo.java:25)
at com.cosium.code.format.AbstractModuleMavenGitCodeFormatMojo.execute(AbstractModuleMavenGitCodeFormatMojo.java:66)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more
Caused by: com.cosium.code.format.MavenGitCodeFormatException: org.eclipse.jgit.api.errors.PatchApplyException: Cannot apply: HunkHeader[1,9->1,5]
at com.cosium.code.format.git.GitStagedFiles.format(GitStagedFiles.java:97)
at com.cosium.code.format.OnPreCommitMojo.onPreCommit(OnPreCommitMojo.java:30)
at com.cosium.code.format.OnPreCommitMojo.doExecute(OnPreCommitMojo.java:22)
... 23 more
Caused by: org.eclipse.jgit.api.errors.PatchApplyException: Cannot apply: HunkHeader[1,9->1,5]
at org.eclipse.jgit.api.ApplyCommand.apply(ApplyCommand.java:224)
at org.eclipse.jgit.api.ApplyCommand.call(ApplyCommand.java:138)
at com.cosium.code.format.git.GitStagedFiles.format(GitStagedFiles.java:92)
... 25 more
I am using CLI, Git version 2.23.0, Windows, Plugin version 2.4. I have a parent pom and added it to that, i am using again in a sub project and this is a multi module project.
The text was updated successfully, but these errors were encountered: