Repository navigation
fix(homebrew): take the formula version from the bottle filename - #100
Merged
Merged
Conversation
The CLI builds a bottle package with no name and no version, so every generated formula fell back to version 1.0.0. The bottle filename (name--version.platform.bottle.tar.gz) encodes the version; the generator now reads it from there. A filename that does not parse, or bottles of one formula with different versions, fail validation before any output is written. Closes #95
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Author
|
Cross-review (read-only, independent model family)
|
bketelsen
approved these changes
Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Every generated Homebrew formula said
version "1.0.0". The CLI builds a bottlemodels.Packagewith only Filename, Size and SHA256Sum, andgenerateFormulafell back to the hard-coded1.0.0whenVersionwas empty. The bottle filenamename--version.platform.bottle.tar.gzencodes the version (docs/specs/generators.md, Homebrew section), so the generator now reads it from there.Closes #95
What changes (all in
internal/generator/homebrew/)parseBottleFilename: name = text before the first--; platform = text after the last.; version = text between them. Suffix.bottle.tar.gzor.bottle.taris required. Name, version and platform must be non-empty.generateFormulatakes the version from the bottle filenames. The1.0.0default is gone. The filename is the source of truth:pkg.Versionis not used for the formula version, because in incremental mode it comes from old formula files, which can hold the wrong1.0.0.Generategroups bottles by the parsed name.extractPackageNameFromURLreuses the parser (old fallback kept for odd input); the unusedextractPackageNameis removed.Behavior for a filename that does not parse
The run fails with an error; nothing is skipped and nothing is defaulted.
ValidatePackagesreturns the error, and it runs in phase 1 ofgenerate, before any format writes output.Generatealso returns the error (defense in depth).Behavior change: mixed versions in one formula
A formula holds 1 version. When the bottles of 1 name have different versions,
ValidatePackagesnow fails (bottles for foo have different versions: 1.0.0, 2.0.0). Before, the formula took the first bottle's metadata version and the first bottle's URL per platform, so an incremental run that added a new version of an existing bottle silently kept the old URL. Upgrading a formula in incremental mode is out of scope here; this change makes the case fail loudly instead of writing a stale formula.Not changed
internal/cli/generate.go(an L1 risk path) is not touched. Setting Name and Version there would switch on incremental conflict detection for bottles (identityname:version, no platform), which is a separate behavior change.Checks
make check— exit 0 (lint 0 issues, docs integrity, unit tests)make vuln,make test-race,make build-crosslocally — greenmake test-integration— needs Docker, not available on the dev host; the CI run covers itrepogen generate --input-dir test/fixtures/bottles --output-dir $TMP/out --base-url https://example.invalidnow writesversion "1.0.0"forrepogen-testandversion "2.0.0"forrepogen-utils.Guard
TestGenerateUsesBottleFilenameVersionbuilds a package like the CLI does (no Name, no Version) forrepogen-utils--2.0.0.x86_64_linux.bottle.tar.gzand assertsversion "2.0.0". A second case sets a staleVersion: "1.0.0", as an old formula gives in incremental mode, and the filename must still win.generator.gorestored from the base,go test ./internal/generator/homebrew/ -count=1failsTestGenerateUsesBottleFilenameVersion(both subtests: the formula holdsversion "1.0.0"),TestValidatePackagesRejectsBadFilenames,TestValidatePackagesRejectsMixedVersionsandTestGenerateRejectsBadFilenames.parseBottleFilename(valid and invalid names), the error for unparsable filenames inValidatePackagesandGenerate(no formula written), and the mixed-version error.test/integration_test.gonow requiresversion "1.0.0"/version "2.0.0"for the 2 fixtures, not only the wordversion.Risk tier
Rationale: Homebrew generator only; no path in
.github/risk-paths.jsonis touched. Output changes only in the formulaversionline, and invalid input now fails instead of writing a wrong formula.Verification
node scripts/check-docs.mjsgreen (insidemake check)docs/specs/generators.mdupdated alongside the code