Skip to content

Commit 10a745b

Browse files
authored
feat: improve version bump overall (#100)
1 parent a999352 commit 10a745b

File tree

16 files changed

+608
-1090
lines changed

16 files changed

+608
-1090
lines changed

.dev/15-implementation-todo-plan.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ This document outlines the implementation plan to transform the current additive
2222

2323
## Implementation Phases
2424

25-
### Phase 1: Core Infrastructure Changes
25+
### Phase 1: Core Infrastructure Changes
2626

2727
#### 1.1 Update Component Precedence System ✅
2828

@@ -532,7 +532,7 @@ pub mod reset;
532532
- `src/cli/version/args.rs` - Remove override processing (move to ZervVars)
533533
- All test files - Update method calls to use `process_*` methods
534534

535-
### Phase 2: Pre-release Component Enhancements
535+
### Phase 2: Pre-release Component Enhancements
536536

537537
#### 2.1 Add `--bump-pre-release-label` Flag ✅
538538

@@ -778,7 +778,7 @@ let label = PreReleaseLabel::from_str_or_alpha(pre_l.as_str());
778778
- **Consistency**: Same patterns across codebase
779779
- **Maintainability**: Single source of truth for label handling
780780

781-
#### 2.2 Update Pre-release Creation Logic
781+
#### 2.2 Update Pre-release Creation Logic
782782

783783
**Priority**: High
784784
**Effort**: Low
@@ -794,9 +794,9 @@ let label = PreReleaseLabel::from_str_or_alpha(pre_l.as_str());
794794
- `src/version/zerv/bump/vars_secondary.rs` - Update `bump_pre_release` method
795795
- `src/error.rs` - Add validation error types
796796

797-
### Phase 3: Reset Behavior Implementation
797+
### Phase 3: Reset Behavior Implementation
798798

799-
#### 3.1 Implement Version Component Reset Logic
799+
#### 3.1 Implement Version Component Reset Logic
800800

801801
**Priority**: High
802802
**Effort**: High
@@ -949,7 +949,7 @@ mod tests {
949949
- Test files - Add reset behavior tests using process\_\* methods
950950
- This phase mainly adds comprehensive testing for the reset behavior
951951

952-
#### 3.2 Implement Epoch Reset Logic
952+
#### 3.2 Implement Epoch Reset Logic
953953

954954
**Priority**: Medium
955955
**Effort**: Medium
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Reset Logic Schema Component Issue
2+
3+
## Issue Summary
4+
5+
During test refactoring in `src/version/zerv/bump/vars_primary.rs`, we discovered a design flaw in the reset logic for version bumping.
6+
7+
## Problem Description
8+
9+
When bumping major/minor/patch versions, the current reset logic only resets `ZervVars` fields but doesn't handle schema components that depend on those fields.
10+
11+
### Current Behavior
12+
13+
- `ZervVars.pre_release` gets reset to `None`
14+
- `Component::VarField("pre_release")` in schema remains untouched ❌
15+
- Build metadata and other non-ZervVars components persist ❌
16+
17+
### Expected Behavior (Semantic Versioning)
18+
19+
- Major bump: `1.5.2-rc.1+build.456``2.0.0` (all lower precedence removed)
20+
- Minor bump: `1.5.2-rc.1+build.456``1.6.0` (patch, pre-release, build removed)
21+
22+
## Technical Details
23+
24+
### Components Affected
25+
26+
- `Component::String(String)` - static, should remain
27+
- `Component::Integer(u64)` - static, should remain
28+
- `Component::VarField(String)` - **ISSUE**: should be reset when referenced ZervVar is reset
29+
- `Component::VarTimestamp(String)` - static pattern, should remain
30+
31+
### Current Reset Implementation
32+
33+
Located in `/src/version/zerv/bump/reset.rs`:
34+
35+
- Only resets `ZervVars` fields (major, minor, patch, pre_release, post, dev, epoch)
36+
- Doesn't touch schema components in `extra_core` or `build`
37+
38+
## Test Cases That Revealed the Issue
39+
40+
```rust
41+
// These tests currently fail due to the bug:
42+
#[case("1.0.0+build.123", 1, "2.0.0")] // Expected: no build metadata
43+
#[case("1.5.2-rc.1+build.456", 1, "2.0.0")] // Expected: no pre-release or build
44+
45+
// Current (incorrect) behavior:
46+
#[case("1.0.0+build.123", 1, "2.0.0+build.123")] // Build metadata persists
47+
#[case("1.5.2-rc.1+build.456", 1, "2.0.0+build.456")] // Build metadata persists
48+
```
49+
50+
## Proposed Solutions
51+
52+
### Option A: Extend Reset Logic
53+
54+
Modify `reset_lower_precedence_components` to also clean schema components:
55+
56+
- Remove `VarField` components that reference reset ZervVars
57+
- Keep static `String`/`Integer` components
58+
59+
### Option B: Schema-Aware Reset
60+
61+
Create separate method to reset schema components based on precedence rules.
62+
63+
### Option C: Architectural Change
64+
65+
Move all dynamic data into `ZervVars` so reset logic is centralized.
66+
67+
## Impact
68+
69+
This affects semantic versioning compliance and could lead to incorrect version strings being generated during automated bumping.
70+
71+
## Status
72+
73+
- **Discovered**: During test refactoring
74+
- **Severity**: Medium (affects SemVer compliance)
75+
- **Complexity**: High (requires careful design consideration)
76+
- **Decision**: Deferred for later architectural review
77+
78+
## Files Involved
79+
80+
- `src/version/zerv/bump/reset.rs` - Current reset implementation
81+
- `src/version/zerv/bump/vars_primary.rs` - Test cases that revealed issue
82+
- `src/version/zerv/components.rs` - Component definitions
83+
- `src/version/semver/from_zerv.rs` - Conversion logic that shows the problem
84+
85+
## Next Steps
86+
87+
1. Review overall reset architecture
88+
2. Decide on approach (A, B, or C above)
89+
3. Implement solution with comprehensive tests
90+
4. Ensure SemVer compliance across all scenarios

0 commit comments

Comments
 (0)