Skip to content

HUSKY_GIT_PARAMS not complete at Windows/cygwin #735

@amjmhs

Description

@amjmhs

HUSKY_GIT_PARAMS are not correctly provided to a node-process for prepare-commit-message.

OS: Windows 10
Shell: cygwin
Node: 12.16.1
Husky: 4.2.5

"prepare-commit-msg": "node bin/prepare-commit-msg/git-commit-template.js"

bin/prepare-commit-msg/git-commit-template.js
---------------------------------------------

#!/usr/bin/env node

console.dir(process.env.HUSKY_GIT_PARAMS);

Output:

$ git commit
husky > prepare-commit-msg (node v12.16.1)
'.git/COMMIT_EDITMSG'

$ git commit               (with existing commit.template-setting)
husky > prepare-commit-msg (node v12.16.1)
'.git/COMMIT_EDITMSG'

$ git commit -m "foobar"
husky > prepare-commit-msg (node v12.16.1)
'.git/COMMIT_EDITMSG'

$ git commit --amend
husky > prepare-commit-msg (node v12.16.1)
'.git/COMMIT_EDITMSG'

Expected Output:

$ git commit
husky > prepare-commit-msg (node v12.16.1)
'.git/COMMIT_EDITMSG'

$ git commit               (with existing commit.template-setting)
husky > prepare-commit-msg (node v12.16.1)
'.git/COMMIT_EDITMSG template'

$ git commit -m "foobar"
husky > prepare-commit-msg (node v12.16.1)
'.git/COMMIT_EDITMSG message'

$ git commit --amend
husky > prepare-commit-msg (node v12.16.1)
'.git/COMMIT_EDITMSG commit HEAD'

Am I doing something wrong here?

I think the root-cause is at the .git/hooks/husky.sh - Line 17
"$@" husky-run $hookName "$gitParams"
should be
"$@" husky-run $hookName \"$gitParams\"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions