Skip to content

On Windows .cmd extension cause ''C:\Program' is not recognized as an internal or external command, operable program or batch file.' #53

@yl-coder

Description

@yl-coder

What steps will reproduce the problem?
Steps to reproduce the behavior:

  1. mvn git-code-format:install-hooks
  2. Change some code
  3. run git commit -m "exclude for now"
    'C:\Program' is not recognized as an internal or external command,
    operable program or batch file.

What is the expected output?
Githook should be triggered and code should be formatted
What happens instead?
Terminal output
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

Environment:

  • OS: Windows 10
  • Git version: git version 2.27.0.windows.1
  • git-code-format-maven-plugin version: 2.5

Link to a git repository that can be cloned to reproduce the problem:
This is happens on my machine only. The reason is because in ~\IdeaProjects{project_name}.git\hooks{project_name}.git-code-format.pre-commit content has a .cmd postfix which cause the prehook command to fail.

Additional context
I solved this by removing .cmd postfix in {project_name}.git-code-format.pre-commit file

Before
#!/bin/bash
set -e
"C:/Program Files/JetBrains/IntelliJ IDEA 2019.1.4/plugins/maven/lib/maven3/bin/mvn.cmd" -f "C:/Users/{home}/IdeaProjects/{project_name}/pom.xml" com.cosium.code:git-code-format-maven-plugin:on-pre-commit

After

#!/bin/bash
set -e
"C:/Program Files/JetBrains/IntelliJ IDEA 2019.1.4/plugins/maven/lib/maven3/bin/mvn" -f "C:/Users/{home}/IdeaProjects/{project_name}/pom.xml" com.cosium.code:git-code-format-maven-plugin:on-pre-commit

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions