Skip to content

feat: prefix-aware read paths for monorepo multi-product releases - #847

Merged
BYK merged 1 commit into
masterfrom
feat/prefixed-tags-fixes
Jul 21, 2026
Merged

feat: prefix-aware read paths for monorepo multi-product releases#847
BYK merged 1 commit into
masterfrom
feat/prefixed-tags-fixes

Conversation

@BYK

@BYK BYK commented Jul 21, 2026

Copy link
Copy Markdown
Member

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 existing tagPrefix write-side support (no new version library — uses craft's home-grown SemVer utils).

Changes

  • getLatestTag(git, tagPrefix='') scopes git describe via --match '<prefix>*'; threaded through the prepare and changelog read paths. Backward compatible (empty prefix → previous behavior).
  • getGitTagPrefix() warns when multiple github targets declare differing tagPrefix values (ambiguous) and returns the first. No selector yet — that's deferred to the workspaces work.
  • getVersion/parseVersion extract the version from prefixed tags (cli@1.2.31.2.3), locked with tests.

Review fixes folded in

  • changelog (Bugbot Medium): the tag-prefix lookup is now wrapped in try/catch (mirroring the versioningPolicy path) so an unreadable/invalid .craft.yml no longer aborts a standalone craft changelog run; 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 bare release run no longer wrongly claims another product's release/cli/x branches.

Docs

github.md / configuration.md document the current per-.craft.yml-per-product model and explicitly note that a first-class, target-agnostic workspaces: 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-prefix findReleaseBranches (incl. the "bare release doesn't claim release/cli/x" case), changelog try/catch fallback, prefixed version extraction, getGitTagPrefix conflict warning.
  • tsc, pnpm lint, and prettier --check on 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 prettier miss on config.ts (from the cherry-picked base) which is fixed here.

Parks #844; supersedes its multi-product portion. Part of #842.

🤖 Generated with opencode

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.
@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-21 20:52 UTC

@BYK
BYK merged commit f70d5a8 into master Jul 21, 2026
24 checks passed
@BYK
BYK deleted the feat/prefixed-tags-fixes branch July 21, 2026 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant