Skip to content

Commit 263bb20

Browse files
committed
test: set default branch to master
1 parent eed629b commit 263bb20

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

src/test/java/me/qoomon/gitversioning/commons/GitUtilTest.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class GitUtilTest {
2929
void status_clean() throws GitAPIException {
3030

3131
// given
32-
Git git = Git.init().setDirectory(tempDir.toFile()).call();
32+
Git git = Git.init().setInitialBranch(MASTER).setDirectory(tempDir.toFile()).call();
3333

3434
// when
3535
Status status = GitUtil.status(git.getRepository());
@@ -42,7 +42,7 @@ void status_clean() throws GitAPIException {
4242
void status_dirty() throws GitAPIException, IOException {
4343

4444
// given
45-
Git git = Git.init().setDirectory(tempDir.toFile()).call();
45+
Git git = Git.init().setInitialBranch(MASTER).setDirectory(tempDir.toFile()).call();
4646

4747
boolean dummyFileCreated = new File(tempDir.toFile(), "README.md").createNewFile();
4848
assertThat(dummyFileCreated).isTrue();
@@ -58,7 +58,7 @@ void status_dirty() throws GitAPIException, IOException {
5858
void branch_emptyRepo() throws GitAPIException, IOException {
5959

6060
// given
61-
Git git = Git.init().setDirectory(tempDir.toFile()).call();
61+
Git git = Git.init().setInitialBranch(MASTER).setDirectory(tempDir.toFile()).call();
6262

6363
// when
6464
String branch = GitUtil.branch(git.getRepository());
@@ -71,7 +71,7 @@ void branch_emptyRepo() throws GitAPIException, IOException {
7171
void branch_nonEmptyRepo() throws GitAPIException, IOException {
7272

7373
// given
74-
Git git = Git.init().setDirectory(tempDir.toFile()).call();
74+
Git git = Git.init().setInitialBranch(MASTER).setDirectory(tempDir.toFile()).call();
7575
RevCommit givenCommit = git.commit().setMessage("initial commit").setAllowEmpty(true).call();
7676
String givenBranchName = "feature";
7777
git.branchCreate().setName(givenBranchName).setStartPoint(givenCommit).call();
@@ -88,7 +88,7 @@ void branch_nonEmptyRepo() throws GitAPIException, IOException {
8888
void tag_pointsAt_emptyRepo() throws GitAPIException, IOException {
8989

9090
// given
91-
Git git = Git.init().setDirectory(tempDir.toFile()).call();
91+
Git git = Git.init().setInitialBranch(MASTER).setDirectory(tempDir.toFile()).call();
9292

9393
// when
9494
List<String> tags = GitUtil.tag_pointsAt(git.getRepository(), HEAD);
@@ -101,7 +101,7 @@ void tag_pointsAt_emptyRepo() throws GitAPIException, IOException {
101101
void tag_pointsAt_noTags() throws GitAPIException, IOException {
102102

103103
// given
104-
Git git = Git.init().setDirectory(tempDir.toFile()).call();
104+
Git git = Git.init().setInitialBranch(MASTER).setDirectory(tempDir.toFile()).call();
105105

106106
git.commit().setMessage("initial commit").setAllowEmpty(true).call();
107107

@@ -116,7 +116,7 @@ void tag_pointsAt_noTags() throws GitAPIException, IOException {
116116
void tag_pointsAt_oneTag() throws GitAPIException, IOException {
117117

118118
// given
119-
Git git = Git.init().setDirectory(tempDir.toFile()).call();
119+
Git git = Git.init().setInitialBranch(MASTER).setDirectory(tempDir.toFile()).call();
120120

121121
RevCommit givenCommit = git.commit().setMessage("initial commit").setAllowEmpty(true).call();
122122
String givenTagName = "v1.0.0";
@@ -133,7 +133,7 @@ void tag_pointsAt_oneTag() throws GitAPIException, IOException {
133133
void tag_pointsAt_multipleTags() throws GitAPIException, IOException {
134134

135135
// given
136-
Git git = Git.init().setDirectory(tempDir.toFile()).call();
136+
Git git = Git.init().setInitialBranch(MASTER).setDirectory(tempDir.toFile()).call();
137137

138138
RevCommit givenCommit = git.commit().setMessage("initial commit").setAllowEmpty(true).call();
139139
String givenTagName1 = "111";
@@ -154,7 +154,7 @@ void tag_pointsAt_multipleTags() throws GitAPIException, IOException {
154154
void tag_pointsAt_lightweightTag() throws GitAPIException, IOException {
155155

156156
// given
157-
Git git = Git.init().setDirectory(tempDir.toFile()).call();
157+
Git git = Git.init().setInitialBranch(MASTER).setDirectory(tempDir.toFile()).call();
158158

159159
RevCommit givenCommit = git.commit().setMessage("initial commit").setAllowEmpty(true).call();
160160

@@ -172,7 +172,7 @@ void tag_pointsAt_lightweightTag() throws GitAPIException, IOException {
172172
void revParse_emptyRepo() throws GitAPIException, IOException {
173173

174174
// given
175-
Git git = Git.init().setDirectory(tempDir.toFile()).call();
175+
Git git = Git.init().setInitialBranch(MASTER).setDirectory(tempDir.toFile()).call();
176176

177177
// when
178178
String ref = GitUtil.revParse(git.getRepository(), HEAD);
@@ -185,7 +185,7 @@ void revParse_emptyRepo() throws GitAPIException, IOException {
185185
void revParse_nonEmptyRepo() throws GitAPIException, IOException {
186186

187187
// given
188-
Git git = Git.init().setDirectory(tempDir.toFile()).call();
188+
Git git = Git.init().setInitialBranch(MASTER).setDirectory(tempDir.toFile()).call();
189189

190190
RevCommit givenCommit = git.commit().setMessage("initial commit").setAllowEmpty(true).call();
191191

@@ -200,7 +200,7 @@ void revParse_nonEmptyRepo() throws GitAPIException, IOException {
200200
void headSituation_emptyRepo() throws GitAPIException, IOException {
201201

202202
// Given
203-
Git git = Git.init().setDirectory(tempDir.toFile()).call();
203+
Git git = Git.init().setInitialBranch(MASTER).setDirectory(tempDir.toFile()).call();
204204

205205
// When
206206
GitSituation gitSituation = GitUtil.situation(git.getRepository().getDirectory());
@@ -218,7 +218,7 @@ void headSituation_emptyRepo() throws GitAPIException, IOException {
218218
void headSituation_onBranch() throws GitAPIException, IOException {
219219

220220
// Given
221-
Git git = Git.init().setDirectory(tempDir.toFile()).call();
221+
Git git = Git.init().setInitialBranch(MASTER).setDirectory(tempDir.toFile()).call();
222222
RevCommit givenCommit = git.commit().setMessage("init").setAllowEmpty(true).call();
223223

224224
// When
@@ -237,7 +237,7 @@ void headSituation_onBranch() throws GitAPIException, IOException {
237237
void headSituation_onBranchWithTag() throws GitAPIException, IOException {
238238

239239
// Given
240-
Git git = Git.init().setDirectory(tempDir.toFile()).call();
240+
Git git = Git.init().setInitialBranch(MASTER).setDirectory(tempDir.toFile()).call();
241241
RevCommit givenCommit = git.commit().setMessage("init").setAllowEmpty(true).call();
242242
String givenTag = "v1";
243243
git.tag().setName(givenTag).setObjectId(givenCommit).call();
@@ -258,7 +258,7 @@ void headSituation_onBranchWithTag() throws GitAPIException, IOException {
258258
void headSituation_detachedHead() throws GitAPIException, IOException {
259259

260260
// Given
261-
Git git = Git.init().setDirectory(tempDir.toFile()).call();
261+
Git git = Git.init().setInitialBranch(MASTER).setDirectory(tempDir.toFile()).call();
262262
RevCommit givenCommit = git.commit().setMessage("init").setAllowEmpty(true).call();
263263
git.checkout().setName(givenCommit.getName()).call();
264264

@@ -278,7 +278,7 @@ void headSituation_detachedHead() throws GitAPIException, IOException {
278278
void headSituation_detachedHeadWithTag() throws GitAPIException, IOException {
279279

280280
// Given
281-
Git git = Git.init().setDirectory(tempDir.toFile()).call();
281+
Git git = Git.init().setInitialBranch(MASTER).setDirectory(tempDir.toFile()).call();
282282
RevCommit givenCommit = git.commit().setMessage("init").setAllowEmpty(true).call();
283283
String givenTag = "v1";
284284
git.tag().setName(givenTag).setObjectId(givenCommit).call();
@@ -300,7 +300,7 @@ void headSituation_detachedHeadWithTag() throws GitAPIException, IOException {
300300
void situation_annotatedTagOnMaster() throws Exception, IOException {
301301

302302
// Given
303-
Git git = Git.init().setDirectory(tempDir.toFile()).call();
303+
Git git = Git.init().setInitialBranch(MASTER).setDirectory(tempDir.toFile()).call();
304304
RevCommit givenCommit = git.commit().setMessage("initial commit").setAllowEmpty(true).call();
305305

306306
String givenTag = "v1";
@@ -322,7 +322,7 @@ void situation_annotatedTagOnMaster() throws Exception, IOException {
322322
void situation_annotatedTagDetached() throws Exception {
323323

324324
// Given
325-
Git git = Git.init().setDirectory(tempDir.toFile()).call();
325+
Git git = Git.init().setInitialBranch(MASTER).setDirectory(tempDir.toFile()).call();
326326
RevCommit givenCommit = git.commit().setMessage("initial commit").setAllowEmpty(true).call();
327327

328328
String givenTag = "v1";
@@ -345,7 +345,7 @@ void situation_annotatedTagDetached() throws Exception {
345345
void situation_lightweightTagOnMaster() throws Exception {
346346

347347
// Given
348-
Git git = Git.init().setDirectory(tempDir.toFile()).call();
348+
Git git = Git.init().setInitialBranch(MASTER).setDirectory(tempDir.toFile()).call();
349349
RevCommit givenCommit = git.commit().setMessage("initial commit").setAllowEmpty(true).call();
350350

351351
String givenTag = "v1";
@@ -367,7 +367,7 @@ void situation_lightweightTagOnMaster() throws Exception {
367367
void situation_lightweightTagDetached() throws Exception {
368368

369369
// Given
370-
Git git = Git.init().setDirectory(tempDir.toFile()).call();
370+
Git git = Git.init().setInitialBranch(MASTER).setDirectory(tempDir.toFile()).call();
371371
RevCommit givenCommit = git.commit().setMessage("initial commit").setAllowEmpty(true).call();
372372

373373
String givenTag = "v1";
@@ -390,7 +390,7 @@ void situation_lightweightTagDetached() throws Exception {
390390
void situation_multipleTags() throws Exception {
391391

392392
// Given
393-
Git git = Git.init().setDirectory(tempDir.toFile()).call();
393+
Git git = Git.init().setInitialBranch(MASTER).setDirectory(tempDir.toFile()).call();
394394
git.commit().setMessage("initial commit").setAllowEmpty(true).call();
395395

396396
String givenTag1 = "v2";

src/test/java/me/qoomon/gradle/gitversioning/GitVersioningPluginTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import java.nio.file.Path;
1717

1818
import static org.assertj.core.api.Assertions.assertThat;
19+
import static org.eclipse.jgit.lib.Constants.MASTER;
1920
import static org.gradle.util.GFileUtils.writeFile;
2021

2122
class GitVersioningPluginTest {
@@ -50,7 +51,7 @@ void runVersionTask() throws GitAPIException {
5051
void apply() throws GitAPIException, IOException {
5152

5253
// given
53-
Git git = Git.init().setDirectory(projectDir.toFile()).call();
54+
Git git = Git.init().setInitialBranch(MASTER).setDirectory(projectDir.toFile()).call();
5455
RevCommit commit = git.commit().setMessage("initial commit").setAllowEmpty(true).call();
5556

5657
Project project = ProjectBuilder.builder().withProjectDir(projectDir.toFile()).build();

0 commit comments

Comments
 (0)