QB64Official / vscode

QB64 Extension for Visual Studio Code.
MIT License
13 stars 3 forks source link

.gitignore for .vscode #19

Closed DualBrain closed 2 years ago

DualBrain commented 2 years ago

I'm wondering if there is a way to detect if the source loaded is within a git context and, if so, either add to or create (prompting) the .gitignore to include .vscode folder - right now having to do that manually.

LordDurus commented 2 years ago

@DualBrain Which .gitignore are you referring to? The one for the extension project or the QB64 project (where the bas file are)?

If its in the one in the QB64... Editing a .gitignore is doable. I'm not sure how to check if within a git context. But I had a template; creating a new one can be done as well.

At this point I'm not sure how to do a prompt (might be as easy as just calling Alert).

So if I'm reading this correctly 2 things need to be done 1) Editing and exiting .gitignore 2) Create a .gitignore if it does not exist.

DualBrain commented 2 years ago

About the one in the opened .bas file. In my case, .bas files are in c:\bas and/or c:\github\projectname - not in the c:\qb64 executable folder. Whenever I open with a .bas file with the extension active it creates a .vscode folder and that doesn't really present itself as a problem until I go to review my commit to github. ;-) It's easy enough to work around, but if it could be automated that would be a lot better.

Your #1 and #2 are correct. The challenge as I see it is accurately detecting the root of the github "project" as it might not be in the same folder as the .bas file but in a parent (or parent's parent) folder.

LordDurus commented 2 years ago

The creating of the .vscode folder currently always happens in the same folder that .bas file is in. That is so the launch.json gets created thus allowing the F5 to work.

I see show this could be a problem. We would need to find the parent's .gitingore then add .vscode for that folder and all sub-folders.

A quick fix that would be better than the nothing we have now; is if there is a .gitingore in the same folder as the .bas add the .vscode folder to it.

That won't fix your problem, but anyone how keeps all their .bas files in the root of the project and puts the include files in sub folders would be fixed.

DualBrain commented 2 years ago

I think .gitignore works in subfolders as well as the parent, so having multiple isn't necessarily an issue - I tend (personal work patter) try to keep "projects" in their own subfolders.

DualBrain commented 2 years ago

And to me adding a .gitignore is "good" while having a "personal" .vscode in the repo is "bad". ;-)

LordDurus commented 2 years ago

What all do you think should be in the gitignore

DualBrain commented 2 years ago

If I recall off the top of my head, I think it's...

.vscode/
DualBrain commented 2 years ago

Found this...

https://stackoverflow.com/questions/56792135/gitignore-ignore-all-vscode-directories-but-include-the-top-level-launch-json

I'm not sure it's a good idea to include the launch.json file at this point given that things might change... but, it does seem there's some argument for excluding everything but this file. Food for thought.

LordDurus commented 2 years ago

I agree including the launch.json at this point is not what we want to do.

I'm thing for now I'll create the .gitignore in the same folder the bas file is in. And see how that works out. Then go from there.

LordDurus commented 2 years ago

I have the the creating of a gitignore working (if it's not already there and the setting for it is true)

But I was thinking (if it's not crazy hard) what would be better than auto adding stuff to the file. Would be adding a right click option to the VSCode explorer context menu to add to .gitignore.

So summing up add an option here. Called "Add to .gitignore" then what ever you right clicked on gets added.
image

LordDurus commented 2 years ago

Getting the menu option there was pretty easy (both files and folders). Now to make do something image