-
Notifications
You must be signed in to change notification settings - Fork 582
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
Attempt auto-generated files being hidden by default #421
Attempt auto-generated files being hidden by default #421
Conversation
I love this idea! Here are some initial thoughts:
That's all my first pass on the details of implementation. Generally though, this feels like a feature I didn't realize I needed. I'm gonna read through the PR now. |
ExcludeDotFiles: repo.ExcludeDotFiles, | ||
SpecialFiles: wd.SpecialFiles(), | ||
AutoGeneratedFilePatterns: wd.AutoGeneratedFilePatterns(vcsDir), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to clarify, you swapped the order of this block so that we don't create opt
if there's an error pulling?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah i swapped it because i needed wd.PullOrClone
to be executed first so that when wd.AutoGeneratedFilePatterns(vcsDir)
is called, it can find the .gitattributes
file. wd.PullOrClone
will populate the directory so without it, the first run of this flow will not see accurate results for autogenerated files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh gotcha, that makes sense.
vcs/git.go
Outdated
if len(matches) == 2 { | ||
pattern := strings.ReplaceAll(matches[1], "**", "*") | ||
pattern = strings.ReplaceAll(pattern, "*", ".*") | ||
filePatterns = append(filePatterns, pattern) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Could you add a test for this pattern-to-regex conversion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah i might change this logic (see my comment about regexes and using direct file paths instead). but either way, i will add a test for the code added in this file!
@@ -693,7 +693,7 @@ var ContentFor = function(line, regexp) { | |||
|
|||
var FileContentView = React.createClass({ | |||
getInitialState: function() { | |||
return { open: true }; | |||
return { open: !this.props.isAutoGenerated }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be nice to put an [AUTOGENERATED]
badge next to the file path. That's not a blocker of course, but it would be a nice visual indication about why the file is collapsed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea, will do!
Ok! Two asks before I approve this:
One other thought on the feature itself: it might be worth having an override for this feature in the config. For example, you might have a |
Thanks for taking a look and glad you think this feature is worthy of being added! I agree we can follow Github's approach where we hide but still index/search on these autogenerated files. I'll look into adding a badge, adding documentation into the README, and adding config override! Actually for the glob-to-regex logic, I'm not sure it's the right approach anymore. I just realized that you could nest (sorry for not responding earlier!) |
@ivantsepp your response rate is still probably better than ours on this repo! That approach sounds more than fine to me. It looks like |
} | ||
} | ||
|
||
if err := filesCmd.Wait(); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Followed the pattern in the example in https://pkg.go.dev/os/exec#Cmd.StdoutPipe so hopefully this is right
friendly bump! was hounding the other day and was reminded that this feature would be cool! Any thoughts on the revised PR? |
@ivantsepp Thank you for the bump! I think these updates look good. I'll float this PR around with the rest of the folks to see if there are any objections, but otherwise I'll merge this and cut a release. Thank you again! |
This PR introduces a new feature to auto hide autogenerated files. It builds upon the recent commit of being able to collapse files (c1ffa46). The idea is to parse out autogenerated file patterns from
.gitattributes
(link) and automatically collapse matching files in the UI.Note
This is a PR just to spark discussion! I'm not sure what the best approach is as there are many options. We can ask questions like:
excluded_files.json
(should speed up searches as these files aren't indexed)Thoughts on a feature like this? And what would the best approach be? Thanks!