-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Partially Staged Files #23
Comments
Hi ben, happy to hear that, you're welcome. 💓
hmm Interesting ... good point! I'll look into this soon
I didn't fully understand the question but, include is just a filtering layer not related to this problem. husky by itself doesn't re-stage any files but because it is passing the entire file to the dotnet format, any changes made by dotnet format can cause this problem. I think I should somehow exclude the unstaged parts after executing the task. thank you for the feedback |
I've done more research and this may not really be a Husky.Net issue. (Although, Husky.Net could probably help resolve the issue.) These links were VERY helpful: As a workaround I've added the following tasks. This has mostly resolved the issue. (This is definitely not ideal but seems to work.)
UPDATE: |
Thanks for sharing the links, |
I literally just ran into this and saw a possible solution here: lint-staged/lint-staged#62 This feels like somewhat of a blocking issue that users might not be aware of. |
Thanks Looks promising, I will try it today. my problem with git stash currently is the conflicts after |
Until I find a clean way to solve this problem internally, the bellow workaround using the the #!/bin/sh
. "$(dirname "$0")/_/husky.sh"
## stash all un-staged files before running the tasks
git stash -k -q
dotnet husky run --group 'pre-commit' the #!/bin/sh
. "$(dirname "$0")/_/husky.sh"
## restore recently stashed files
git cherry-pick -n -m1 -Xtheirs stash
git reset please let me know if this solved the problem. I'm still looking for a better way to handle this issue. |
The fix above solved this issue but completely broke rolling back previous commits (undo in Git Kraken). As such I've had to disable these changes. |
Do you know what commands Git Kraken is using internally to roll back previous commits? I didn't find any problem using standard git commands e.g Although I'm not gonna use the |
They allow you to do Also make sure you have stagged / unstagged files when you do this as a test case. |
I released a preview version https://www.nuget.org/packages/Husky/0.4.0-preview
My checklist
about dotnet-format: thanks for your help |
A few problems that we found in the first preview version were solved.
I'll wait for some feedback, thanks |
The |
When we partially stage a file, that means we have 2 versions of that file. one in the working directory and one in the git object database. In preview-2 husky.net saves the partial version to a temporary cache folder in |
I just tried several scenarios on
I'm currently stuck in a scenario where I cannot commit because of the following error message: |
Thanks for the feedback. 🙏
I'm struggling with this. dotnet-format is not actually like other code formatter or linters. It needs to build the project first which is sad :/.
hmm! Noted. how did it happen? can you give me reproducible examples? |
Oh nvm, my bad. I found the second problem. 😳 fixed in preview3:
|
I found a partial solution to this issue. ☝🏻
You CAN |
I could've moved the temp files(partially staged) next to the original files before running the dotnet-format. this way |
😬 I was going to suggest a |
Yeah, It doesn't solve this. Honestly, I'm not sure how critical is this problem, should I consider implementing this differently or not? I had two options:
I chose the second approach to avoid conflict problems, now I realized that dotnet-format doesn't behave nicely. 😒 I don't know what is the next step really, suggestions are welcome. |
I agree that the 2nd option is preferable. Hopefully, the dotnet format team can prioritize a fix for this issue. 🤞🏻 🤷🏻 |
☝🏻 Looks like this |
This comment has been minimized.
This comment has been minimized.
@alirezanet It's hacky but a |
Considering your suggestion I implemented a better cleaning up process, So by default, it handles temporary files. and we don't need to specify the cache location. Please try preview4 and let me know if it's working as expected. (I didn't fully test yet) dotnet tool update husky --version 0.4.0-preview-4 PS. If it works correctly for formatting purposees, I think we only need an option to switch to analyzer mode to support dotnet analyzers that usually don't change the code. Not sure yet. (the weird thing is I didn't get any compilation errors with dotnet-format 5.1.250801 !) |
Fixed in |
Hi! 👋🏻
First off -- I love this tool. Thank you for all of your hard work and effort. ❤️
I'd like to incorporate this tool into our development process but can't because of a single issue: Partial stages
For a single file, it is very common for me to stage some changes while leaving other changes unstaged.
I currently use a task similar to the one above ☝🏻. When I commit, the task reformats the entire file (which is fine), but then it stages and commits the entire file including the changes I did not want (or intend) to commit.
Question: Does the include property on the task declare what staged files to "re-stage"?
Potential fix: Can the task runner return an error code if a file that's going to be "re-staged" is in the list of unstaged files?
Again, thank you for this wonderful tool! Let me know if you need any further clarification. Cheers!
The text was updated successfully, but these errors were encountered: