Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse2017-03-12 22:44:11 -0400
committerMatthias Sohn2017-03-16 16:13:19 -0400
commit6b025671a8ab3dba438aa16a004ee378c1863bce (patch)
tree0bdb5bd831c38433a4a0cd31b4b23afb06aa55ca /org.eclipse.egit.core.test/src
parent4c829541d483ea6b94d0bb40c8106fb5e3dca281 (diff)
downloadegit-6b025671a8ab3dba438aa16a004ee378c1863bce.tar.gz
egit-6b025671a8ab3dba438aa16a004ee378c1863bce.tar.xz
egit-6b025671a8ab3dba438aa16a004ee378c1863bce.zip
Open Git instances in try-with-resource in tests
Change-Id: I881cab412475d692f02e2d5bf76677c08fb3ac54 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.egit.core.test/src')
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/indexdiff/IndexDiffCacheTest.java4
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/storage/GitBlobStorageTest.java3
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/AbstractCacheTest.java7
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java6
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java24
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitSubscriberResourceMappingContextTest.java6
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/StagedChangeCacheTest.java130
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/ThreeWayDiffEntryTest.java90
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/WorkingTreeChangeCacheTest.java34
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/dto/GitSynchronizeDataTest.java6
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitProjectSetCapabilityTest.java12
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java25
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/internal/mapping/HistoryTest.java25
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/ModelTestCase.java4
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/CloneOperationTest.java43
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/CommitOperationTest.java22
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/MergeOperationTest.java5
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/RewordCommitsOperationTest.java5
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/SquashCommitsOperationTest.java10
19 files changed, 282 insertions, 179 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/indexdiff/IndexDiffCacheTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/indexdiff/IndexDiffCacheTest.java
index 4f7cc2160..c6866cb7d 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/indexdiff/IndexDiffCacheTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/indexdiff/IndexDiffCacheTest.java
@@ -93,7 +93,9 @@ public class IndexDiffCacheTest extends GitTestCase {
if (!indexDiffData.getUntracked().contains(path))
fail("IndexDiffData did not contain aFile as untracked");
// This call should trigger an indexDiffChanged event
- new Git(repository).add().addFilepattern(path).call();
+ try (Git git = new Git(repository)) {
+ git.add().addFilepattern(path).call();
+ }
IndexDiffData indexDiffData2 = waitForListenerCalled();
if (indexDiffData2.getUntracked().contains(path))
fail("IndexDiffData contains aFile as untracked");
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/storage/GitBlobStorageTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/storage/GitBlobStorageTest.java
index 01e5ee47f..16418ebd5 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/storage/GitBlobStorageTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/storage/GitBlobStorageTest.java
@@ -87,11 +87,10 @@ public class GitBlobStorageTest extends GitTestCase {
ConnectProviderOperation connectOp = new ConnectProviderOperation(proj, singleProjectGitDir);
connectOp.execute(progress);
- try {
+ try (Git git = new Git(singleProjectRepo)) {
IFile file = proj.getFile("file");
file.create(new ByteArrayInputStream("data".getBytes("UTF-8")), 0,
progress);
- Git git = new Git(singleProjectRepo);
git.add().addFilepattern(".").call();
RevCommit commit = git.commit().setAuthor("JUnit", "junit@jgit.org").setAll(true).setMessage("First commit").call();
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/AbstractCacheTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/AbstractCacheTest.java
index 51da51db3..881fc728c 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/AbstractCacheTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/AbstractCacheTest.java
@@ -43,9 +43,10 @@ public abstract class AbstractCacheTest extends LocalDiskRepositoryTestCase {
public void setUp() throws Exception {
super.setUp();
db = createWorkRepository();
- Git git = new Git(db);
- git.commit().setMessage("initial commit").call();
- git.tag().setName(INITIAL_TAG).call();
+ try (Git git = new Git(db)) {
+ git.commit().setMessage("initial commit").call();
+ git.tag().setName(INITIAL_TAG).call();
+ }
}
protected void assertFileAddition(Map<String, Change> result, String path, String fileName) {
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java
index 564a91035..088e07af8 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java
@@ -61,8 +61,10 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
repo = RepositoryMapping.getMapping(iProject).getRepository();
// make initial commit
- new Git(repo).commit().setAuthor("JUnit", "junit@jgit.org")
- .setMessage("Initial commit").call();
+ try (Git git = new Git(repo)) {
+ git.commit().setAuthor("JUnit", "junit@jgit.org")
+ .setMessage("Initial commit").call();
+ }
}
@After
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java
index 7c0614c21..a3d75a777 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java
@@ -85,8 +85,10 @@ public class GitResourceVariantTreeTest extends GitTestCase {
@Test
public void shouldReturnOneRoot() throws Exception {
// when
- new Git(repo).commit().setAuthor("JUnit", "junit@egit.org")
- .setMessage("Initial commit").call();
+ try (Git git = new Git(repo)) {
+ git.commit().setAuthor("JUnit", "junit@egit.org")
+ .setMessage("Initial commit").call();
+ }
GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, HEAD,
false);
GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);
@@ -117,8 +119,10 @@ public class GitResourceVariantTreeTest extends GitTestCase {
IProject secondIProject = secondProject.project;
// add connect project with repository
new ConnectProviderOperation(secondIProject, gitDir).execute(null);
- new Git(repo).commit().setAuthor("JUnit", "junit@egit.org")
- .setMessage("Initial commit").call();
+ try (Git git = new Git(repo)) {
+ git.commit().setAuthor("JUnit", "junit@egit.org")
+ .setMessage("Initial commit").call();
+ }
GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, HEAD,
false);
GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);
@@ -158,8 +162,10 @@ public class GitResourceVariantTreeTest extends GitTestCase {
@Test
public void shouldReturnNullResourceVariant() throws Exception {
// when
- new Git(repo).commit().setAuthor("JUnit", "junit@egit.org")
- .setMessage("Initial commit").call();
+ try (Git git = new Git(repo)) {
+ git.commit().setAuthor("JUnit", "junit@egit.org")
+ .setMessage("Initial commit").call();
+ }
GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, MASTER,
false);
GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);
@@ -184,8 +190,10 @@ public class GitResourceVariantTreeTest extends GitTestCase {
IPackageFragment iPackage = project.createPackage("org.egit.test");
IType mainJava = project.createType(iPackage, "Main.java",
"class Main {}");
- new Git(repo).commit().setAuthor("JUnit", "junit@egit.org")
- .setMessage("Initial commit").call();
+ try (Git git = new Git(repo)) {
+ git.commit().setAuthor("JUnit", "junit@egit.org")
+ .setMessage("Initial commit").call();
+ }
GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, MASTER,
false);
GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitSubscriberResourceMappingContextTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitSubscriberResourceMappingContextTest.java
index dec2db6e8..c8a5107d9 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitSubscriberResourceMappingContextTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitSubscriberResourceMappingContextTest.java
@@ -58,8 +58,10 @@ public class GitSubscriberResourceMappingContextTest extends GitTestCase {
repo = RepositoryMapping.getMapping(iProject).getRepository();
// make initial commit
- new Git(repo).commit().setAuthor("JUnit", "junit@jgit.org")
- .setMessage("Initial commit").call();
+ try (Git git = new Git(repo)) {
+ git.commit().setAuthor("JUnit", "junit@jgit.org")
+ .setMessage("Initial commit").call();
+ }
}
@Test
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/StagedChangeCacheTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/StagedChangeCacheTest.java
index cfbc3e870..393fe5b44 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/StagedChangeCacheTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/StagedChangeCacheTest.java
@@ -25,7 +25,9 @@ public class StagedChangeCacheTest extends AbstractCacheTest {
public void shouldListSingleWorkspaceAddition() throws Exception {
// given
writeTrashFile(db, "a.txt", "trash");
- new Git(db).add().addFilepattern("a.txt").call();
+ try (Git git = new Git(db)) {
+ git.add().addFilepattern("a.txt").call();
+ }
// when
Map<String, Change> result = StagedChangeCache.build(db);
@@ -40,7 +42,9 @@ public class StagedChangeCacheTest extends AbstractCacheTest {
// given
writeTrashFile(db, "a.txt", "trash");
writeTrashFile(db, "b.txt", "trash");
- new Git(db).add().addFilepattern("a.txt").addFilepattern("b.txt").call();
+ try (Git git = new Git(db)) {
+ git.add().addFilepattern("a.txt").addFilepattern("b.txt").call();
+ }
// when
Map<String, Change> result = StagedChangeCache.build(db);
@@ -55,7 +59,9 @@ public class StagedChangeCacheTest extends AbstractCacheTest {
public void shouldListSingleWorkspaceAdditionInFolder() throws Exception {
// given
writeTrashFile(db, "folder/a.txt", "trash");
- new Git(db).add().addFilepattern("folder/a.txt").call();
+ try (Git git = new Git(db)) {
+ git.add().addFilepattern("folder/a.txt").call();
+ }
// when
Map<String, Change> result = StagedChangeCache.build(db);
@@ -70,7 +76,10 @@ public class StagedChangeCacheTest extends AbstractCacheTest {
// given
writeTrashFile(db, "folder/a.txt", "trash");
writeTrashFile(db, "folder/b.txt", "trash");
- new Git(db).add().addFilepattern("folder/a.txt").addFilepattern("folder/b.txt").call();
+ try (Git git = new Git(db)) {
+ git.add().addFilepattern("folder/a.txt")
+ .addFilepattern("folder/b.txt").call();
+ }
// when
Map<String, Change> result = StagedChangeCache.build(db);
@@ -84,11 +93,12 @@ public class StagedChangeCacheTest extends AbstractCacheTest {
@Test
public void shouldListSingleWorkspaceDeletion() throws Exception {
// given
- Git git = new Git(db);
- writeTrashFile(db, "a.txt", "trash");
- git.add().addFilepattern("a.txt").call();
- git.commit().setMessage("initial add").call();
- git.rm().addFilepattern("a.txt").call();
+ try (Git git = new Git(db)) {
+ writeTrashFile(db, "a.txt", "trash");
+ git.add().addFilepattern("a.txt").call();
+ git.commit().setMessage("initial add").call();
+ git.rm().addFilepattern("a.txt").call();
+ }
// when
Map<String, Change> result = StagedChangeCache.build(db);
@@ -101,12 +111,13 @@ public class StagedChangeCacheTest extends AbstractCacheTest {
@Test
public void shouldListTwoWorkspaceDeletions() throws Exception {
// given
- Git git = new Git(db);
- writeTrashFile(db, "a.txt", "trash");
- writeTrashFile(db, "b.txt", "trash");
- git.add().addFilepattern("a.txt").addFilepattern("b.txt").call();
- git.commit().setMessage("new commit").call();
- git.rm().addFilepattern("a.txt").addFilepattern("b.txt").call();
+ try (Git git = new Git(db)) {
+ writeTrashFile(db, "a.txt", "trash");
+ writeTrashFile(db, "b.txt", "trash");
+ git.add().addFilepattern("a.txt").addFilepattern("b.txt").call();
+ git.commit().setMessage("new commit").call();
+ git.rm().addFilepattern("a.txt").addFilepattern("b.txt").call();
+ }
// when
Map<String, Change> result = StagedChangeCache.build(db);
@@ -120,11 +131,12 @@ public class StagedChangeCacheTest extends AbstractCacheTest {
@Test
public void shouldListSingleWorkspaceDeletionInFolder() throws Exception {
// given
- Git git = new Git(db);
- writeTrashFile(db, "folder/a.txt", "trash");
- git.add().addFilepattern("folder/a.txt").call();
- git.commit().setMessage("new commit").call();
- git.rm().addFilepattern("folder/a.txt").call();
+ try (Git git = new Git(db)) {
+ writeTrashFile(db, "folder/a.txt", "trash");
+ git.add().addFilepattern("folder/a.txt").call();
+ git.commit().setMessage("new commit").call();
+ git.rm().addFilepattern("folder/a.txt").call();
+ }
// when
Map<String, Change> result = StagedChangeCache.build(db);
@@ -137,13 +149,15 @@ public class StagedChangeCacheTest extends AbstractCacheTest {
@Test
public void shouldListTwoWorkspaceDeletionsInFolder() throws Exception {
// given
- Git git = new Git(db);
- writeTrashFile(db, "folder/a.txt", "trash");
- writeTrashFile(db, "folder/b.txt", "trash");
- git.add().addFilepattern("folder/a.txt").addFilepattern("folder/b.txt").call();
- git.commit().setMessage("new commit").call();
- git.rm().addFilepattern("folder/a.txt").call();
- git.rm().addFilepattern("folder/b.txt").call();
+ try (Git git = new Git(db)) {
+ writeTrashFile(db, "folder/a.txt", "trash");
+ writeTrashFile(db, "folder/b.txt", "trash");
+ git.add().addFilepattern("folder/a.txt")
+ .addFilepattern("folder/b.txt").call();
+ git.commit().setMessage("new commit").call();
+ git.rm().addFilepattern("folder/a.txt").call();
+ git.rm().addFilepattern("folder/b.txt").call();
+ }
// when
Map<String, Change> result = StagedChangeCache.build(db);
@@ -157,12 +171,13 @@ public class StagedChangeCacheTest extends AbstractCacheTest {
@Test
public void shouldListSingleWorkspaceChange() throws Exception {
// given
- Git git = new Git(db);
- writeTrashFile(db, "a.txt", "trash");
- git.add().addFilepattern("a.txt").call();
- git.commit().setMessage("initial a.txt commit").call();
- writeTrashFile(db, "a.txt", "modification");
- git.add().addFilepattern("a.txt").call();
+ try (Git git = new Git(db)) {
+ writeTrashFile(db, "a.txt", "trash");
+ git.add().addFilepattern("a.txt").call();
+ git.commit().setMessage("initial a.txt commit").call();
+ writeTrashFile(db, "a.txt", "modification");
+ git.add().addFilepattern("a.txt").call();
+ }
// when
Map<String, Change> result = StagedChangeCache.build(db);
@@ -175,14 +190,15 @@ public class StagedChangeCacheTest extends AbstractCacheTest {
@Test
public void shouldListTwoWorkspaceChanges() throws Exception {
// given
- Git git = new Git(db);
- writeTrashFile(db, "a.txt", "trash");
- writeTrashFile(db, "b.txt", "trash");
- git.add().addFilepattern("a.txt").addFilepattern("b.txt").call();
- git.commit().setMessage("new commmit").call();
- writeTrashFile(db, "a.txt", "modification");
- writeTrashFile(db, "b.txt", "modification");
- git.add().addFilepattern("a.txt").addFilepattern("b.txt").call();
+ try (Git git = new Git(db)) {
+ writeTrashFile(db, "a.txt", "trash");
+ writeTrashFile(db, "b.txt", "trash");
+ git.add().addFilepattern("a.txt").addFilepattern("b.txt").call();
+ git.commit().setMessage("new commmit").call();
+ writeTrashFile(db, "a.txt", "modification");
+ writeTrashFile(db, "b.txt", "modification");
+ git.add().addFilepattern("a.txt").addFilepattern("b.txt").call();
+ }
// when
Map<String, Change> result = StagedChangeCache.build(db);
@@ -196,12 +212,13 @@ public class StagedChangeCacheTest extends AbstractCacheTest {
@Test
public void shouldListSingleWorkspaceChangeInFolder() throws Exception {
// given
- Git git = new Git(db);
- writeTrashFile(db, "folder/a.txt", "trash");
- git.add().addFilepattern("folder/a.txt").call();
- git.commit().setMessage("new commit").call();
- writeTrashFile(db, "folder/a.txt", "modification");
- git.add().addFilepattern("folder/a.txt").call();
+ try (Git git = new Git(db)) {
+ writeTrashFile(db, "folder/a.txt", "trash");
+ git.add().addFilepattern("folder/a.txt").call();
+ git.commit().setMessage("new commit").call();
+ writeTrashFile(db, "folder/a.txt", "modification");
+ git.add().addFilepattern("folder/a.txt").call();
+ }
// when
Map<String, Change> result = StagedChangeCache.build(db);
@@ -214,14 +231,17 @@ public class StagedChangeCacheTest extends AbstractCacheTest {
@Test
public void shouldListTwoWorkspaceChagneInFolder() throws Exception {
// given
- Git git = new Git(db);
- writeTrashFile(db, "folder/a.txt", "trash");
- writeTrashFile(db, "folder/b.txt", "trash");
- git.add().addFilepattern("folder/a.txt").addFilepattern("folder/b.txt").call();
- git.commit().setMessage("new commit").call();
- writeTrashFile(db, "folder/a.txt", "modification");
- writeTrashFile(db, "folder/b.txt", "modification");
- git.add().addFilepattern("folder/a.txt").addFilepattern("folder/b.txt").call();
+ try (Git git = new Git(db)) {
+ writeTrashFile(db, "folder/a.txt", "trash");
+ writeTrashFile(db, "folder/b.txt", "trash");
+ git.add().addFilepattern("folder/a.txt")
+ .addFilepattern("folder/b.txt").call();
+ git.commit().setMessage("new commit").call();
+ writeTrashFile(db, "folder/a.txt", "modification");
+ writeTrashFile(db, "folder/b.txt", "modification");
+ git.add().addFilepattern("folder/a.txt")
+ .addFilepattern("folder/b.txt").call();
+ }
// when
Map<String, Change> result = StagedChangeCache.build(db);
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/ThreeWayDiffEntryTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/ThreeWayDiffEntryTest.java
index f1e6a28bd..e26d57c77 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/ThreeWayDiffEntryTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/ThreeWayDiffEntryTest.java
@@ -43,9 +43,11 @@ public class ThreeWayDiffEntryTest extends LocalDiskRepositoryTestCase {
public void shouldListOutgoingAddition() throws Exception {
// given
writeTrashFile("a.txt", "content");
- Git git = new Git(db);
- git.add().addFilepattern("a.txt").call();
- RevCommit c = git.commit().setMessage("initial commit").call();
+ RevCommit c;
+ try (Git git = new Git(db)) {
+ git.add().addFilepattern("a.txt").call();
+ c = git.commit().setMessage("initial commit").call();
+ }
// when
try (TreeWalk walk = new TreeWalk(db)) {
@@ -69,9 +71,11 @@ public class ThreeWayDiffEntryTest extends LocalDiskRepositoryTestCase {
public void shouldListIncomingAddition() throws Exception {
// given
writeTrashFile("a.txt", "content");
- Git git = new Git(db);
- git.add().addFilepattern("a.txt").call();
- RevCommit c = git.commit().setMessage("initial commit").call();
+ RevCommit c;
+ try (Git git = new Git(db)) {
+ git.add().addFilepattern("a.txt").call();
+ c = git.commit().setMessage("initial commit").call();
+ }
// when
try (TreeWalk walk = new TreeWalk(db)) {
@@ -95,9 +99,11 @@ public class ThreeWayDiffEntryTest extends LocalDiskRepositoryTestCase {
public void shouldListOutgoingDelete() throws Exception {
// given
writeTrashFile("a.txt", "content");
- Git git = new Git(db);
- git.add().addFilepattern("a.txt").call();
- RevCommit c = git.commit().setMessage("initial commit").call();
+ RevCommit c;
+ try (Git git = new Git(db)) {
+ git.add().addFilepattern("a.txt").call();
+ c = git.commit().setMessage("initial commit").call();
+ }
// when
try (TreeWalk walk = new TreeWalk(db)) {
@@ -121,9 +127,11 @@ public class ThreeWayDiffEntryTest extends LocalDiskRepositoryTestCase {
public void shouldListIncomingDelete() throws Exception {
// given
writeTrashFile("a.txt", "content");
- Git git = new Git(db);
- git.add().addFilepattern("a.txt").call();
- RevCommit c = git.commit().setMessage("initial commit").call();
+ RevCommit c;
+ try (Git git = new Git(db)) {
+ git.add().addFilepattern("a.txt").call();
+ c = git.commit().setMessage("initial commit").call();
+ }
// when
try (TreeWalk walk = new TreeWalk(db)) {
@@ -147,9 +155,11 @@ public class ThreeWayDiffEntryTest extends LocalDiskRepositoryTestCase {
public void shouldListConflictingChange() throws Exception {
// given
writeTrashFile("a.txt", "content");
- Git git = new Git(db);
- git.add().addFilepattern("a.txt").call();
- RevCommit c = git.commit().setMessage("initial commit").call();
+ RevCommit c;
+ try (Git git = new Git(db)) {
+ git.add().addFilepattern("a.txt").call();
+ c = git.commit().setMessage("initial commit").call();
+ }
// when
try (TreeWalk walk = new TreeWalk(db)) {
@@ -173,9 +183,11 @@ public class ThreeWayDiffEntryTest extends LocalDiskRepositoryTestCase {
public void shouldListConflictingChange2() throws Exception {
// given
writeTrashFile("a.txt", "content");
- Git git = new Git(db);
- git.add().addFilepattern("a.txt").call();
- RevCommit c = git.commit().setMessage("initial commit").call();
+ RevCommit c;
+ try (Git git = new Git(db)) {
+ git.add().addFilepattern("a.txt").call();
+ c = git.commit().setMessage("initial commit").call();
+ }
// when
try (TreeWalk walk = new TreeWalk(db)) {
@@ -198,12 +210,14 @@ public class ThreeWayDiffEntryTest extends LocalDiskRepositoryTestCase {
public void shouldListIncomingModify() throws Exception {
// given
writeTrashFile("a.txt", "content");
- Git git = new Git(db);
- git.add().addFilepattern("a.txt").call();
- RevCommit c = git.commit().setMessage("initial commit").call();
- writeTrashFile("a.txt", "new line");
- RevCommit c1 = git.commit().setAll(true).setMessage("second commit")
- .call();
+ RevCommit c;
+ RevCommit c1;
+ try (Git git = new Git(db)) {
+ git.add().addFilepattern("a.txt").call();
+ c = git.commit().setMessage("initial commit").call();
+ writeTrashFile("a.txt", "new line");
+ c1 = git.commit().setAll(true).setMessage("second commit").call();
+ }
// when
try (TreeWalk walk = new TreeWalk(db)) {
@@ -227,12 +241,14 @@ public class ThreeWayDiffEntryTest extends LocalDiskRepositoryTestCase {
public void shouldListOutgoingModify() throws Exception {
// given
writeTrashFile("a.txt", "content");
- Git git = new Git(db);
- git.add().addFilepattern("a.txt").call();
- RevCommit c = git.commit().setMessage("initial commit").call();
- writeTrashFile("a.txt", "newe line");
- RevCommit c1 = git.commit().setAll(true).setMessage("second commit")
- .call();
+ RevCommit c;
+ RevCommit c1;
+ try (Git git = new Git(db)) {
+ git.add().addFilepattern("a.txt").call();
+ c = git.commit().setMessage("initial commit").call();
+ writeTrashFile("a.txt", "newe line");
+ c1 = git.commit().setAll(true).setMessage("second commit").call();
+ }
// when
try (TreeWalk walk = new TreeWalk(db)) {
@@ -256,12 +272,14 @@ public class ThreeWayDiffEntryTest extends LocalDiskRepositoryTestCase {
public void shouldListConflictingModify() throws Exception {
// given
writeTrashFile("a.txt", "content");
- Git git = new Git(db);
- git.add().addFilepattern("a.txt").call();
- RevCommit c = git.commit().setMessage("initial commit").call();
- writeTrashFile("a.txt", "new line");
- RevCommit c1 = git.commit().setAll(true).setMessage("second commit")
- .call();
+ RevCommit c;
+ RevCommit c1;
+ try (Git git = new Git(db)) {
+ git.add().addFilepattern("a.txt").call();
+ c = git.commit().setMessage("initial commit").call();
+ writeTrashFile("a.txt", "new line");
+ c1 = git.commit().setAll(true).setMessage("second commit").call();
+ }
// when
try (TreeWalk walk = new TreeWalk(db)) {
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/WorkingTreeChangeCacheTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/WorkingTreeChangeCacheTest.java
index 1e3260ba5..941560ea3 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/WorkingTreeChangeCacheTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/WorkingTreeChangeCacheTest.java
@@ -82,7 +82,9 @@ public class WorkingTreeChangeCacheTest extends AbstractCacheTest {
public void shouldListSingleWorkspaceDeletion() throws Exception {
// given
writeTrashFile(db, "a.txt", "trash");
- new Git(db).add().addFilepattern("a.txt").call();
+ try (Git git = new Git(db)) {
+ git.add().addFilepattern("a.txt").call();
+ }
deleteTrashFile(db, "a.txt");
// when
@@ -98,7 +100,9 @@ public class WorkingTreeChangeCacheTest extends AbstractCacheTest {
// given
writeTrashFile(db, "a.txt", "trash");
writeTrashFile(db, "b.txt", "trash");
- new Git(db).add().addFilepattern("a.txt").addFilepattern("b.txt").call();
+ try (Git git = new Git(db)) {
+ git.add().addFilepattern("a.txt").addFilepattern("b.txt").call();
+ }
deleteTrashFile(db, "a.txt");
deleteTrashFile(db, "b.txt");
@@ -115,7 +119,9 @@ public class WorkingTreeChangeCacheTest extends AbstractCacheTest {
public void shouldListSingleWorkspaceDeletionInFolder() throws Exception {
// given
writeTrashFile(db, "folder/a.txt", "trash");
- new Git(db).add().addFilepattern("folder/a.txt").call();
+ try (Git git = new Git(db)) {
+ git.add().addFilepattern("folder/a.txt").call();
+ }
deleteTrashFile(db, "folder/a.txt");
// when
@@ -131,7 +137,10 @@ public class WorkingTreeChangeCacheTest extends AbstractCacheTest {
// given
writeTrashFile(db, "folder/a.txt", "trash");
writeTrashFile(db, "folder/b.txt", "trash");
- new Git(db).add().addFilepattern("folder/a.txt").addFilepattern("folder/b.txt").call();
+ try (Git git = new Git(db)) {
+ git.add().addFilepattern("folder/a.txt")
+ .addFilepattern("folder/b.txt").call();
+ }
deleteTrashFile(db, "folder/a.txt");
deleteTrashFile(db, "folder/b.txt");
@@ -148,7 +157,9 @@ public class WorkingTreeChangeCacheTest extends AbstractCacheTest {
public void shouldListSingleWorkspaceChange() throws Exception {
// given
writeTrashFile(db, "a.txt", "trash");
- new Git(db).add().addFilepattern("a.txt").call();
+ try (Git git = new Git(db)) {
+ git.add().addFilepattern("a.txt").call();
+ }
writeTrashFile(db, "a.txt", "modification");
// when
@@ -164,7 +175,9 @@ public class WorkingTreeChangeCacheTest extends AbstractCacheTest {
// given
writeTrashFile(db, "a.txt", "trash");
writeTrashFile(db, "b.txt", "trash");
- new Git(db).add().addFilepattern("a.txt").addFilepattern("b.txt").call();
+ try (Git git = new Git(db)) {
+ git.add().addFilepattern("a.txt").addFilepattern("b.txt").call();
+ }
writeTrashFile(db, "a.txt", "modification");
writeTrashFile(db, "b.txt", "modification");
@@ -181,7 +194,9 @@ public class WorkingTreeChangeCacheTest extends AbstractCacheTest {
public void shouldListSingleWorkspaceChangeInFolder() throws Exception {
// given
writeTrashFile(db, "folder/a.txt", "trash");
- new Git(db).add().addFilepattern("folder/a.txt").call();
+ try (Git git = new Git(db)) {
+ git.add().addFilepattern("folder/a.txt").call();
+ }
writeTrashFile(db, "folder/a.txt", "modification");
// when
@@ -197,7 +212,10 @@ public class WorkingTreeChangeCacheTest extends AbstractCacheTest {
// given
writeTrashFile(db, "folder/a.txt", "trash");
writeTrashFile(db, "folder/b.txt", "trash");
- new Git(db).add().addFilepattern("folder/a.txt").addFilepattern("folder/b.txt").call();
+ try (Git git = new Git(db)) {
+ git.add().addFilepattern("folder/a.txt")
+ .addFilepattern("folder/b.txt").call();
+ }
writeTrashFile(db, "folder/a.txt", "modification");
writeTrashFile(db, "folder/b.txt", "modification");
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/dto/GitSynchronizeDataTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/dto/GitSynchronizeDataTest.java
index 1594a6999..e5d464e94 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/dto/GitSynchronizeDataTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/dto/GitSynchronizeDataTest.java
@@ -39,8 +39,10 @@ public class GitSynchronizeDataTest extends GitTestCase {
repo = RepositoryMapping.getMapping(project.project).getRepository();
// make initial commit
- new Git(repo).commit().setAuthor("JUnit", "junit@jgit.org")
- .setMessage("Initial commit").call();
+ try (Git git = new Git(repo)) {
+ git.commit().setAuthor("JUnit", "junit@jgit.org")
+ .setMessage("Initial commit").call();
+ }
}
@Test
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitProjectSetCapabilityTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitProjectSetCapabilityTest.java
index 8d9bef7e5..166dd9ae5 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitProjectSetCapabilityTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitProjectSetCapabilityTest.java
@@ -376,11 +376,13 @@ public class GitProjectSetCapabilityTest {
repo.create();
repo.close();
- Git git = new Git(repo);
- git.add().addFilepattern(".").call();
- git.commit().setMessage("initial").call();
- if (!branch.equals("master"))
- git.checkout().setName(branch).setCreateBranch(true).call();
+ try (Git git = new Git(repo)) {
+ git.add().addFilepattern(".").call();
+ git.commit().setMessage("initial").call();
+ if (!branch.equals("master")) {
+ git.checkout().setName(branch).setCreateBranch(true).call();
+ }
+ }
pathsToClean.add(gitDirectory);
return gitDirectory;
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java
index 9910b2884..398bc7019 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java
@@ -226,12 +226,13 @@ public class TestRepository {
NoMessageException, UnmergedPathException,
ConcurrentRefUpdateException, JGitInternalException,
WrongRepositoryStateException, GitAPIException {
- Git git = new Git(repository);
- CommitCommand commitCommand = git.commit();
- commitCommand.setAuthor("J. Git", "j.git@egit.org");
- commitCommand.setCommitter(commitCommand.getAuthor());
- commitCommand.setMessage(message);
- return commitCommand.call();
+ try (Git git = new Git(repository)) {
+ CommitCommand commitCommand = git.commit();
+ commitCommand.setAuthor("J. Git", "j.git@egit.org");
+ commitCommand.setCommitter(commitCommand.getAuthor());
+ commitCommand.setMessage(message);
+ return commitCommand.call();
+ }
}
/**
@@ -245,7 +246,9 @@ public class TestRepository {
public void track(File file) throws IOException, NoFilepatternException, GitAPIException {
String repoPath = getRepoRelativePath(new Path(file.getPath())
.toString());
- new Git(repository).add().addFilepattern(repoPath).call();
+ try (Git git = new Git(repository)) {
+ git.add().addFilepattern(repoPath).call();
+ }
}
/**
@@ -282,8 +285,8 @@ public class TestRepository {
public void untrack(File file) throws IOException {
String repoPath = getRepoRelativePath(new Path(file.getPath())
.toString());
- try {
- new Git(repository).rm().addFilepattern(repoPath).call();
+ try (Git git = new Git(repository)) {
+ git.rm().addFilepattern(repoPath).call();
} catch (GitAPIException e) {
throw new IOException(e.getMessage());
}
@@ -363,7 +366,9 @@ public class TestRepository {
*/
public void addToIndex(IResource resource) throws CoreException, IOException, NoFilepatternException, GitAPIException {
String repoPath = getRepoRelativePath(resource.getLocation().toString());
- new Git(repository).add().addFilepattern(repoPath).call();
+ try (Git git = new Git(repository)) {
+ git.add().addFilepattern(repoPath).call();
+ }
}
/**
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/internal/mapping/HistoryTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/internal/mapping/HistoryTest.java
index 69f5d214b..e146dbb3b 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/internal/mapping/HistoryTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/internal/mapping/HistoryTest.java
@@ -67,18 +67,19 @@ public class HistoryTest extends GitTestCase {
workDir = thisGit.getWorkTree();
thisGit.create();
- Git git = new Git(thisGit);
-
- createFile("Project-1/A.txt","A.txt - first version\n");
- createFile("Project-1/B.txt","B.txt - first version\n");
- git.add().addFilepattern("Project-1/A.txt").addFilepattern("Project-1/B.txt").call();
- git.commit().setAuthor(jauthor).setCommitter(jcommitter)
- .setMessage("Foo\n\nMessage").call();
-
- createFile("Project-1/B.txt","B.txt - second version\n");
- git.add().addFilepattern("Project-1/B.txt").call();
- git.commit().setAuthor(jauthor).setCommitter(jcommitter)
- .setMessage("Modified").call();
+ try (Git git = new Git(thisGit)) {
+ createFile("Project-1/A.txt", "A.txt - first version\n");
+ createFile("Project-1/B.txt", "B.txt - first version\n");
+ git.add().addFilepattern("Project-1/A.txt")
+ .addFilepattern("Project-1/B.txt").call();
+ git.commit().setAuthor(jauthor).setCommitter(jcommitter)
+ .setMessage("Foo\n\nMessage").call();
+
+ createFile("Project-1/B.txt", "B.txt - second version\n");
+ git.add().addFilepattern("Project-1/B.txt").call();
+ git.commit().setAuthor(jauthor).setCommitter(jcommitter)
+ .setMessage("Modified").call();
+ }
ConnectProviderOperation operation = new ConnectProviderOperation(
project.getProject(), gitDir);
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/ModelTestCase.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/ModelTestCase.java
index e17a47b2f..4accd975b 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/ModelTestCase.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/ModelTestCase.java
@@ -98,7 +98,9 @@ public abstract class ModelTestCase extends GitTestCase {
}
protected Status status(Repository repository) throws Exception {
- return new Git(repository).status().call();
+ try (Git git = new Git(repository)) {
+ return git.status().call();
+ }
}
protected IResourceMappingMerger createMerger() throws CoreException {
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/CloneOperationTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/CloneOperationTest.java
index fba5bbbd8..0d9267344 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/CloneOperationTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/CloneOperationTest.java
@@ -50,22 +50,23 @@ public class CloneOperationTest extends DualRepositoryTestCase {
File file = new File(workdir, "file1.txt");
FileUtils.createNewFile(file);
- Git git = new Git(repository1.getRepository());
- git.add().addFilepattern("file1.txt").call();
-
- git.commit().setMessage("first commit").call();
- git.tag().setName("tag").call();
-
- file = new File(workdir, "file2.txt");
- FileUtils.createNewFile(file);
- git.add().addFilepattern("file2.txt").call();
- git.commit().setMessage("second commit").call();
- git.branchCreate().setName("dev").call();
-
- file = new File(workdir, "file3.txt");
- FileUtils.createNewFile(file);
- git.add().addFilepattern("file3.txt").call();
- git.commit().setMessage("third commit").call();
+ try (Git git = new Git(repository1.getRepository())) {
+ git.add().addFilepattern("file1.txt").call();
+
+ git.commit().setMessage("first commit").call();
+ git.tag().setName("tag").call();
+
+ file = new File(workdir, "file2.txt");
+ FileUtils.createNewFile(file);
+ git.add().addFilepattern("file2.txt").call();
+ git.commit().setMessage("second commit").call();
+ git.branchCreate().setName("dev").call();
+
+ file = new File(workdir, "file3.txt");
+ FileUtils.createNewFile(file);
+ git.add().addFilepattern("file3.txt").call();
+ git.commit().setMessage("third commit").call();
+ }
}
@Test
@@ -192,10 +193,12 @@ public class CloneOperationTest extends DualRepositoryTestCase {
}
protected void createNoteInOrigin() throws GitAPIException {
- Git git = new Git(repository1.getRepository());
- git.add().addFilepattern("file.txt").call();
- RevCommit commit = git.commit().setMessage("Initial commit").call();
- git.notesAdd().setNotesRef("refs/notes/review").setObjectId(commit).setMessage("text").call();
+ try (Git git = new Git(repository1.getRepository())) {
+ git.add().addFilepattern("file.txt").call();
+ RevCommit commit = git.commit().setMessage("Initial commit").call();
+ git.notesAdd().setNotesRef("refs/notes/review").setObjectId(commit)
+ .setMessage("text").call();
+ }
}
}
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/CommitOperationTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/CommitOperationTest.java
index d8fcc7cee..15fe9ade5 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/CommitOperationTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/CommitOperationTest.java
@@ -129,8 +129,10 @@ public class CommitOperationTest extends GitTestCase {
commitOperation.setRepository(repository);
commitOperation.execute(null);
- Git git = new Git(repository);
- Iterator<RevCommit> commits = git.log().call().iterator();
+ Iterator<RevCommit> commits;
+ try (Git git = new Git(repository)) {
+ commits = git.log().call().iterator();
+ }
RevCommit firstCommit = commits.next();
assertTrue(firstCommit.getCommitTime() > 0);
@@ -144,8 +146,9 @@ public class CommitOperationTest extends GitTestCase {
commitOperation.setRepository(repository);
commitOperation.execute(null);
- git = new Git(repository);
- commits = git.log().call().iterator();
+ try (Git git = new Git(repository)) {
+ commits = git.log().call().iterator();
+ }
RevCommit secondCommit = commits.next();
assertTrue(secondCommit.getCommitTime() > 0);
@@ -173,8 +176,10 @@ public class CommitOperationTest extends GitTestCase {
commitOperation.setRepository(repository);
commitOperation.execute(null);
- Git git = new Git(repository);
- Iterator<RevCommit> commits = git.log().call().iterator();
+ Iterator<RevCommit> commits;
+ try (Git git = new Git(repository)) {
+ commits = git.log().call().iterator();
+ }
RevCommit secondCommit = commits.next();
try (TreeWalk treeWalk = new TreeWalk(repository)) {
treeWalk.addTree(secondCommit.getTree().getId());
@@ -199,8 +204,9 @@ public class CommitOperationTest extends GitTestCase {
commitOperation.setCommitAll(false);
commitOperation.execute(null);
- git = new Git(repository);
- commits = git.log().call().iterator();
+ try (Git git = new Git(repository)) {
+ commits = git.log().call().iterator();
+ }
secondCommit = commits.next();
try (TreeWalk treeWalk = new TreeWalk(repository)) {
treeWalk.addTree(secondCommit.getTree().getId());
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/MergeOperationTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/MergeOperationTest.java
index cc6dd7e1a..cb0aa543a 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/MergeOperationTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/MergeOperationTest.java
@@ -144,7 +144,10 @@ public class MergeOperationTest extends GitTestCase {
}
private int countCommitsInHead() throws GitAPIException {
- LogCommand log = new Git(testRepository.getRepository()).log();
+ LogCommand log;
+ try (Git git = new Git(testRepository.getRepository())) {
+ log = git.log();
+ }
Iterable<RevCommit> commits = log.call();
int result = 0;
for (Iterator i = commits.iterator(); i.hasNext();) {
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/RewordCommitsOperationTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/RewordCommitsOperationTest.java
index fa19d8960..45a2fc795 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/RewordCommitsOperationTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/RewordCommitsOperationTest.java
@@ -59,7 +59,10 @@ public class RewordCommitsOperationTest extends GitTestCase {
testRepository.getRepository(), commit, "new message");
op.execute(new NullProgressMonitor());
- LogCommand log = new Git(testRepository.getRepository()).log();
+ LogCommand log;
+ try (Git git = new Git(testRepository.getRepository())) {
+ log = git.log();
+ }
RevCommit newCommit = log.call().iterator().next();
assertEquals("new message", newCommit.getFullMessage());
}
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/SquashCommitsOperationTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/SquashCommitsOperationTest.java
index 69970a7fc..f119146e6 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/SquashCommitsOperationTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/SquashCommitsOperationTest.java
@@ -88,14 +88,20 @@ public class SquashCommitsOperationTest extends GitTestCase {
assertEquals(2, countCommitsInHead());
- LogCommand log = new Git(testRepository.getRepository()).log();
+ LogCommand log;
+ try (Git git = new Git(testRepository.getRepository())) {
+ log = git.log();
+ }
Iterable<RevCommit> logCommits = log.call();
RevCommit latestCommit = logCommits.iterator().next();
assertEquals("squashed", latestCommit.getFullMessage());
}
private int countCommitsInHead() throws GitAPIException {
- LogCommand log = new Git(testRepository.getRepository()).log();
+ LogCommand log;
+ try (Git git = new Git(testRepository.getRepository())) {
+ log = git.log();
+ }
Iterable<RevCommit> commits = log.call();
int result = 0;
for (Iterator i = commits.iterator(); i.hasNext();) {

Back to the top