fix: generate brew style-compliant cask in homebrew-tap workflow#2898
fix: generate brew style-compliant cask in homebrew-tap workflow#2898markphelps merged 1 commit intomainfrom
Conversation
|
Thanks for fixing the One minor suggestion: Consider adding shell escaping to the sed substitution for better robustness against special characters: # Substitute shell variables into the generated cask
sed -i "s|\\${VERSION}|${VERSION}|g" cog.rb
sed -i "s|\\${SHA_ARM}|${SHA_ARM}|g" cog.rb
sed -i "s|\\${SHA_X86}|${SHA_X86}|g" cog.rb
sed -i "s|\\${BASE_URL}|${BASE_URL//\\/\\\\/}|g" cog.rbThe additional escaping ensures the literal |
dd829cb to
cdaa8a2
Compare
|
Posted a suggestion about improving the sed variable substitution robustness. The current implementation is functional since inputs are controlled, but the escaping would make it more defensive against edge cases. Otherwise LGTM - the changes properly address all five |
|
I'm Bonk, and I've done a quick review of your PR. This PR fixes the Homebrew cask generation workflow to comply with The changes properly address all the style and audit issues mentioned. The switch to a quoted heredoc with explicit sed substitution is a clean approach that makes the template readable while avoiding shell expansion issues. One small suggestion for additional robustness: # Substitute shell variables into the generated cask.
# Only version and sha256 need substitution — URLs use Ruby #{version}
# interpolation which Homebrew evaluates at install time.
sed -i "s|\\\${VERSION}|${VERSION}|g" cog.rb
sed -i "s|\\\${SHA_ARM}|${SHA_ARM}|g" cog.rb
sed -i "s|\\\${SHA_X86}|${SHA_X86}|g" cog.rbThe extra backslash ensures the literal LGTM |
Summary
brew stylechecks without manual interventionbrew style --fixmanually on the PR (e.g. replicate/homebrew-tap@0394f59)Changes
Style violations fixed (from
brew style --fix)on_intelbeforeon_armon_armbeforeon_intel(alphabetical)urlbeforesha256sha256beforeurl(with blank line between)https://cog.runhttps://cog.run/(trailing slash required)Hardware::CPU.intel?ternaryon_intel/on_armblock syntax with proper alignmentargs:alignment in postflightsystem_commandcall columnAudit violations fixed (from
brew audit)sha256 :no_checkwhen URL is unversioned"#{version}interpolation so Homebrew recognizes them as versionedverified: "github.com/replicate/cog/"parameter tourlstanzasNote: The "cask token conflicts with homebrew/core formula" warning is expected and intentional — both the formula and cask are the same project (cog).
Template approach
Switched from a shell-expanded heredoc with indentation stripping to a quoted heredoc (
<<'CASK') with explicitsedvariable substitution. This is more robust and keeps the template visually matching the final output.Testing
Simulated the generation locally and verified the output matches
brew styleexpectations.