31
31
import java .util .List ;
32
32
import java .util .Map ;
33
33
import java .util .stream .Stream ;
34
- import java .util .stream .StreamSupport ;
35
34
36
35
import static org .assertj .core .api .Assertions .assertThatNoException ;
37
36
import static org .assertj .core .api .Assertions .assertThatThrownBy ;
@@ -126,7 +125,6 @@ void copyExistingGitRepo(@TempDir File sampleRepo) throws GitAPIException, IOExc
126
125
Git .cloneRepository ()
127
126
.setURI (gitRepoURI .toString ())
128
127
.setDirectory (tempDir )
129
- .setBranch ("main" )
130
128
.setTransportConfigCallback (GitServerContainerTest ::configureWithPasswordAndNoHostKeyChecking )
131
129
.call ()
132
130
);
@@ -149,7 +147,6 @@ void copyExistingGitRepoWithCustomRepoName(@TempDir File sampleRepo) throws IOEx
149
147
Git .cloneRepository ()
150
148
.setURI (gitRepoURI .toString ())
151
149
.setDirectory (tempDir )
152
- .setBranch ("main" )
153
150
.setTransportConfigCallback (GitServerContainerTest ::configureWithPasswordAndNoHostKeyChecking )
154
151
.call ()
155
152
);
@@ -170,7 +167,6 @@ void setupGitRepo(GitServerVersions gitServer) {
170
167
Git .cloneRepository ()
171
168
.setURI (gitRepoURI .toString ())
172
169
.setDirectory (tempDir )
173
- .setBranch ("main" )
174
170
.setTransportConfigCallback (GitServerContainerTest ::configureWithPasswordAndNoHostKeyChecking )
175
171
.call ()
176
172
);
@@ -189,7 +185,6 @@ void pubKeyAuth(GitServerVersions gitServer) {
189
185
Git .cloneRepository ()
190
186
.setURI (gitRepoURI .toString ())
191
187
.setDirectory (tempDir )
192
- .setBranch ("main" )
193
188
.setTransportConfigCallback (configureWithSshIdentityAndNoHostVerification (containerUnderTest .getSshClientIdentity ()))
194
189
.call ()
195
190
);
@@ -210,12 +205,30 @@ void strictHostKeyVerifivation(GitServerVersions gitServer) {
210
205
Git .cloneRepository ()
211
206
.setURI (gitRepoURI .toString ())
212
207
.setDirectory (tempDir )
213
- .setBranch ("main" )
214
208
.setTransportConfigCallback (configureWithSshIdentityAndHostKey (containerUnderTest .getSshClientIdentity (), containerUnderTest .getHostKey ()))
215
209
.call ()
216
210
);
217
211
}
218
212
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
+
219
232
@ NotNull
220
233
private TransportConfigCallback configureWithSshIdentityAndHostKey (SshIdentity sshIdentity , SshHostKey hostKey ) {
221
234
return transport -> {
0 commit comments