-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
cmd/shard: new command #15513
cmd/shard: new command #15513
Conversation
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.
Could you describe your intended sharding scheme/strategy here more explicitly?
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.
Probably should be in dev-cmd
?
switch "--check", | ||
description: "Audit the directory for sharding." |
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.
Should this just be done by default?
Library/Homebrew/sharder.rb
Outdated
end | ||
|
||
def move_file(source, destination) | ||
success = system("git mv '#{source}' '#{destination}' 2>/dev/null") |
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.
You should probably use system_command
here
@carlocab, at least for
For sharding purposes, all non-alphabetical characters are replaced by Not a fan of using
The rationale behind it was to try and preserve the file history. I'll integrate the rest of the comments. |
Co-authored-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>
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.
Thanks for the PR @razvanazamfirei, it's much appreciated and I love the forward progress on sharding but I don't think it's quite the right approach for us for a few reasons:
- I don't think we need either a user-focused or developer-focused command for something that will be run only once per tap
- the auditing process should be moved into
brew audit
(orbrew style
properly but we should mostly do the right thing if they runbrew create
for something that's going to end up in the right tap - similarly, there may be a need to teach other Homebrew internals how to generate the right shard name and this sharding logic will likely vary per-tap and is only needed on two taps (homebrew-core and homebrew-cask)
I'll reply to a couple of other things in the issue thread too.
Thanks again ❤️
af40e34
to
f0afb08
Compare
Let's have more discussion on the sharding scheme, please. As discussed in Slack: I don't think this sharding scheme makes sense. I would like to avoid:
For example, my proposed scheme for homebrew/core would be: hash = {}
CoreTap.instance.formula_names.each do |formula_name|
first_letter = formula_name[0]
key = if formula_name.start_with?("lib")
"lib"
else
first_letter
end
hash[key] ||= []
hash[key] << formula_name
end
hash.each_key {|key| puts "#{key}: #{h[key].size}" } Which, for each key, gives you (at the time of calculation), this many formulae per directory:
Don't want to be too harsh here but:
|
Just leaving a note here: |
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?This PR adds
brew shard
, a command used to shard repositories and, more importantly, audit that files are in the correct place.Still needs tests written and making sure flags work as intended, but I appreciate any feedback.
Currently I'm using
git mv
for moving files in order to preserve history. It's a bit slow, but this should be noticeable only on the initial sharding.