1
- use gix_revision:: spec;
2
-
3
1
use crate :: spec:: parse:: { parse, try_parse} ;
4
2
5
3
#[ test]
@@ -10,15 +8,37 @@ fn at_by_itself_is_shortcut_for_head() {
10
8
}
11
9
12
10
#[ test]
13
- fn multiple_ats_are_invalid_but_may_cause_callbacks ( ) {
14
- let err = try_parse ( "@@" ) . unwrap_err ( ) ;
15
- assert ! ( matches!( err, spec:: parse:: Error :: AtNeedsCurlyBrackets { input} if input == "@" ) ) ;
11
+ fn at_is_allowed ( ) {
12
+ for name in [ "a@b" , "@branch" , "branch@" , "@@" , "@inner@" ] {
13
+ let rec = parse ( name) ;
14
+ assert ! ( rec. kind. is_none( ) ) ;
15
+ assert_eq ! ( rec. get_ref( 0 ) , name) ;
16
+ assert_eq ! ( rec. find_ref[ 1 ] , None ) ;
17
+ }
18
+ }
19
+
20
+ #[ test]
21
+ fn at_in_ranges_is_allowed ( ) {
22
+ let input = "@@@.." ;
23
+ let rec = parse ( input) ;
24
+ assert_eq ! ( rec. kind, Some ( gix_revision:: spec:: Kind :: RangeBetween ) ) ;
25
+ assert_eq ! ( rec. get_ref( 0 ) , "@@@" ) ;
26
+ assert_eq ! ( rec. get_ref( 1 ) , "HEAD" ) ;
27
+
28
+ let input = "@@...@@" ;
29
+ let rec = parse ( input) ;
30
+ assert_eq ! ( rec. kind, Some ( gix_revision:: spec:: Kind :: ReachableToMergeBase ) ) ;
31
+ assert_eq ! ( rec. get_ref( 0 ) , "@@" ) ;
32
+ assert_eq ! ( rec. get_ref( 1 ) , "@@" ) ;
16
33
}
17
34
18
35
#[ test]
19
- fn lonely_at_after_ref_is_invalid ( ) {
20
- let err = try_parse ( "HEAD@" ) . unwrap_err ( ) ;
21
- assert ! ( matches!( err, spec:: parse:: Error :: AtNeedsCurlyBrackets { input} if input == "@" ) ) ;
36
+ fn strange_revspecs_do_not_panic ( ) {
37
+ let err = try_parse ( ".@." ) . unwrap_err ( ) ;
38
+ assert ! ( matches!(
39
+ err,
40
+ gix_revision:: spec:: parse:: Error :: AtNeedsCurlyBrackets { input } if input == "@."
41
+ ) ) ;
22
42
}
23
43
24
44
#[ test]
0 commit comments