feat: add tagPrefix for monorepo support#67
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a top-level tagPrefix configuration option to support monorepo workflows where packages are tagged with prefixed versions (e.g., app-v1.0.0). Only tags matching the prefix are considered for version resolution, and the prefix is stripped before semver parsing. An empty prefix (default) preserves existing behavior.
Changes:
- Added
tagPrefixfield to theConfigschema and threaded it through version resolution logic (fetchCommitInfo,resolveTaggedVersion,findPreviousSemVerVersions) - Extracted a shared
parseSemVerTagshelper along withmatchesTagPrefixandstripTagPrefixutilities to filter and strip tag prefixes - Added 7 new unit tests and documentation for the monorepo
tagPrefixfeature
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/config/types.ts |
Added tagPrefix string field with empty default to the Config Zod schema |
src/version/versionResolver.ts |
Threaded tagPrefix through version resolution; added parseSemVerTags, matchesTagPrefix, and stripTagPrefix helpers |
src/version/versionResolver.test.ts |
Added 7 new tests for tagPrefix behavior; added tagPrefix to mock config |
docs/configuration.md |
Documented the tagPrefix option and added a "Monorepo Support" section |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| it("should keep raw tag in commitInfo.tag", () => { | ||
| mockListTags.mockReturnValue(["app-v1.0.0"]); | ||
| mockListTagsBeforeCommit.mockReturnValue([]); | ||
|
|
||
| const platform = createMockPlatform({ | ||
| getGitTag: () => "app-v1.0.0", | ||
| }); | ||
| const config = createMinimalConfig({ tagPrefix: "app-" }); | ||
| const strategies = [new VersionStrategy("test", config.strategies.test)]; | ||
| const result = resolveVersion(config, platform, strategies); | ||
|
|
||
| // Version is stripped, but we verify via the semver result | ||
| expect(result.isSemVerVersion).toBe(true); | ||
| expect(result.strategies.test.version).toBe("1.0.0"); | ||
| }); |
Adds a top-level tagPrefix config option that scopes GTS to only consider tags matching the prefix. The prefix is stripped before semver parsing. This enables monorepo workflows where packages are tagged with prefixed versions (e.g. app-v1.0.0, lib-v2.1.0) — each package uses its own tagPrefix to isolate version resolution. When tagPrefix is empty (default), all tags are considered and behavior is unchanged. Closes #63
The "should keep raw tag in commitInfo.tag" test couldn't actually assert on commitInfo.tag (not exposed in VersionResult) and was identical to the earlier prefix stripping test.
There was a problem hiding this comment.
Pull request overview
Adds a top-level tagPrefix configuration option to support monorepo workflows where packages use prefixed git tags (e.g., app-v1.0.0). Only tags matching the configured prefix are considered for version resolution, and the prefix is stripped before semver parsing. An empty prefix (default) preserves full backwards compatibility.
Changes:
- New
tagPrefixfield on theConfigZod schema with a default of"" - Tag prefix filtering, stripping, and scoped version resolution logic in
versionResolver.ts(including a newparseSemVerTagshelper) - Documentation and 6 new unit tests covering prefix matching, stripping, scoping, and backwards compatibility
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/config/types.ts |
Adds tagPrefix string field to the Config schema |
src/version/versionResolver.ts |
Implements tag prefix matching, stripping, and scoped version resolution via matchesTagPrefix, stripTagPrefix, and parseSemVerTags helpers |
src/version/versionResolver.test.ts |
Adds tagPrefix to test config factory and 6 new tests for prefix behavior |
docs/configuration.md |
Documents the tagPrefix option and adds a monorepo support section |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| const tag = platform.getGitTag(); | ||
| const previousSemVerVersions = findPreviousSemVerVersions(commitSha); | ||
| const rawTag = platform.getGitTag(); | ||
| const tag = matchesTagPrefix(rawTag, config.tagPrefix) ? rawTag : undefined; |
Summary
Adds a top-level
tagPrefixconfig option for monorepo workflows where packages are tagged with prefixed versions (e.g.app-v1.0.0,lib-v2.1.0).app-v1.0.0→v1.0.0→1.0.0)isHighest*,previousSemVerVersion, etc.) are scoped to matching tagsExample:
Also settable via CLI:
git-that-semver -c tagPrefix=app-Test plan
Closes #63