feat: prefix-aware read paths for monorepo multi-product releases - #847
Merged
Conversation
Makes craft's version-detection read paths honor a github target's `tagPrefix`, so a single repo can host independently-versioned products (e.g. `cli@1.2.3`, `mcp@2.0.0`) without cross-contaminating each other's latest-tag detection, changelog base, or CalVer scans. Builds on the existing `tagPrefix` write-side support. - `getLatestTag(git, tagPrefix='')` scopes `git describe` via `--match '<prefix>*'`; threaded through prepare and changelog read paths. - `getGitTagPrefix()` warns when multiple `github` targets declare differing `tagPrefix` values (ambiguous) and returns the first. - `getVersion`/`parseVersion` extract the version from prefixed tags (`cli@1.2.3` -> `1.2.3`); locked with tests. Review fixes folded in: - changelog: wrap the tag-prefix lookup in try/catch (like the versioningPolicy path) so an unreadable/invalid .craft.yml no longer aborts a standalone `craft changelog` run; fall back to the latest tag overall. (Bugbot Medium) - findReleaseBranches: treat the release-branch prefix as an opaque string, cutting at the last "/" (branch = "<prefix>/<version>") instead of segment arithmetic. A bare `release` run no longer claims another product's `release/cli/x` branches. (review + Bugbot Low) Docs note that a first-class, target-agnostic `workspaces:` model is planned (#842) and will supersede the per-.craft.yml convention documented here.
Contributor
|
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
The salvageable, non-controversial core of #844 — prefix-aware version-detection read paths — plus the two review fixes it accumulated. #844 itself is parked in favor of a broader, target-agnostic workspaces redesign (tracked in #842); this PR lands the parts that are correct regardless of that redesign so they aren't lost.
Lets a single repo host independently-versioned products (e.g.
cli@1.2.3,mcp@2.0.0) without cross-contaminating each other's latest-tag detection, changelog base, or CalVer scans. Builds on the existingtagPrefixwrite-side support (no new version library — uses craft's home-grown SemVer utils).Changes
getLatestTag(git, tagPrefix='')scopesgit describevia--match '<prefix>*'; threaded through theprepareandchangelogread paths. Backward compatible (empty prefix → previous behavior).getGitTagPrefix()warns when multiplegithubtargets declare differingtagPrefixvalues (ambiguous) and returns the first. No selector yet — that's deferred to the workspaces work.getVersion/parseVersionextract the version from prefixed tags (cli@1.2.3→1.2.3), locked with tests.Review fixes folded in
versioningPolicypath) so an unreadable/invalid.craft.ymlno longer aborts a standalonecraft changelogrun; it falls back to the latest tag overall.findReleaseBranches(review + Bugbot Low): the release-branch prefix is treated as an opaque string — cut at the last/(branch =<prefix>/<version>) instead of segment arithmetic. A barereleaserun no longer wrongly claims another product'srelease/cli/xbranches.Docs
github.md/configuration.mddocument the current per-.craft.yml-per-product model and explicitly note that a first-class, target-agnosticworkspaces:model is coming (#842) and will supersede it — so we're not doubling down on the per-file convention in docs.Testing
pnpm test— full suite green (1067 passed, 1 skipped). New/updated tests: opaque-prefixfindReleaseBranches(incl. the "barereleasedoesn't claimrelease/cli/x" case), changelog try/catch fallback, prefixed version extraction,getGitTagPrefixconflict warning.tsc,pnpm lint, andprettier --checkon all changed source files clean. Docs build clean.Review
Adversarial subagent review: code logic solid — the opaque-prefix rewrite's one behavioral divergence is the intended fix (not a regression), all edges (HEAD entries, leading/trailing slash, empty version, no-slash) handled correctly, try/catch correct, no half-implemented selector. Flagged a
prettiermiss onconfig.ts(from the cherry-picked base) which is fixed here.Parks #844; supersedes its multi-product portion. Part of #842.
🤖 Generated with opencode