@@ -17,7 +17,21 @@ macro_rules! t {
1717 } ;
1818}
1919
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 ) {
2135 let td = TempDir :: new ( ) . unwrap ( ) ;
2236 let repo = Repository :: init ( td. path ( ) ) . unwrap ( ) ;
2337 {
@@ -35,6 +49,31 @@ pub fn repo_init() -> (TempDir, Repository) {
3549 ( td, repo)
3650}
3751
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+
3877pub fn commit ( repo : & Repository ) -> ( Oid , Oid ) {
3978 let mut index = t ! ( repo. index( ) ) ;
4079 let root = repo. path ( ) . parent ( ) . unwrap ( ) ;
@@ -62,6 +101,14 @@ pub fn worktrees_env_init(repo: &Repository) -> (TempDir, Branch<'_>) {
62101 ( wtdir, branch)
63102}
64103
104+ #[ derive( Debug , Clone , Copy ) ]
105+ pub enum RepoType {
106+ Typical ,
107+ TypicalWorktree ,
108+ Bare ,
109+ BareWorktree ,
110+ }
111+
65112#[ cfg( windows) ]
66113pub fn realpath ( original : & Path ) -> io:: Result < PathBuf > {
67114 Ok ( original. to_path_buf ( ) )
0 commit comments