Closed ultrr closed 2 years ago
I don't totally understand what is the problem!? Since husky doesn't change the file states.
how do you add your files to git in the first place (staging step)? Your reproducible example doesn't do anything because nothing is staged yet.
also, I've tried git add test.txt
to stage a file:
everything was normal except weird behavior from reglint tool (I have no idea why it is scanning my entire system and found a different project !)
If you think this is a husky-related bug, please remove other third-party tools and give me a reproducible example.
thanks
My bad! Forgot to include the output. Managed to recreate the issue on a fresh solution, with usage of Husky.Net only.
Link to the repo with said solution: https://github.com/ultrr/husky.net-staged-bug
Steps to reproduce:
dotnet restore
echo someContent123 >> file1.txt
echo someOtherContent123 >> file2.txt
git add file1.txt file2.txt
git commit -m "test"
Output:
[Husky] 🚀 Loading tasks ...
--------------------------------------------------
[Husky] ⚡ Preparing task 'before-echo-staged'
[Husky] ⌛ Executing task 'before-echo-staged' ...
file1.txt file2.txt
[Husky] ✔ Successfully executed in 2ms
--------------------------------------------------
[Husky] ⚡ Preparing task 'cp'
[Husky] ⌛ Executing task 'cp' ...
[Husky] ✔ Successfully executed in 9ms
--------------------------------------------------
[Husky] ⚡ Preparing task 'after-echo-staged'
[Husky] ⌛ Executing task 'after-echo-staged' ...
file1.txt 26c27_file2.txt file2.txt
[Husky] ✔ Successfully executed in 1ms
--------------------------------------------------
[Husky] ⚡ Preparing task 'git'
[Husky] ⌛ Executing task 'git' ...
[Husky] ✔ Successfully executed in 8ms
--------------------------------------------------
[master 059d397] test
3 files changed, 3 insertions(+), 2 deletions(-)
create mode 100644 63c0e_file2.txt
git status
output:
On branch master
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
deleted: 63c0e_file2.txt
no changes added to commit (use "git add" and/or "git commit -a")
Hi, Thank you for the repo
because in this case, you want to control git indexing situation to prevent husky interference I've added a new option -p
to the run command that you can use in v0.4.2
:
So you just need to update your run command to:
dotnet husky run -p
Version
0.4.0
Details
I was running a git hook with several steps configured. I was expecting only REAL staged files to be committed but unfortunately there were some additional staged files which shouldn't be added to ${staged} variable.
Steps to reproduce
task-runner.json
git add ${staged}
afterregitlint
but it results in committing those temporary files as well.