@@ -5,7 +5,7 @@ use gitbutler_reference::{LocalRefname, Refname};
55use gitbutler_repo:: RepositoryExt ;
66use tempfile:: TempDir ;
77
8- use super :: { VAR_NO_CLEANUP , init_opts} ;
8+ use super :: { VAR_NO_CLEANUP , commit_with_signature , init_opts, maybe_find_branch_by_refname } ;
99
1010pub fn temp_dir ( ) -> TempDir {
1111 tempfile:: tempdir ( ) . unwrap ( )
@@ -36,8 +36,8 @@ impl Default for TestProject {
3636 let mut index = local_repository. index ( ) . expect ( "failed to get index" ) ;
3737 let oid = index. write_tree ( ) . expect ( "failed to write tree" ) ;
3838 let signature = git2:: Signature :: now ( "test" , "test@email.com" ) . unwrap ( ) ;
39- let repo : & git2 :: Repository = & local_repository ;
40- repo . commit_with_signature (
39+ commit_with_signature (
40+ & local_repository ,
4141 Some ( & "refs/heads/master" . parse ( ) . unwrap ( ) ) ,
4242 & signature,
4343 & signature,
@@ -137,17 +137,12 @@ impl TestProject {
137137 Refname :: Remote ( remote) => format ! ( "refs/heads/{}" , remote. branch( ) ) . parse ( ) . unwrap ( ) ,
138138 _ => "INVALID" . parse ( ) . unwrap ( ) ,
139139 } ;
140- let branch = self
141- . remote_repo
142- . maybe_find_branch_by_refname ( & branch_name)
143- . unwrap ( ) ;
140+ let branch = maybe_find_branch_by_refname ( & self . remote_repo , & branch_name) . unwrap ( ) ;
144141 let branch_commit = branch. unwrap ( ) . get ( ) . peel_to_commit ( ) . unwrap ( ) ;
145142
146143 let master_branch = {
147144 let name: Refname = "refs/heads/master" . parse ( ) . unwrap ( ) ;
148- self . remote_repo
149- . maybe_find_branch_by_refname ( & name)
150- . unwrap ( )
145+ maybe_find_branch_by_refname ( & self . remote_repo , & name) . unwrap ( )
151146 } ;
152147 let master_branch_commit = master_branch. unwrap ( ) . get ( ) . peel_to_commit ( ) . unwrap ( ) ;
153148
@@ -213,15 +208,13 @@ impl TestProject {
213208 Refname :: Remote ( remote) => format ! ( "refs/heads/{}" , remote. branch( ) ) . parse ( ) ?,
214209 _ => "INVALID" . parse ( ) ?,
215210 } ;
216- let branch = self
217- . remote_repo
218- . maybe_find_branch_by_refname ( & branch_name) ?
219- . expect ( "branch exists" ) ;
211+ let branch =
212+ maybe_find_branch_by_refname ( & self . remote_repo , & branch_name) ?. expect ( "branch exists" ) ;
220213 let branch_commit = branch. get ( ) . peel_to_commit ( ) ?;
221214
222215 let master_branch = {
223216 let name: Refname = "refs/heads/master" . parse ( ) ?;
224- self . remote_repo . maybe_find_branch_by_refname ( & name) ?
217+ maybe_find_branch_by_refname ( & self . remote_repo , & name) ?
225218 } ;
226219 let master_branch_commit = master_branch
227220 . as_ref ( )
@@ -248,8 +241,8 @@ impl TestProject {
248241 self . remote_repo . find_tree ( tree_id. to_git2 ( ) ) ?
249242 } ;
250243
251- let repo : & git2 :: Repository = & self . remote_repo ;
252- repo . commit_with_signature (
244+ commit_with_signature (
245+ & self . remote_repo ,
253246 Some ( & "refs/heads/master" . parse ( ) ?) ,
254247 & branch_commit. author ( ) ,
255248 & branch_commit. committer ( ) ,
@@ -280,7 +273,7 @@ impl TestProject {
280273 pub fn checkout ( & self , branch : & LocalRefname ) {
281274 let refname: Refname = branch. into ( ) ;
282275 let head_commit = self . local_repo . head ( ) . unwrap ( ) . peel_to_commit ( ) . unwrap ( ) ;
283- let tree = match self . local_repo . maybe_find_branch_by_refname ( & refname) {
276+ let tree = match maybe_find_branch_by_refname ( & self . local_repo , & refname) {
284277 Ok ( branch) => match branch {
285278 Some ( branch) => branch. get ( ) . peel_to_tree ( ) . unwrap ( ) ,
286279 None => {
@@ -310,8 +303,8 @@ impl TestProject {
310303 let oid = index. write_tree ( ) . expect ( "failed to write tree" ) ;
311304 let signature = git2:: Signature :: now ( "test" , "test@email.com" ) . unwrap ( ) ;
312305 let refname: Refname = head. name ( ) . unwrap ( ) . parse ( ) . unwrap ( ) ;
313- let repo : & git2 :: Repository = & self . local_repo ;
314- repo . commit_with_signature (
306+ commit_with_signature (
307+ & self . local_repo ,
315308 Some ( & refname) ,
316309 & signature,
317310 & signature,
0 commit comments