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

Tweak cask-source API handling #14439

Merged
merged 6 commits into from Feb 2, 2023

Conversation

MikeMcQuaid
Copy link
Member

  • Use raw.githubusercontent.com to download cask source rather than formulae.brew.sh. This allows us to remove these files
  • output the tap's current HEAD for both formulae and cask JSON
  • use this HEAD for the cask-source API to get the exact file on raw.githubusercontent.com rather than just whatever is newest (which is what the previous API did)
  • set the Tap correctly when creating a Cask from the API
  • if the formula.json file exists: print its modified time include brew config
  • memoize tap.git_head as we'll be calling it a lot in the same process with the same value

@Rylan12 would appreciate if you can kick the tires on this a bit. Feel free to merge when you're happy or commit to it and then merge if you want changes. Thanks ❤️ 🙇🏻

- Use raw.githubusercontent.com to download cask source rather than
  formulae.brew.sh. This allows us to remove these files
- output the tap's current `HEAD` for both formulae and cask JSON
- use this `HEAD` for the cask-source API to get the exact file on
  raw.githubusercontent.com rather than just whatever is newest (which
  is what the previous API did)
- set the `Tap` correctly when creating a `Cask` from the API
- if the `formula.json` file exists: print its modified time include
  `brew config`
- memoize `tap.git_head` as we'll be calling it a lot in the same
  process with the same value
@MikeMcQuaid MikeMcQuaid added the critical Critical change which should be shipped as soon as possible. label Jan 26, 2023
@BrewTestBot
Copy link
Member

BrewTestBot commented Jan 26, 2023

Review period ended.

Copy link
Member

@Rylan12 Rylan12 left a comment

Choose a reason for hiding this comment

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

Thanks for opening this!

I think the cask source method should live in Homebrew::API::Cask since the modules within Homebrew::API are meant to correspond to actual formulae.brew.sh API endpoints. If we're planning on removing /api/cask-source, we should also remove Homebrew::API::CaskSource.

I'm away for a family event this weekend so won't have as much time to play with it, but I'll try to push those changes and test it out a bit when I have time

Library/Homebrew/api.rb Outdated Show resolved Hide resolved
return FromContentLoader.new(cask_source).load(config: config)
end

# convert generic string replacements into actual ones
json_cask[:artifacts] = json_cask[:artifacts].map(&method(:from_h_hash_gsubs))
json_cask[:caveats] = from_h_string_gsubs(json_cask[:caveats])

Cask.new(token, source: cask_source, config: config) do
tap = Tap.fetch(json_cask[:tap]) if json_cask[:tap].to_s.include?("/")
Copy link
Member

Choose a reason for hiding this comment

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

What's the case where json_cask[:tap].to_s does not include /?

Copy link
Member Author

Choose a reason for hiding this comment

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

Mainly thinking of the case where it's an empty/invalid string.

@Rylan12 Rylan12 added the install from api Relates to API installs label Jan 28, 2023
MikeMcQuaid added a commit to Homebrew/formulae.brew.sh that referenced this pull request Feb 2, 2023
This is no longer needed after
Homebrew/brew#14439 is merged and in a stable
tag.
@MikeMcQuaid MikeMcQuaid merged commit cdf58fe into Homebrew:master Feb 2, 2023
@MikeMcQuaid MikeMcQuaid deleted the cask_source_tweaks branch February 2, 2023 12:50
MikeMcQuaid added a commit to Homebrew/formulae.brew.sh that referenced this pull request Feb 4, 2023
These is no longer needed after
Homebrew/brew#14439 and
Homebrew/brew#14500 are merged and in a stable
tag.
MikeMcQuaid added a commit to Homebrew/formulae.brew.sh that referenced this pull request Feb 4, 2023
These are no longer needed after
Homebrew/brew#14439 and
Homebrew/brew#14500 are merged and in a stable
tag.
MikeMcQuaid added a commit to Homebrew/formulae.brew.sh that referenced this pull request Feb 4, 2023
These are no longer needed after
Homebrew/brew#14439 and
Homebrew/brew#14500 are merged and in a stable
tag.
MikeMcQuaid added a commit to Homebrew/formulae.brew.sh that referenced this pull request Feb 4, 2023
These are no longer needed after
Homebrew/brew#14439 and
Homebrew/brew#14500 are merged and in a stable
tag.
MikeMcQuaid added a commit to Homebrew/formulae.brew.sh that referenced this pull request Feb 7, 2023
These are no longer needed after
Homebrew/brew#14439 and
Homebrew/brew#14500 are merged and in a stable
tag.
MikeMcQuaid added a commit to Homebrew/formulae.brew.sh that referenced this pull request Feb 8, 2023
These are no longer needed after
Homebrew/brew#14439 and
Homebrew/brew#14500 are merged and in a stable
tag.
MikeMcQuaid added a commit to Homebrew/formulae.brew.sh that referenced this pull request Feb 15, 2023
These are no longer needed after
Homebrew/brew#14439 and
Homebrew/brew#14500 are merged and in a stable
tag.
@github-actions github-actions bot added the outdated PR was locked due to age label Mar 5, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
critical Critical change which should be shipped as soon as possible. install from api Relates to API installs outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants