File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -142,15 +142,29 @@ impl TryFrom<&'_ PackageId> for Crate {
142
142
Ok ( Crate :: GitHub ( GitHubRepo {
143
143
org : org. to_string ( ) ,
144
144
name : repo_name. to_string ( ) ,
145
- sha : rev. pretty_ref ( false ) . map ( |rev| rev. to_string ( ) ) ,
145
+ sha : match rev {
146
+ GitReference :: Rev ( rev)
147
+ if rev. chars ( ) . all ( |c| c. is_ascii_hexdigit ( ) ) =>
148
+ {
149
+ Some ( rev. to_string ( ) )
150
+ }
151
+ _ => None ,
152
+ } ,
146
153
} ) )
147
154
} else {
148
155
bail ! ( "Github Git URL doesn't have a valid path" )
149
156
}
150
157
} else {
151
158
Ok ( Crate :: Git ( GitRepo {
152
159
url : url. to_string ( ) ,
153
- sha : rev. pretty_ref ( false ) . map ( |rev| rev. to_string ( ) ) ,
160
+ sha : match rev {
161
+ GitReference :: Rev ( rev)
162
+ if rev. chars ( ) . all ( |c| c. is_ascii_hexdigit ( ) ) =>
163
+ {
164
+ Some ( rev. to_string ( ) )
165
+ }
166
+ _ => None ,
167
+ } ,
154
168
} ) )
155
169
}
156
170
} else {
@@ -391,13 +405,13 @@ mod tests {
391
405
"git+ssh://git@github.com/rust-lang/regex.git?branch=dev#regex@1.4.3" => Crate :: GitHub ( GitHubRepo {
392
406
org: "rust-lang" . to_string( ) ,
393
407
name: "regex" . to_string( ) ,
394
- sha: Some ( "branch=dev" . to_string ( ) )
408
+ sha: None
395
409
} ) ,
396
410
397
411
"git+https://gitlab.com/dummy_org/dummy?rev=9823f01cf4948a41279f6a3febcf793130cab4f6" => Crate :: Git ( GitRepo {
398
412
url: "https://gitlab.com/dummy_org/dummy"
399
413
. to_string( ) ,
400
- sha: Some ( "rev= 9823f01cf4948a41279f6a3febcf793130cab4f6" . to_string( ) )
414
+ sha: Some ( "9823f01cf4948a41279f6a3febcf793130cab4f6" . to_string( ) )
401
415
} ) ,
402
416
403
417
"file:///path/to/my/project/foo" => Crate :: Path ( "/path/to/my/project/foo" . to_string( ) ) ,
You can’t perform that action at this time.
0 commit comments