@Test
public void testClone() throws IOException {
final File parentFolder = createTempDirectory();
final File gitFolder = new File( parentFolder, "mytest.git" );
final Git origin = JGitUtil.newRepository( gitFolder, true );
commit( origin, "user_branch", "name", "name@example.com", "commit!", null, null, false, new HashMap<String, File>() {{
put( "file2.txt", tempFile( "temp2222" ) );
}} );
commit( origin, "master", "name", "name@example.com", "commit", null, null, false, new HashMap<String, File>() {{
put( "file.txt", tempFile( "temp" ) );
}} );
commit( origin, "master", "name", "name@example.com", "commit", null, null, false, new HashMap<String, File>() {{
put( "file3.txt", tempFile( "temp3" ) );
}} );
final File gitClonedFolder = new File( parentFolder, "myclone.git" );
final Git git = cloneRepository( gitClonedFolder, origin.getRepository().getDirectory().toString(), true, CredentialsProvider.getDefault() );
assertThat( git ).isNotNull();
assertThat( branchList( git, ALL ) ).hasSize( 4 );
assertThat( branchList( git, ALL ).get( 0 ).getName() ).isEqualTo( "refs/heads/master" );
assertThat( branchList( git, ALL ).get( 1 ).getName() ).isEqualTo( "refs/heads/user_branch" );
assertThat( branchList( git, ALL ).get( 2 ).getName() ).isEqualTo( "refs/remotes/origin/master" );
assertThat( branchList( git, ALL ).get( 3 ).getName() ).isEqualTo( "refs/remotes/origin/user_branch" );
}