-
-
Notifications
You must be signed in to change notification settings - Fork 37
Description
Version
Seen on v0.6.4 to v0.7.1
Details
So I am trying to run csharpier as a pre commit hook and support formatting files which have been renamed in git, I opted for using a custom variable that was inspired by the ${staged} variable in the husky code.
{
"variables": [
{
"name": "staged-diff-files",
"command": "git",
"args": ["diff", "--cached", "--name-only", "--no-ext-diff", "--diff-filter=ACMRTUXB"]
}
],
"tasks": [
{
"name": "Run csharpier",
"group": "pre-commit",
"command": "dotnet",
"args": [ "csharpier", "${staged-diff-files}" ],
"include": [ "**/*.cs" ]
},
]
}I noticed that the formatting changes only appear post commit, unstaged.
When I use this instead :
{
"tasks": [
{
"name": "Run csharpier",
"group": "pre-commit",
"command": "dotnet",
"args": [ "csharpier", "${staged}" ],
"include": [ "**/*.cs" ]
},
]
}It adds the formatting to the commit as is expected with a pre commit hook.
Even when I set the variable to the exact same as in the code for the ${staged} variable using --diff-filter=AM it does not have the same behavior, it does not add the formatting changes to the commit.
Wondering if this is expected behavior with custom variables or if this is a bug.
Steps to reproduce
Set task runner json with a variable in the csharpier task, with husky running it a pre-commit hook :
{
"variables": [
{
"name": "staged-diff-files",
"command": "git",
"args": ["diff", "--cached", "--name-only", "--no-ext-diff", "--diff-filter=AM"]
}
],
"tasks": [
{
"name": "Run csharpier",
"group": "pre-commit",
"command": "dotnet",
"args": [ "csharpier", "${staged-diff-files}" ],
"include": [ "**/*.cs" ]
},
]
}Take a .cs file, change the formatting so it triggers csharpier, add it, commit it. The formatting will not be included in the commit, but will be an unstaged change after the commit, not the case when using ${staged}