Skip to content

feat: add tagPrefix for monorepo support#67

Merged
maff merged 2 commits into
mainfrom
feat/tag-prefix
Mar 15, 2026
Merged

feat: add tagPrefix for monorepo support#67
maff merged 2 commits into
mainfrom
feat/tag-prefix

Conversation

@maff
Copy link
Copy Markdown
Owner

@maff maff commented Mar 15, 2026

Summary

Adds a top-level tagPrefix config option for monorepo workflows where packages are tagged with prefixed versions (e.g. app-v1.0.0, lib-v2.1.0).

  • Only tags matching the prefix are considered for version resolution
  • The prefix is stripped before semver parsing (app-v1.0.0v1.0.01.0.0)
  • All version flags (isHighest*, previousSemVerVersion, etc.) are scoped to matching tags
  • Non-matching tags on the current commit are treated as snapshots
  • Empty prefix (default) preserves existing behavior — fully backwards compatible

Example:

tagPrefix: "app-"

strategies:
  docker:
    enabled: true

Also settable via CLI: git-that-semver -c tagPrefix=app-

Test plan

  • CI passes
  • 7 new unit tests covering: non-matching tag → snapshot, prefix stripping for semver and non-semver tags, scoped highest version checks, scoped previous version, raw tag in commitInfo, empty prefix default behavior
  • All existing tests pass unchanged (backwards compatible)
  • E2E tests pass

Closes #63

Copilot AI review requested due to automatic review settings March 15, 2026 17:30
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 tagPrefix field to the Config schema and threaded it through version resolution logic (fetchCommitInfo, resolveTaggedVersion, findPreviousSemVerVersions)
  • Extracted a shared parseSemVerTags helper along with matchesTagPrefix and stripTagPrefix utilities to filter and strip tag prefixes
  • Added 7 new unit tests and documentation for the monorepo tagPrefix feature

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.

Comment thread src/version/versionResolver.test.ts Outdated
Comment on lines +425 to +439
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");
});
maff added 2 commits March 15, 2026 18:37
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.
Copilot AI review requested due to automatic review settings March 15, 2026 17:37
@maff maff force-pushed the feat/tag-prefix branch from f0debd6 to 6a8f795 Compare March 15, 2026 17:37
@maff maff enabled auto-merge March 15, 2026 17:37
@maff maff merged commit e9b3416 into main Mar 15, 2026
8 checks passed
@maff maff deleted the feat/tag-prefix branch March 15, 2026 17:39
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 tagPrefix field on the Config Zod schema with a default of ""
  • Tag prefix filtering, stripping, and scoped version resolution logic in versionResolver.ts (including a new parseSemVerTags helper)
  • 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;
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.

feat: monorepo support via tag prefix filtering

2 participants