Skip to content

Commit 34f5866

Browse files
committed
docs: update phase 2 plan
1 parent f077094 commit 34f5866

File tree

4 files changed

+651
-139
lines changed

4 files changed

+651
-139
lines changed

.dev/00-current-state.md

Lines changed: 0 additions & 139 deletions
This file was deleted.

.dev/00-new-cli-design.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ Main version processing pipeline with composable operations.
1818

1919
Validation-only command for version strings.
2020

21+
### `zerv compare <version1> <op> <version2> --format <format>`
22+
23+
Version comparison command with format-specific ordering rules.
24+
2125
## Pipeline Stages
2226

2327
### 1. Input Sources (`--source`)
@@ -67,6 +71,10 @@ zerv version
6771
# Validate version
6872
zerv check 1.2.3
6973

74+
# Compare versions (format required due to different ordering rules)
75+
zerv compare 1.2.3 gt 1.2.2 --format semver
76+
zerv compare 2.0.0a1 lt 2.0.0 --format pep440
77+
7078
# Standard format output
7179
zerv version --output-format pep440
7280

@@ -195,8 +203,62 @@ zerv version --output-format pep440 > VERSION.txt
195203

196204
# Jenkins
197205
zerv version --output-template "{{major}}.{{minor}}.{{patch}}" > version.properties
206+
207+
# Version comparison in CI
208+
CURRENT=$(git describe --tags --abbrev=0)
209+
NEW=$(zerv version --output-format semver)
210+
if zerv compare "$NEW" gt "$CURRENT" --format semver; then
211+
echo "Deploying new version: $NEW"
212+
else
213+
echo "Version $NEW is not newer than $CURRENT"
214+
exit 1
215+
fi
216+
```
217+
218+
## Version Comparison Command
219+
220+
### `zerv compare <version1> <op> <version2> --format <format>`
221+
222+
**Operators** (following `dpkg --compare-versions` pattern):
223+
224+
- `gt` - greater than
225+
- `lt` - less than
226+
- `eq` - equal
227+
- `ge` - greater than or equal
228+
- `le` - less than or equal
229+
230+
**Format Required**: Version ordering differs significantly between standards:
231+
232+
- **PEP440**: `2.0.0a1 < 2.0.0b1 < 2.0.0rc1 < 2.0.0`
233+
- **SemVer**: `2.0.0-alpha.1 < 2.0.0-beta.1 < 2.0.0-rc.1 < 2.0.0`
234+
235+
**Examples**:
236+
237+
```bash
238+
# SemVer comparison
239+
zerv compare 1.2.3 gt 1.2.2 --format semver # exit 0 (true)
240+
zerv compare 1.2.3 lt 1.2.2 --format semver # exit 1 (false)
241+
zerv compare 2.0.0-alpha.1 lt 2.0.0 --format semver # exit 0 (true)
242+
243+
# PEP440 comparison
244+
zerv compare 1.2.3 eq 1.2.3 --format pep440 # exit 0 (true)
245+
zerv compare 2.0.0a1 lt 2.0.0 --format pep440 # exit 0 (true)
246+
zerv compare 1.2.3 ge 1.2.2 --format pep440 # exit 0 (true)
198247
```
199248

249+
**Use Cases**:
250+
251+
- CI/CD pipeline version validation
252+
- Release automation scripts
253+
- Version constraint checking
254+
- Deployment safety checks
255+
256+
**Exit Codes**:
257+
258+
- `0` - Comparison is true
259+
- `1` - Comparison is false
260+
- `2` - Error (invalid version, unknown format, etc.)
261+
200262
## Benefits
201263

202264
### 1. **Unified Architecture**

.dev/02-current-state.md

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# Current Implementation State
2+
3+
## Phase 1 Complete ✅ - Git VCS Integration
4+
5+
### 1. Universal Version System (`src/version/zerv/`)
6+
7+
**Complete Implementation**:
8+
9+
- `Zerv` - Universal version representation combining format template and data
10+
- `ZervFormat` - Component-based format definition (core, extra_core, build)
11+
- `ZervVars` - Variable storage for all version data
12+
- `Component` - Format components (String, Integer, VarField, VarTimestamp, VarCustom)
13+
14+
**Key Features**:
15+
16+
- Format-agnostic component system
17+
- Variable reference system for reusable data
18+
- Support for semantic versions, timestamps, VCS metadata
19+
- Extensible custom variables via HashMap
20+
21+
### 2. PEP440 Implementation (`src/version/pep440/`)
22+
23+
**Production-Ready**:
24+
25+
- ✅ Parsing from strings with comprehensive regex
26+
- ✅ Display formatting with normalization
27+
- ✅ Conversion to/from Zerv format
28+
- ✅ Ordering and comparison
29+
- ✅ All PEP440 features: epoch, pre-release, post, dev, local versions
30+
31+
### 3. SemVer Implementation (`src/version/semver/`)
32+
33+
**Production-Ready**:
34+
35+
- ✅ Core structure with major.minor.patch
36+
- ✅ Pre-release identifiers (string/integer)
37+
- ✅ Build metadata support
38+
- ✅ Conversion to/from Zerv format
39+
- ✅ Display formatting and parsing
40+
41+
### 4. Git VCS Integration (`src/vcs/`)
42+
43+
**Complete Implementation**:
44+
45+
- ✅ VCS trait system with clean abstraction
46+
- ✅ Git repository detection and validation
47+
- ✅ Tag discovery and filtering (`get_latest_tag`)
48+
- ✅ Distance calculation from tag to HEAD
49+
- ✅ Commit hash extraction (short/full)
50+
- ✅ Dirty state detection
51+
- ✅ Branch name extraction
52+
- ✅ Timestamp handling (commit + tag)
53+
- ✅ Shallow clone detection with warnings
54+
- ✅ Docker-based testing for isolation
55+
- ✅ Comprehensive error handling
56+
57+
### 5. Development Infrastructure
58+
59+
**Production-Quality**:
60+
61+
- ✅ 97.36% code coverage (2732/2806 lines)
62+
- ✅ Docker-based Git integration tests
63+
- ✅ Fast local tests (no external dependencies)
64+
- ✅ Makefile workflow for development
65+
- ✅ Automated formatting with rustfmt
66+
- ✅ Linting with clippy
67+
- ✅ Comprehensive error handling with `ZervError`
68+
69+
## Phase 2 In Progress 🎯 - Pipeline CLI Interface
70+
71+
### What's Built ✅
72+
73+
**CLI Framework**:
74+
75+
- ✅ Basic CLI structure (`src/cli/`) with clap integration
76+
- ✅ Command framework foundation
77+
- ✅ Error handling system ready
78+
79+
### What's Missing ❌
80+
81+
**Pipeline Implementation**:
82+
83+
-`zerv version --source git` command
84+
- ❌ Integration between VCS data and version generation
85+
- ❌ RON schema parsing for custom schemas
86+
-`zerv-default` schema preset
87+
- ❌ VCS data to `ZervVars` mapping
88+
- ❌ Pattern matching for tag parsing
89+
90+
## Phase 3 Not Started ⏳ - Output Templates
91+
92+
**Missing Features**:
93+
94+
- ❌ Template engine for `--output-template`
95+
- ❌ Variable substitution in templates
96+
- ❌ Template validation
97+
98+
## Architecture Assessment
99+
100+
### Strengths
101+
102+
1. **Exceptional Foundation**: Universal Zerv format with complete format implementations
103+
2. **Production-Ready VCS**: Comprehensive Git integration with Docker testing
104+
3. **High Code Quality**: 97.36% test coverage, consistent error handling
105+
4. **Clean Architecture**: Excellent separation of concerns and abstractions
106+
5. **Type Safety**: Strong Rust typing prevents runtime errors
107+
108+
### Current State
109+
110+
- **Phase 1 (Git VCS)**: ✅ **COMPLETE** - Production-ready implementation
111+
- **Phase 2 (CLI)**: 🎯 **IN PROGRESS** - Framework ready, needs pipeline implementation
112+
- **Phase 3 (Templates)**: ⏳ **NOT STARTED**
113+
114+
## Next Critical Steps
115+
116+
### Immediate (Phase 2 Completion)
117+
118+
1. **VCS-Version Integration**: Connect `VcsData` to `ZervVars`
119+
2. **CLI Pipeline**: Implement `zerv version --source git`
120+
3. **Schema System**: Add `zerv-default` preset and RON parsing
121+
4. **Tag Parsing**: Pattern matching for version extraction from tags
122+
123+
### Success Criteria for Phase 2
124+
125+
- `zerv version` generates versions from Git repository state
126+
- `--source git` explicitly uses Git VCS
127+
- Basic pipeline architecture functional
128+
- Integration tests pass for end-to-end workflow
129+
130+
## Code Quality Metrics
131+
132+
- **Test Coverage**: 97.36% (2732/2806 lines covered)
133+
- **Architecture**: Clean, modular, well-abstracted
134+
- **Error Handling**: Comprehensive with `ZervError`
135+
- **Performance**: Fast parsing, efficient memory usage
136+
- **Maintainability**: Excellent separation of concerns
137+
138+
The project has a **exceptionally solid foundation** with Phase 1 complete. The VCS integration is more comprehensive than many production tools. Ready for rapid Phase 2 completion.

0 commit comments

Comments
 (0)