Skip to content
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

formula_{auditor,versions}: handle sharding. #15865

Merged
merged 1 commit into from Aug 15, 2023

Conversation

MikeMcQuaid
Copy link
Member

Ensure that FormulaVersions correctly also looks at older paths for sharded formulae.

While we're here, also cleanup FormulaVersions a bit to have more signatures, cleanup dead code, make more code private, improve variable naming.

Partial solution for #15856

@MikeMcQuaid MikeMcQuaid requested a review from Bo98 August 14, 2023 18:17
Ensure that `FormulaVersions` correctly also looks at older paths for
sharded formulae.

While we're here, also cleanup `FormulaVersions` a bit to have more
signatures, cleanup dead code, make more code private, improve
variable naming.
Comment on lines +34 to +37
[relative_path, old_relative_path].compact.each do |entry|
Utils.popen_read(*rev_list_cmd, branch, "--", entry) do |io|
yield [io.readline.chomp, entry] until io.eof?
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can just pass both paths to git rev-list? Probably will be faster. Unless you need to pass them separately in order to correctly process the output? But it doesn't seem like it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carlocab You can do both at once but it only returns a Git SHA and then you don't know what entry the SHA refers to for git cat-file later (which spits out errors to stdout if paths don't exist).

It's a bit slower but not dramatically:

$ hyperfine "git rev-list --abbrev-commit --remove-empty master -- Formula/a/ack.rb Formula/ack.rb"
Benchmark 1: git rev-list --abbrev-commit --remove-empty master -- Formula/a/ack.rb Formula/ack.rb
  Time (mean ± σ):      7.874 s ±  0.164 s    [User: 7.459 s, System: 0.396 s]
  Range (min … max):    7.596 s …  8.032 s    10 runs
$ hyperfine "git rev-list --abbrev-commit --remove-empty master -- Formula/a/ack.rb; git rev-list --abbrev-commit --remove-empty master -- Formula/ack.rb" 
Benchmark 1: git rev-list --abbrev-commit --remove-empty master -- Formula/a/ack.rb; git rev-list --abbrev-commit --remove-empty master -- Formula/ack.rb
  Time (mean ± σ):      8.310 s ±  0.572 s    [User: 7.475 s, System: 0.806 s]
  Range (min … max):    7.769 s …  9.825 s    10 runs

}
def formula_at_revision(rev, &_block)
def formula_at_revision(revision, formula_relative_path = relative_path, &_block)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a vague memory of using this in test-bot. I'll double check later, but it would be good to fix any callers there too.

Copy link
Member

@Bo98 Bo98 Aug 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any uses outside of Homebrew/brew.

@Bo98
Copy link
Member

Bo98 commented Aug 15, 2023

Looks like I might have misdiagnosed the brew bottle issue as being caused by this due to me trying to review code on a phone - but this was still a bug that affected audits and needed fixing anyway. Thanks for the fix!

@MikeMcQuaid
Copy link
Member Author

Looks like I might have misdiagnosed the brew bottle issue as being caused by this due to me trying to review code on a phone

I think it still could have been based on looking at the uses of this? Even although I didn't change the caller: it will still be checking two names now when it only changed one before.

@MikeMcQuaid MikeMcQuaid merged commit 0d29831 into Homebrew:master Aug 15, 2023
24 checks passed
@MikeMcQuaid MikeMcQuaid deleted the formula_versions_sharding branch August 15, 2023 10:29
@github-actions github-actions bot added the outdated PR was locked due to age label Sep 15, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants