|
65 | 65 | - **DIAGRAMS**: Copy mermaid diagrams from `.claude/plan/32-zerv-flow-implementation-plan.md` |
66 | 66 | - ✅ **Schema Variants**: 10+ standard schema presets only (no CalVer support) |
67 | 67 | - ✅ **Branch Rules**: Configurable pattern matching (default GitFlow) for pre-release automation |
68 | | - - **Pre-release Control**: Labels (alpha/beta/rc), numbers, hash-based identification |
69 | | - - **Post Mode Options**: Tag distance vs commit distance calculation modes |
| 68 | + - ✅ **Pre-release Control**: Labels (alpha/beta/rc), numbers, hash-based identification |
| 69 | + - ✅ **Post Mode Options**: Tag distance vs commit distance calculation modes |
70 | 70 | - **zerv version**: Manual control with 4 main capability areas: |
71 | | - - **Schema Variants**: 20+ presets (standard, calver families) and custom RON schemas |
72 | | - - **VCS Overrides**: Override tag version, distance, dirty state, branch, commit data |
73 | | - - **Version Bumping**: Field-based bumps (major/minor/patch) and schema-based bumps |
| 71 | + - ✅ **Schema Variants**: 20+ presets (standard, calver families) and custom RON schemas |
| 72 | + - ✅ **VCS Overrides**: Override tag version, distance, dirty state, branch, commit data |
| 73 | + - ✅ **Version Bumping**: Field-based bumps (major/minor/patch) and schema-based bumps |
74 | 74 | - **Component Overrides**: Fine-grained control over individual version components |
75 | 75 | - **zerv check**: Version validation for different formats |
76 | 76 | - **Input/Output & Piping**: Shared capabilities for both zerv version and zerv flow: |
@@ -150,20 +150,78 @@ Every code example in documentation must have a corresponding test with referenc |
150 | 150 | 4. **Validate**: Ensure examples exactly match test outputs |
151 | 151 | 5. **Coordinated Updates**: Update tests first, then documentation to match |
152 | 152 |
|
| 153 | +### 🚨 Critical Implementation Patterns & Pitfalls |
| 154 | + |
| 155 | +**BRANCH HASH PATTERNS - AVOID REGEX FALLBACKS**: |
| 156 | + |
| 157 | +❌ **WRONG**: Using `{regex:\\d+}` for branch hashes |
| 158 | + |
| 159 | +```rust |
| 160 | +// BAD - This is lazy and unpredictable |
| 161 | +"1.0.1-alpha.{regex:\\d+}.post.1+feature.test.1.g{hex:7}" |
| 162 | +``` |
| 163 | + |
| 164 | +✅ **CORRECT**: Use `expect_branch_hash()` for predictable hash generation |
| 165 | +
|
| 166 | +```rust |
| 167 | +// GOOD - Use actual hash values from expect_branch_hash() |
| 168 | +let feature_test_hash = expect_branch_hash("feature/test", 5, "60124"); |
| 169 | +assert_command( |
| 170 | + "flow --source stdin --distance 42", |
| 171 | + &format!( |
| 172 | + "1.0.1-alpha.{}.post.42+feature.test.42.g{{hex:7}}", |
| 173 | + feature_test_hash |
| 174 | + ), |
| 175 | +); |
| 176 | +``` |
| 177 | + |
| 178 | +**GIT COMMIT HASH PATTERNS**: |
| 179 | + |
| 180 | +- ✅ **For generated commits**: Use `g{{hex:7}}` in format strings |
| 181 | +- ✅ **For manual overrides**: Use exact hash (e.g., `.a1b2c3d` without `g` prefix) |
| 182 | + |
| 183 | +**LOOK AT EXISTING EXAMPLES FIRST**: |
| 184 | + |
| 185 | +Before writing new tests, study these reference files: |
| 186 | + |
| 187 | +1. **Branch Hash Examples**: `tests/integration_tests/flow/docs/quick_start.rs` - Shows proper `expect_branch_hash()` usage |
| 188 | +2. **Hash Generation**: `src/cli/flow/test_utils.rs` - Understanding hash calculation |
| 189 | +3. **Existing Override Tests**: `tests/integration_tests/flow/docs/override_controls.rs` - Working examples of all patterns |
| 190 | +4. **Branch Rules**: `tests/integration_tests/flow/docs/branch_rules.rs` - Shows `release/` branch number extraction vs hash fallback |
| 191 | + |
| 192 | +**COMMON PITFALLS TO AVOID**: |
| 193 | + |
| 194 | +1. **Never use `{regex:\\d+}`** - Always use `expect_branch_hash()` for predictable results |
| 195 | +2. **Don't guess hash values** - Run the test first to get actual hash, then update expected value |
| 196 | +3. **Don't mix hash patterns** - Consistently use either numeric hashes or `{{hex:7}}` format |
| 197 | +4. **Don't assume override behavior** - Test actual behavior, don't rely on assumptions |
| 198 | +5. **Always check branch patterns** - `release/42` → `rc.42` (number extraction) vs `release/candidate` → `rc.{hash}` (hash fallback) |
| 199 | + |
| 200 | +**WORKFLOW FOR NEW DOCUMENTATION EXAMPLES**: |
| 201 | + |
| 202 | +1. **Study existing patterns** in `tests/integration_tests/flow/docs/` |
| 203 | +2. **Run the actual command** to see real output before writing test |
| 204 | +3. **Get the actual hash** using `expect_branch_hash("branch-name", 5, "12345")` |
| 205 | +4. **Match the test assertion pattern** exactly from existing working examples |
| 206 | +5. **Use realistic hex values** in documentation (e.g., `ga1b2c3d`, `g8f7e6d5`) |
| 207 | + |
153 | 208 | **Infrastructure in Place**: |
154 | 209 |
|
155 | 210 | - ✅ **TestScenario**: Chainable test framework with CLI command execution |
156 | 211 | - ✅ **Pattern Assertion System**: `{hex:7}`, `{timestamp:now}`, `{regex:pattern}` support |
157 | 212 | - ✅ **Documentation Standards**: Comprehensive guidelines in `.claude/ref/documentation-maintenance.md` |
158 | 213 | - ✅ **Maintenance Comments**: Professional "Corresponding test:" format |
| 214 | +- ✅ **Hash Generation**: `expect_branch_hash()` for predictable branch hash generation |
159 | 215 |
|
160 | 216 | **File Structure**: |
161 | 217 |
|
162 | 218 | ``` |
163 | 219 | tests/integration_tests/flow/docs/ |
164 | 220 | ├── mod.rs |
165 | 221 | ├── test_utils.rs # TestScenario implementation |
166 | | -├── quick_start.rs # Quick Start documentation tests |
| 222 | +├── quick_start.rs # Quick Start documentation tests (BEST PATTERN REFERENCE) |
| 223 | +├── branch_rules.rs # Branch pattern and hash examples |
| 224 | +├── override_controls.rs # Override examples with proper hash patterns |
167 | 225 | └── tmp.rs # assert_commands functionality (temporary) |
168 | 226 | ``` |
169 | 227 |
|
|
0 commit comments