Closed SunilDSK closed 10 months ago
Hi @SunilDSK, I don't see it as a bug since I didn't fully understand what do you expect Husky does for you?
if you wanna prevent commits if appsettings.Development.json
is staged I would suggest to use the task-runner
instead.
something like: e.g pre-commit file
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
dotnet husky run -v --group "pre-commit"
task-runner.json
{
"tasks": [
{
"name": "Verify staged files",
"group": "pre-commit",
"include": "appsettings.Development.json",
"command": "cmd",
"args": ["/c", "git reset appsettings.Development.json & exit 1", "${staged}"]
}
]
}
This would automatically unstage the appsettings.Development.json
file if it is staged and prevent the commits including this file.
also using taks-runner makes your console log prettier :)
Version
0.6.0
Details
I have a webapi project with environment specific appsettings.json file. I don't want the
appsettings.Development.json
to be committed or pushed(its already tracked). I have a pre-commit hook with one command -git reset appsettings.Development.json
. When I haveappsettings.Development.json
as only file, the pre-commit is unstaging theappsettings.Development.json
file, but it is also creating an empty commit with no files. How do I avoid the empty commit?Steps to reproduce
$ dotnet husky add pre-commit -c "git reset appsettings.Development.json"
.appsettings.Development.json
.appsettings.Development.json
file and create an empty commit.