Skip to content

Commit 430f9a8

Browse files
committed
docs: add plan for zerv flow
1 parent 25f8a33 commit 430f9a8

File tree

3 files changed

+611
-13
lines changed

3 files changed

+611
-13
lines changed

.claude/plan/32-zerv-flow-implementation-plan.md

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,37 @@ This document defines the planned `zerv flow` subcommand, an opinionated automat
5656

5757
**Clean branches**: `main`, `master` → No pre-release (clean releases)
5858

59-
**Post-release resolution when branching**:
59+
**Post-release resolution logic**:
6060

61-
- Reset to `.post.1` when pre-release label INCREASES (alpha → beta → rc)
62-
- Continue post count when pre-release label STAYS SAME OR DECREASES (alpha → alpha, beta → beta, beta → alpha)
63-
- Starting from clean release: Continue with `.post.1` (previous post count was 0)
64-
- Examples:
65-
- `1.0.2-beta.1.post.56``1.0.2-rc.1.post.1` (beta→rc, reset)
66-
- `1.0.2-beta.1.post.57``1.0.2-alpha.12345.post.58` (beta→alpha, continue)
67-
- `1.0.2-alpha.12345.post.3``1.0.2-alpha.54321.post.4` (alpha→alpha, continue)
68-
- `1.0.2``1.0.2-alpha.98765.post.1` (clean→alpha, continue from post 0)
61+
- **Configurable post representation** with two options:
62+
- **Tag Distance**: Count commits from last tag
63+
- **Commit Distance**: Count commits from branch creation point
64+
- **Default**: Tag Distance (most common use case)
65+
- **`post.0`**: Exactly on reference point (no commits since)
66+
- **`post.N`**: N commits since reference point
67+
- **Consistent across all branch types** (alpha, beta, rc, etc.)
68+
69+
**Examples**:
70+
71+
**Tag Distance (release branches):**
72+
73+
```
74+
main: v1.0.0 (tag)
75+
└── release/1 (created) → create tag v1.0.1-rc.1.post.1
76+
└── 1 commit → 1.0.1-rc.1.post.1.dev.1729924622 (same post, dev timestamp)
77+
└── 2 commits → 1.0.1-rc.1.post.1.dev.1729924623 (same post, dev timestamp)
78+
└── create tag → 1.0.1-rc.1.post.2 (new tag increments post)
79+
└── more commits → 1.0.1-rc.1.post.2.dev.1729924624 (new post, dev timestamp)
80+
```
81+
82+
**Commit Distance (develop branch):**
83+
84+
```
85+
main: v1.0.0 (tag)
86+
└── develop (created from v1.0.0) → commit 1.0.1-beta.1.post.1 (1 commits since branch creation)
87+
└── 5 commits later → 1.0.1-beta.1.post.6 (6 commits since branch creation)
88+
└── 1 more commit → 1.0.1-beta.1.post.7 (7 commits since branch creation)
89+
```
6990

7091
## Examples
7192

@@ -188,19 +209,20 @@ gitGraph
188209
commit id: "1.0.1-alpha.54321.post.1"
189210
190211
checkout main
191-
merge hotfix/critical id: "1.0.1" tag: "hotfix released"
212+
merge hotfix/critical id: "1.0.1" tag: "tagged"
192213
193214
checkout develop
194215
merge main id: "1.0.2-beta.1.post.3" tag: "update main"
195216
commit id: "1.0.2-beta.1.post.4"
196217
197218
branch release/1 order: 2
198219
checkout release/1
199-
commit id: "1.0.2-rc.1.post.1"
200-
commit id: "1.0.2-rc.1.post.2"
220+
commit id: "1.0.2-rc.1.post.1" tag: "tagged"
221+
commit id: "1.0.2-rc.1.post.2" tag: "tagged"
222+
commit id: "1.0.2-rc.1.post.2.dev.1729924622"
201223
202224
checkout main
203-
merge release/1 id: "1.1.0" tag: "released"
225+
merge release/1 id: "1.1.0" tag: "tagged"
204226
205227
checkout develop
206228
merge main id: "1.1.1-beta.1.post.1" tag: "update main"
Lines changed: 302 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,302 @@
1+
# Zerv Flow CLI Command Design
2+
3+
**Status**: Planned
4+
**Priority**: High
5+
**Context**: Simplified CLI design for `zerv flow` command, mirroring `zerv version` structure with flow-specific pre-release management.
6+
7+
## Command Structure
8+
9+
```bash
10+
zerv flow [OPTIONS]
11+
```
12+
13+
**Single command only** - no subcommands.
14+
15+
## Core Arguments
16+
17+
### Output Options (same as zerv version)
18+
19+
```bash
20+
-o, --output-format <FORMAT> Output format [default: semver] [possible values: semver, pep440, zerv]
21+
-t, --output-template <TEMPLATE> Custom output template using handlebars syntax
22+
-p, --output-prefix <PREFIX> Add prefix to output version
23+
```
24+
25+
### Input Options (same as zerv version)
26+
27+
```bash
28+
-s, --source <SOURCE> Version source [default: git] [possible values: git, hg, bzr, svn]
29+
-f, --input-format <FORMAT> Input format [default: semver] [possible values: semver, pep440, calver, docker, raw]
30+
-d, --directory <DIR> Repository directory [default: current directory]
31+
```
32+
33+
### Flow-Specific Options
34+
35+
```bash
36+
-l, --pre-release-label <LABEL> Pre-release label [default: auto-detect from branch] [possible values: alpha, beta, rc]
37+
-n, --pre-release-num <NUM> Pre-release number [default: hash from branch name]
38+
--branch-rules <RON> Custom branch rules (RON format) [default: release-only]
39+
--bumped-branch <BRANCH> Override branch name for pre-release resolution (same as zerv version)
40+
--bumped-branch-hash-length <LENGTH> Branch hash length for pre-release numbers [default: 5] [range: 4..16]
41+
--post-mode <TYPE> Post calculation mode [default: tag] [possible values: tag, commit]
42+
--build-context Include build context (+branch.commit) in output [default: true]
43+
--no-build-context Exclude build context from output
44+
--dev-ts Include dev timestamp for dirty working directory [default: auto-detect]
45+
--no-dev-ts Exclude dev timestamp from output
46+
--with-pre-release Include pre-release/post-release but no build context
47+
--base-only Base version only (major.minor.patch)
48+
-v, --verbose Show verbose output including version resolution details
49+
-h, --help Print help
50+
-V, --version Print version
51+
```
52+
53+
## Pre-release Resolution Logic
54+
55+
### Default Behavior (no flags)
56+
57+
- **Label**: `alpha` with hash-based number from branch name (e.g., `feature/auth``alpha.12345`)
58+
- **Number**: Hash derived from branch name using `--bumped-branch-hash-length`
59+
60+
### Post Distance Logic
61+
62+
**Configurable post distance calculation with two methods:**
63+
64+
#### Tag Distance (default)
65+
66+
- **`post`** increments when new tags are created on the branch
67+
- **Reference point**: Last tag created on the branch
68+
- **`post.0`**: Exactly when a new tag is created
69+
- **Untagged commits**: Same `post` number, different `dev.timestamp`
70+
- **Use case**: Release branches where you want to tag specific milestones
71+
72+
```
73+
release/1 created → tag v1.0.1-rc.1.post.1
74+
1 commit → v1.0.1-rc.1.post.1.dev.1729924622 (same post)
75+
2 commits → v1.0.1-rc.1.post.1.dev.1729924623 (same post)
76+
new tag → v1.0.1-rc.1.post.2 (post increments)
77+
```
78+
79+
#### Commit Distance
80+
81+
- **`post`** counts commits since branch creation point
82+
- **Reference point**: Branch creation from tag/branch
83+
- **`post.0`**: Exactly when branch is created
84+
- **All commits**: Increment `post` with each commit
85+
- **Use case**: Development branches tracking total work done
86+
87+
```
88+
develop created from v1.0.0 → 1.0.1-beta.1.post.0
89+
1 commit → 1.0.1-beta.1.post.1
90+
2 commits → 1.0.1-beta.1.post.2
91+
```
92+
93+
**Control via `--post-mode` argument:**
94+
95+
- `--post-mode tag` (default): Tag-based post calculation
96+
- `--post-mode commit`: Commit-based post calculation
97+
98+
### Branch Pattern Detection (`--branch-rules`)
99+
100+
**Configurable branch rules via RON string or use defaults:**
101+
102+
```bash
103+
# Use custom branch rules
104+
zerv flow --branch-rules "[(pattern: \"develop\", pre_release: \"beta\", number: \"1\", post_mode: \"commit\")]"
105+
106+
# Use default rules (no argument needed)
107+
zerv flow --branch-rules
108+
```
109+
110+
**Default rules (when no RON provided):**
111+
112+
```ron
113+
[
114+
(pattern: "develop", pre_release: "beta", number: "1", post_mode: "commit"),
115+
(pattern: "release/*", pre_release: "rc", post_mode: "tag"),
116+
]
117+
```
118+
119+
**Branch rules can specify:**
120+
121+
- **pattern**: Branch name pattern to match
122+
- **pre_release**: Pre-release type (alpha, beta, rc)
123+
- **number**: Fixed number or hash-based
124+
- **post_mode**: Tag or commit distance calculation
125+
126+
**Advanced RON configuration examples:**
127+
128+
```ron
129+
(
130+
[
131+
(pattern: "develop", pre_release: "beta", number: "1", post_mode: "commit"),
132+
(pattern: "release/*", pre_release: "rc", post_mode: "tag"),
133+
(pattern: "feature/*", pre_release: "alpha", post_mode: "tag"),
134+
(pattern: "hotfix/*", pre_release: "alpha", post_mode: "tag"),
135+
],
136+
)
137+
```
138+
139+
**Pattern matching rules:**
140+
141+
- **Exact match**: `develop` matches only `develop` branch
142+
- **Wildcard match**: `release/*` matches branches starting with `release/`
143+
- **Number extraction**: For wildcard patterns, tries to extract number:
144+
- `release/1` → extracts `1`
145+
- `release/1/xxxxx` → extracts `1`
146+
- `release/feature-name` (no number) → uses hash-based numbering
147+
148+
**Branch behaviors (not on tagged commits):**
149+
150+
- `main``1.1.0-alpha.1.post.2+main.2.a1b2c3d`
151+
- `develop``1.0.1-beta.1.post.3+develop.3.c2d3e4f`
152+
- `release/1``1.0.1-rc.1.post.1+release.1.1.e4f5g6h`
153+
- `release/hotfix``1.0.1-rc.12345.post.1+release.hotfix.1.g5h6i7j`
154+
- `feature/auth``1.0.1-alpha.54321.post.2+feature.auth.2.h6i7j8k`
155+
156+
**On tagged commits:** Clean versions (e.g., `1.0.0`, `1.0.1`)
157+
158+
**Branch name processing:**
159+
160+
- Slashes (`/`) converted to dots (`.`): `feature/auth``feature.auth`
161+
- Hash generation uses simplified branch name: `feature.auth``12345`
162+
163+
### Manual Override
164+
165+
**Mutually exclusive with `--pre-release-from-branch`:**
166+
167+
```bash
168+
# Force specific pre-release type and number
169+
zerv flow --pre-release-label beta --pre-release-num 1
170+
171+
# Force rc for release-like branches
172+
zerv flow --pre-release-label rc --pre-release-num 2
173+
174+
# Force alpha for feature branches (uses hash by default)
175+
zerv flow --pre-release-label alpha
176+
```
177+
178+
### Branch Override
179+
180+
**Test different branch scenarios without switching branches:**
181+
182+
```bash
183+
zerv flow --bumped-branch develop --pre-release-from-branch
184+
zerv flow --bumped-branch release/1 --pre-release-from-branch
185+
```
186+
187+
## Output Modes
188+
189+
### Full Output (default)
190+
191+
```
192+
1.0.1-alpha.12345.post.2.dev.1729924622+feature.auth.2.a1b2c3d
193+
```
194+
195+
### Pre-release Output (`--with-pre-release`)
196+
197+
```
198+
1.0.1-alpha.12345.post.2
199+
```
200+
201+
### Base-Only Output (`--base-only`)
202+
203+
```
204+
1.0.1
205+
```
206+
207+
### On Reference Point (post.0)
208+
209+
```
210+
1.0.1-rc.1.post.0 (exactly on branch point/tag)
211+
```
212+
213+
## Format Variations
214+
215+
### SemVer (default)
216+
217+
```
218+
1.0.1-alpha.12345.post.1.dev.1729924622+feature.auth.1.a1b2c3d
219+
```
220+
221+
### PEP440
222+
223+
```
224+
1.0.1a12345.post1.dev1729924622
225+
```
226+
227+
### Zerv (RON format)
228+
229+
```
230+
<zerv ron>
231+
```
232+
233+
## Usage Examples
234+
235+
### Basic Usage
236+
237+
```bash
238+
# Generate flow version with automatic pre-release
239+
zerv flow
240+
241+
# Enable branch pattern detection (GitFlow)
242+
zerv flow --pre-release-from-branch
243+
244+
# Force specific pre-release type
245+
zerv flow --pre-release-label beta
246+
247+
# Include pre-release/post-release but no build context
248+
zerv flow --with-pre-release
249+
250+
# Base version only
251+
zerv flow --base-only
252+
```
253+
254+
### Advanced Usage
255+
256+
```bash
257+
# Complete control over pre-release
258+
zerv flow --bumped-branch release/1 --pre-release-from-branch
259+
260+
# Custom template output
261+
zerv flow --output-template "v{{version}}-{{pre_release}}"
262+
263+
# Different repository directory
264+
zerv flow --directory ../other-repo
265+
266+
# Verbose output
267+
zerv flow --verbose
268+
```
269+
270+
## Future Configuration
271+
272+
**RON configuration files (not in initial implementation):**
273+
274+
```ron
275+
# .zerv.ron
276+
(
277+
branch_patterns: [
278+
(pattern: "develop", pre_release: "beta", number: "1"),
279+
(pattern: "release", pre_release: "rc"),
280+
(pattern: "feature", pre_release: "alpha"),
281+
(pattern: "hotfix", pre_release: "alpha"),
282+
],
283+
)
284+
```
285+
286+
**Usage:**
287+
288+
```bash
289+
zerv flow --config .zerv.ron
290+
```
291+
292+
## Key Design Principles
293+
294+
1. **Mirror zerv version**: Same output/input options structure
295+
2. **Intelligent defaults**: Smart branch-based pre-release detection
296+
3. **Flexible overrides**: Manual control when needed
297+
4. **Honest versioning**: Never hides Git state, always accurate
298+
5. **Clean alternatives**: `--with-pre-release` and `--base-only` for simplified output
299+
300+
---
301+
302+
**Next Steps**: Implement basic `zerv flow` command structure and integrate with existing `zerv version` functions.

0 commit comments

Comments
 (0)