Strategy Pattern
Strategy Pattern
Keep tag generation, existing-tag ordering, and cross-format conversion as separate responsibilities.
app/core/git_ops/tag_strategy/Category
Quick Command
requested strategy -> implementation -> version tagOverviewâ
Custy uses two related but independent strategy families. A TagStrategy
calculates a new tag. A TagSorter orders tags that already exist. Keeping the
families separate prevents parsing and ordering rules from becoming mixed with
version-bump policy.
VersionBridge is a supporting conversion utility. It synchronizes equivalent
SemVer and PEP 440 representations when a project file requires a different
format from the selected Git tag; it does not choose the next version.
The Three Responsibilities
Generate a Tag
Sort Existing Tags
Convert a Version
Tag Generation Family
Built-in Tag Strategies
These implementations answer one question: what tag should Custy use next?
| Pattern | Purpose | Implementation |
|---|---|---|
| SemVer | Increment a semantic version using the selected bump and optional prerelease input. | SemverStrategy |
| PEP 440 | Generate a Python-compatible public version from repository state and bump input. | PEP440Strategy |
| Commitizen | Use Commitizen-compatible project metadata, then delegate the version calculation through semantic-version behavior. | CommitizenStrategy |
| Date | Create a date-based tag for projects whose releases are organized by calendar value. | DateStrategy |
| Git Count | Derive the next value from repository commit count. | GitCountStrategy |
Tag Resolution Flow
Workflow Timeline
Tag Sorting Family
Existing-Tag Ordering
Requests a sorter that matches the active version strategy.
Orders semantic-version tags.
Orders PEP 440-compatible tags.
Orders date-based tags.
Orders commit-count tags.
GitService detects or receives a project strategy, creates the matching
sorter, and caches it for later tag queries. Commitizen does not have a
separate sorter: its generated versions use semantic-version behavior, so
compatible tags are ordered through the SemVer path.
Extension Boundary
Adding a source-owned generation strategy requires more than implementing
get_next_tag(). The contributor must also extend the strategy choice enum,
workflow dispatch, CLI and configuration resolution, tests, and documentation.
If the resulting tag format needs special ordering, the sorter family and
factory require a corresponding implementation too.