@@ -51,6 +51,18 @@ static VALIDATION_REGEX: &'static str = pomsky!(
51
51
) ?
52
52
) ;
53
53
54
+ #[ derive( Debug , Serialize , Deserialize ) ]
55
+ pub enum PostHead {
56
+ Post ,
57
+ Rev ,
58
+ }
59
+
60
+ #[ derive( Debug , Serialize , Deserialize ) ]
61
+ pub struct PostHeader {
62
+ post_head : Option < PostHead > ,
63
+ post_num : Option < u32 >
64
+ }
65
+
54
66
#[ derive( Debug , Serialize , Deserialize ) ]
55
67
pub enum PreHeader {
56
68
/// Present in 1.1alpha1 or 1.1a1 both are represented the same way
@@ -74,10 +86,11 @@ pub struct VersionRelease {
74
86
75
87
#[ derive( Debug , Serialize , Deserialize ) ]
76
88
pub struct PackageVersion {
89
+ pub original : String ,
77
90
epoch : Option < u32 > ,
78
91
release : VersionRelease ,
79
92
pre : Option < PreHeader > ,
80
- post : Option < String > ,
93
+ post : Option < PostHeader > ,
81
94
dev : Option < String > ,
82
95
local : Option < String > ,
83
96
}
@@ -143,9 +156,40 @@ impl PackageVersion {
143
156
None => None ,
144
157
} ;
145
158
146
- // TODO!
147
- let post: Option < String > = match version_match. name ( "post" ) {
148
- Some ( v) => Some ( v. as_str ( ) . to_string ( ) ) ,
159
+ let post: Option < PostHeader > = match version_match. name ( "post" ) {
160
+ Some ( _) => {
161
+ let post_num: Option < u32 > = match version_match. name ( "post_n1" ) {
162
+ Some ( v) => {
163
+ Some ( v. as_str ( ) . parse :: < u32 > ( ) ?)
164
+ }
165
+ None => {
166
+ match version_match. name ( "post_n2" ) {
167
+ Some ( v) => {
168
+ Some ( v. as_str ( ) . parse :: < u32 > ( ) ?)
169
+ } ,
170
+ _ => None ,
171
+ }
172
+ }
173
+ } ;
174
+
175
+ let post_head: Option < PostHead > = match version_match. name ( "post_l" ) {
176
+ Some ( v) => {
177
+ match v. as_str ( ) {
178
+ "post" => Some ( PostHead :: Post ) ,
179
+ "rev" => Some ( PostHead :: Rev ) ,
180
+ "r" => Some ( PostHead :: Rev ) ,
181
+ // This branch Should be impossible (see regex-group post_l)
182
+ _ => None ,
183
+ }
184
+ }
185
+ None => None
186
+ } ;
187
+
188
+ Some ( PostHeader {
189
+ post_head,
190
+ post_num,
191
+ } )
192
+ } ,
149
193
None => None ,
150
194
} ;
151
195
@@ -162,6 +206,7 @@ impl PackageVersion {
162
206
} ;
163
207
164
208
Ok ( Self {
209
+ original : version. to_string ( ) ,
165
210
epoch,
166
211
release,
167
212
pre,
0 commit comments