@@ -17,7 +17,21 @@ macro_rules! t {
17
17
} ;
18
18
}
19
19
20
- pub fn repo_init ( ) -> ( TempDir , Repository ) {
20
+ // `repo_test! will
21
+ macro_rules! repo_test {
22
+ ( $test_name: ident, $( $repo_type: ident) ,+ $test_body: block) => {
23
+ paste:: item! {
24
+ $( #[ test]
25
+ fn [ <$test_name _ $repo_type: snake>] ( ) {
26
+ #[ allow( unused_variables) ]
27
+ let ( td, repo) = $crate:: test:: repo_init2( $crate:: test:: RepoType :: $repo_type) ;
28
+ $test_body
29
+ } ) +
30
+ }
31
+ }
32
+ }
33
+
34
+ pub fn repo_init_typical ( ) -> ( TempDir , Repository ) {
21
35
let td = TempDir :: new ( ) . unwrap ( ) ;
22
36
let repo = Repository :: init ( td. path ( ) ) . unwrap ( ) ;
23
37
{
@@ -35,6 +49,31 @@ pub fn repo_init() -> (TempDir, Repository) {
35
49
( td, repo)
36
50
}
37
51
52
+ pub fn repo_init_bare ( ) -> ( TempDir , Repository ) {
53
+ panic ! ( "unimplemented" )
54
+ }
55
+
56
+ pub fn repo_init_bare_worktree ( ) -> ( TempDir , Repository ) {
57
+ panic ! ( "unimplemented" )
58
+ }
59
+
60
+ pub fn repo_init_typical_worktree ( ) -> ( TempDir , Repository ) {
61
+ panic ! ( "unimplemented" )
62
+ }
63
+
64
+ pub fn repo_init ( ) -> ( TempDir , Repository ) {
65
+ repo_init_typical ( )
66
+ }
67
+
68
+ pub fn repo_init2 ( repo_type : RepoType ) -> ( TempDir , Repository ) {
69
+ match repo_type {
70
+ RepoType :: Typical => repo_init_typical ( ) ,
71
+ RepoType :: Bare => repo_init_bare ( ) ,
72
+ RepoType :: BareWorktree => repo_init_bare_worktree ( ) ,
73
+ RepoType :: TypicalWorktree => repo_init_typical_worktree ( ) ,
74
+ }
75
+ }
76
+
38
77
pub fn commit ( repo : & Repository ) -> ( Oid , Oid ) {
39
78
let mut index = t ! ( repo. index( ) ) ;
40
79
let root = repo. path ( ) . parent ( ) . unwrap ( ) ;
@@ -62,6 +101,14 @@ pub fn worktrees_env_init(repo: &Repository) -> (TempDir, Branch<'_>) {
62
101
( wtdir, branch)
63
102
}
64
103
104
+ #[ derive( Debug , Clone , Copy ) ]
105
+ pub enum RepoType {
106
+ Typical ,
107
+ TypicalWorktree ,
108
+ Bare ,
109
+ BareWorktree ,
110
+ }
111
+
65
112
#[ cfg( windows) ]
66
113
pub fn realpath ( original : & Path ) -> io:: Result < PathBuf > {
67
114
Ok ( original. to_path_buf ( ) )
0 commit comments