3131import java .util .List ;
3232import java .util .Map ;
3333import java .util .stream .Stream ;
34- import java .util .stream .StreamSupport ;
3534
3635import static org .assertj .core .api .Assertions .assertThatNoException ;
3736import static org .assertj .core .api .Assertions .assertThatThrownBy ;
@@ -126,7 +125,6 @@ void copyExistingGitRepo(@TempDir File sampleRepo) throws GitAPIException, IOExc
126125 Git .cloneRepository ()
127126 .setURI (gitRepoURI .toString ())
128127 .setDirectory (tempDir )
129- .setBranch ("main" )
130128 .setTransportConfigCallback (GitServerContainerTest ::configureWithPasswordAndNoHostKeyChecking )
131129 .call ()
132130 );
@@ -149,7 +147,6 @@ void copyExistingGitRepoWithCustomRepoName(@TempDir File sampleRepo) throws IOEx
149147 Git .cloneRepository ()
150148 .setURI (gitRepoURI .toString ())
151149 .setDirectory (tempDir )
152- .setBranch ("main" )
153150 .setTransportConfigCallback (GitServerContainerTest ::configureWithPasswordAndNoHostKeyChecking )
154151 .call ()
155152 );
@@ -170,7 +167,6 @@ void setupGitRepo(GitServerVersions gitServer) {
170167 Git .cloneRepository ()
171168 .setURI (gitRepoURI .toString ())
172169 .setDirectory (tempDir )
173- .setBranch ("main" )
174170 .setTransportConfigCallback (GitServerContainerTest ::configureWithPasswordAndNoHostKeyChecking )
175171 .call ()
176172 );
@@ -189,7 +185,6 @@ void pubKeyAuth(GitServerVersions gitServer) {
189185 Git .cloneRepository ()
190186 .setURI (gitRepoURI .toString ())
191187 .setDirectory (tempDir )
192- .setBranch ("main" )
193188 .setTransportConfigCallback (configureWithSshIdentityAndNoHostVerification (containerUnderTest .getSshClientIdentity ()))
194189 .call ()
195190 );
@@ -210,12 +205,30 @@ void strictHostKeyVerifivation(GitServerVersions gitServer) {
210205 Git .cloneRepository ()
211206 .setURI (gitRepoURI .toString ())
212207 .setDirectory (tempDir )
213- .setBranch ("main" )
214208 .setTransportConfigCallback (configureWithSshIdentityAndHostKey (containerUnderTest .getSshClientIdentity (), containerUnderTest .getHostKey ()))
215209 .call ()
216210 );
217211 }
218212
213+ @ ParameterizedTest
214+ @ EnumSource (GitServerVersions .class )
215+ void defaultBranch (GitServerVersions gitServer ) throws GitAPIException , IOException {
216+ var containerUnderTest = new GitServerContainer (gitServer .getDockerImageName ());
217+
218+ containerUnderTest .start ();
219+
220+ URI gitRepoURI = containerUnderTest .getGitRepoURIAsSSH ();
221+
222+ Git repo = Git .cloneRepository ()
223+ .setURI (gitRepoURI .toString ())
224+ .setDirectory (tempDir )
225+ .setTransportConfigCallback (GitServerContainerTest ::configureWithPasswordAndNoHostKeyChecking )
226+ .call ();
227+
228+ String currentBranch = repo .getRepository ().getBranch ();
229+ assertThat (currentBranch ).isEqualTo ("main" );
230+ }
231+
219232 @ NotNull
220233 private TransportConfigCallback configureWithSshIdentityAndHostKey (SshIdentity sshIdentity , SshHostKey hostKey ) {
221234 return transport -> {
0 commit comments