jellyedwards / gitsweep

VS Code extension to allow changes files to be excluded from git (--skip-worktree, --assume-unchanged, exclude file)
19 stars 1 forks source link

Feature request : Exclude folder option when right click #12

Open mpariente opened 2 years ago

mpariente commented 2 years ago

The new functionality introduced in #10 is really great, I love it saves me tons of time, thanks a lot !

Would it be possible to implement an option that when we right-click on a folder or file in Explorer view, we could "GitSweep : Sweep file/folder under the rug"?

I would just add the file or folder to the .git/info/exclude file, and remove the need for the user to even open this file to exclude folders. This would be especially necessary for folders, because there is no way to exclude them in the Source Control view.

jellyedwards commented 2 years ago

Hey, glad it works for you!

I think that's a nice follow on feature from the last issue, let me see what I can do (when I can find the time)!

jellyedwards commented 2 years ago

If you right click a folder in the explorer you should get a new submenu now: image

jellyedwards commented 2 years ago

Just read it was for files & folders... I'll add files too...

jellyedwards commented 2 years ago

15 should sort that too

mpariente commented 2 years ago

This is great ! Thank you very much for this feature, it really helps ! About the file excluding method, which one do you recommend most "Sweep file by adding to exclude file" ?

Thanks again !

mpariente commented 2 years ago

Hey,

The "Exclude Folder" does not work for me when it's an absolute path somehow. When I change it to relative path, it works though. Is it the same for you ?

jellyedwards commented 2 years ago

Hi,

I'm not quite sure I understand what's going on, can you send me a screenshot or two please?

Does the right click menu allow you to Exclude folder and does .git/info/exclude file change at all for you?

Cheers

mpariente commented 2 years ago

Thanks for your quick answer !

In the following example. I used the right click menu to exclude the to_ignore folder. And the file inside it is not ignored.

image

If I change the folder name in .git/info/exclude to the relative path to_ignore/* instead of /home/.../tmp_sweep/to_ignore/*, the file does get ignored.

image

Does it make sense ?

jellyedwards commented 2 years ago

I see what you mean now, how strange! I'll have a look...

jellyedwards commented 2 years ago

It shouldn't be using the absolute path, what does git rev-parse --show-toplevel show for you?

jellyedwards commented 2 years ago

I couldn't reproduce here but I think it might have to do with a Windows/*nix difference & I've tried to fix it. Could you try out the latest version please & see if it still happens for you?

mpariente commented 2 years ago

This is what I get now :

image

And git rev-parse --show-toplevel gives me /home/mparient/code/cloned/tmp_sweep.

Thanks again for looking into this!

jellyedwards commented 2 years ago

Hmm not good! I won't be able to work on this for about a week but I'll have another go then & give you a shout, looks like it might have a little trouble with the home dir tilde ~...

I didn't see your question earlier sorry:

About the file excluding method, which one do you recommend most "Sweep file by adding to exclude file" ?

I always use --skip-worktree for files that are in the repository and adding to the exclude file for new files and directories. It might be better in a future version if the extension worked out what was best for you.

jellyedwards commented 2 years ago

Hey - sorry for the delay getting back to you!

I'm trying to reproduce on a Ubuntu box & I'm still not getting any clues on how to fix it for you. I've made a pre-release version if you could please use that and let me know what the output is.

To use the pre-release version, go into the GitSweep extension: image

And click the Switch to Pre-Release Version: image

It should install a new version which has a little bit more debug. If you go to output in the terminal window and click GitSweep from the dropdown, you should see something like this when you sweep/unsweep a file/folder: image

You might notice from my example that it uses the git root to truncate the file/folder paths to make them relative paths. Your Git root seems to be: /home/mparient/code/cloned/tmp_sweep but the folder path is /user/mparient/home/code/cloned/tmp_sweep/to_ignore. The git root doesn't match the start of the folder path so it ends up going all the way out to root (../../../../../) to get to your folder. Any idea why they don't match? I don't use Linux much at all but there's no symlink or anything like that is there?

jellyedwards commented 2 years ago

Hey @mpariente , did you get to try out the pre-release version? Or find out what the issue was yourself & save me the effort 😄

mpariente commented 2 years ago

Hey @jellyedwards , sorry no, I didn't take the time to do it yet, but it's on my todo-list for ever now. I edited the exclude file manually since then, so it's a dirty fix but it works for now. Sorry for not taking the time.

jellyedwards commented 2 years ago

No worries, if you do get around to having a look let me know.