-
Notifications
You must be signed in to change notification settings - Fork 29
update the way we glob team files #120
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
Conversation
| code_team = TeamPlugins::Ownership.for(team) | ||
|
|
||
| Dir.glob(code_team.owned_globs).each do |filename| | ||
| map[filename] = team | ||
| end | ||
|
|
||
| # Remove anything that is unowned | ||
| TeamPlugins::Ownership.for(team).unowned_globs.each do |glob| | ||
| Dir.glob(glob).each do |filename| | ||
| map.delete(filename) | ||
| end | ||
| # Remove anything that is unowned by this team | ||
| Dir.glob(code_team.unowned_globs).each do |filename| | ||
| map.delete(filename) |
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.
this change will make these globs a bit faster
The main reason I'd expect this is that it only tries recursing through the code base once for owned and once for unowned w/ all the glob patterns, as opposed to recursing once per glob.
It might be possible to improve further by doing one giant glob, and using File#fnmatch? to exclude unowned patterns. benchmark-ips + benchmark-memory is super helpful for comparing multiple implementations
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.
I went with a slightly different Dir.glob(code_team.owned_globs) - Dir.glob(code_team.unowned_globs) that is used elsewhere for now. It might be worth revisiting for fnmatch, but I'll do it in another commit.
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.
Eh, I couldn't help it. The ugly part here is that unowned_globs is an array, so at best we have to do the following which, thought it might be faster, looping that for every file just annoys me 😬
unowned_globs.any? { File.fnmatch?(_1, filename) }b8d6b40 to
df27298
Compare
df27298 to
171bcd9
Compare
@martinemde says that this change will make these globs a bit faster which is important when you're running this on a large codebase.