-
-
Notifications
You must be signed in to change notification settings - Fork 221
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
Accurate gitignore generator #296
Comments
What is the scope of this task? Doing something like the tool in this link ? When I saw this idea, I thought it was a project that automatically creates a .gitignore file via the command line. |
The projects you're referring to are the ones which I call inaccurate, although a dirty implementation of my proposal could be based on those. It could be a CLI, and/or an IDE plugin. |
I'm not quite sure how that detection should work. For example detecting an ide does not mean a specific project is opened with it. |
@Idrinth there are solutions that are considered dirty, for example For the clean solution, it seems to me that this situation can be solved with project-based plugins. For example, if it is a Next js project, only the lines related to Next should be brought from the fetch project Node .gitignore. This should be done for every language and technology, and in-app plugins should be making by providing contribution. 🤔 |
Opening a project in an IntelliJ IDE creates an |
And half the time(ok, often, but maybe not that often) someone committed that and it's opened by something else, let's say sublime text |
What's the issue then ? If the developer uses Sublime Text, there will be nothing related to that choice that requires any |
There is a boiled down concept here that actually makes alot of sense - Have a CLI that communicates with the files in githubs template repo. Have the user select a template from a menu, that will generate the "dirty" ignore file. After this simply read the new file line by line and test if the path exists, if its not, cut that line out of the file. I'd be happy to work on this project if anyone else is keen. EDIT: Just to extend upon this idea -- That loop would also use something like a lookup table that would match the string to a "handler" function. which would in turn implement rules / actions / checks to be performed should that string be in the ignore file. |
Suggestion : before asking the user to select which gitignore files to use, filter out from the list those that already doesn't output any match. |
My only concern there is CPU Cycles. There would need to be a very efficient algorithm to sort & checking potentially millions of lines of text, against a recursive scan of the current working dir. |
Not if you put the working directory content in an array first, then check it against the gitignore files. |
Thats actually the exact process I had in my head when I wrote that. Got to remember, lets say for each item in the array (that represents a file in the working directory tree) we need to make a call out to a function or something that either magically has every line from every file in this repo stored and sorted so we know what matches are relevant to what theme/framework/whatever OR We make a HTTP call to read each one of the files and see if we get matches that way. But that match that we do get needs to be stored as not only a match, but a match from And we need to repeat that for every file in the current project. You either end up with a very large install size because misc data that we may need, or we have high bandwidth usage because of the HTTP calls. If you have a different solution im all ears haha. |
|
I actually implemented something similar in Go. It is just a fun project so I didn't really add too many features, it just checks for a |
Well, it's not entirely what I suggested, but it's a step :) |
I have a good initial version working! There might be more to do, but mostly I only need a few more language deterministic patterns before I'm ready to call it v1. Latest release (GitHub) | Repository (GitHub)VS Code Extension (VS Code Marketplace) | VS Code Extension Repository (GitHub)Binary verified working on:
How it worksThe general flow is this:
Any suggestions welcome. |
Would love some help with static file language detection, if you know any project files that are usually consistent per language/project I would love to hear it :) such as I am keeping track of all the languages I statically check for right here: chenasraf/gi_gen#2 Feel free to add to the list so I can implement 🙏🏼 |
Also created a VS Code extension that uses the above program :) |
@KaKi87, I hate to make many comments in a row, but I am really looking forward to my submission being reviewed. If you feel it is appropriate, I will appreciate closing this issue, or, letting me know what can be changed, to make that happen. Thank you for the idea, I loved working on this. |
I ran
Here's the initial content :
Here's the resulting diff in overwrite mode : diff --git a/.gitignore b/.gitignore
index 38f2865..82925f5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,4 @@
-.idea
-node_modules
-config.js
-.parcel-cache
-dist
-build
\ No newline at end of file
+# Dependency directories
+node_modules/
+# Nuxt.js build / generate output
+dist
\ No newline at end of file Here's the resulting diff in append mode : diff --git a/.gitignore b/.gitignore
index 38f2865..69c094d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,4 +3,8 @@ node_modules
config.js
.parcel-cache
dist
-build
\ No newline at end of file
+build
+# Dependency directories
+node_modules/
+# Nuxt.js build / generate output
+dist
\ No newline at end of file Additionally, when using this particular mode, I would suggest not removing matching lines even if no template contains it, or asking the user's permission to do so. Thank you for your interest into my idea. |
Thanks for the reply @KaKi87 :)
Yes, I need more examples of files to test against for more template types, I am keeping track of what's possible right now via this issue. I will add IDEs and more
True, I am not modifying the existing contents of the gitignore file, only the ones that GI Gen generates, and then gets added/replaces... It's definitely a point to improve upon. Generally I guess we would want both cleanup logic & dedupe logic in the end output file, not only the output file before it is appended.
Do you have a suggestion on what to do there? Should I ignore some specific examples when matching? A
Is the prompt to clean unused lines not what you mean? Can you elaborate? |
I asked myself about this before posting, and knew that you'd ask as well, unfortunately I'm as clueless as you. 😅 Not only those directories exist in many templates as you know, but the developer might not even use such directory as an output one, but maybe store build scripts/tools in it, and use a differently named directory, to store generated builds.
No, that one works fine.
|
Project description
.gitignore
generators outputs all potentially applicable rules, relying on a project's language or platform, whether those will be used or not.An accurate generator would only include useful ones for a project.
At first glance, here are two ways of doing this.
Dirty : output rules from existing generators, filter out those which won't have any effect (i.e. path does not exist) ;
Clean : output rules from smart detections of dev tools and dependencies.
Relevant Technology
The generator must use a language or platform that can run :
on any operating system ;
alongside any other installed language, platform or dev tool ;
ideally without any dependency.
The generator would ideally support all languages and platforms that could benefit from it.
Complexity and required time
Complexity
Required time (ETA)
Categories
The text was updated successfully, but these errors were encountered: