summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@sonymobile.com>2016-02-12 12:25:20 +0900
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2016-02-12 12:25:20 +0900
commit5ca9aaa17277c2d7f33508afcdc8f748fada8881 (patch)
tree5f95eed4d067747120c947ac8db3b4533399f342 /org.eclipse.jgit.test
parent26012958a35d85639fe44fdbd4690cb58ec3b836 (diff)
downloadjgit-5ca9aaa17277c2d7f33508afcdc8f748fada8881.tar.gz
jgit-5ca9aaa17277c2d7f33508afcdc8f748fada8881.zip
RepoCommandTest: Open Git instances in try-with-resource
Change-Id: I171e84eeb7862e74761ba6c961f14c86beaba9e7 Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java56
1 files changed, 30 insertions, 26 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java
index 524d0b8e7e..77ef1a6466 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java
@@ -82,38 +82,42 @@ public class RepoCommandTest extends RepositoryTestCase {
super.setUp();
defaultDb = createWorkRepository();
- Git git = new Git(defaultDb);
- JGitTestUtil.writeTrashFile(defaultDb, "hello.txt", "branch world");
- git.add().addFilepattern("hello.txt").call();
- oldCommitId = git.commit().setMessage("Initial commit").call().getId();
- git.checkout().setName(BRANCH).setCreateBranch(true).call();
- git.checkout().setName("master").call();
- git.tag().setName(TAG).call();
- JGitTestUtil.writeTrashFile(defaultDb, "hello.txt", "master world");
- git.add().addFilepattern("hello.txt").call();
- git.commit().setMessage("Second commit").call();
- addRepoToClose(defaultDb);
+ try (Git git = new Git(defaultDb)) {
+ JGitTestUtil.writeTrashFile(defaultDb, "hello.txt", "branch world");
+ git.add().addFilepattern("hello.txt").call();
+ oldCommitId = git.commit().setMessage("Initial commit").call().getId();
+ git.checkout().setName(BRANCH).setCreateBranch(true).call();
+ git.checkout().setName("master").call();
+ git.tag().setName(TAG).call();
+ JGitTestUtil.writeTrashFile(defaultDb, "hello.txt", "master world");
+ git.add().addFilepattern("hello.txt").call();
+ git.commit().setMessage("Second commit").call();
+ addRepoToClose(defaultDb);
+ }
notDefaultDb = createWorkRepository();
- git = new Git(notDefaultDb);
- JGitTestUtil.writeTrashFile(notDefaultDb, "world.txt", "hello");
- git.add().addFilepattern("world.txt").call();
- git.commit().setMessage("Initial commit").call();
- addRepoToClose(notDefaultDb);
+ try (Git git = new Git(notDefaultDb)) {
+ JGitTestUtil.writeTrashFile(notDefaultDb, "world.txt", "hello");
+ git.add().addFilepattern("world.txt").call();
+ git.commit().setMessage("Initial commit").call();
+ addRepoToClose(notDefaultDb);
+ }
groupADb = createWorkRepository();
- git = new Git(groupADb);
- JGitTestUtil.writeTrashFile(groupADb, "a.txt", "world");
- git.add().addFilepattern("a.txt").call();
- git.commit().setMessage("Initial commit").call();
- addRepoToClose(groupADb);
+ try (Git git = new Git(groupADb)) {
+ JGitTestUtil.writeTrashFile(groupADb, "a.txt", "world");
+ git.add().addFilepattern("a.txt").call();
+ git.commit().setMessage("Initial commit").call();
+ addRepoToClose(groupADb);
+ }
groupBDb = createWorkRepository();
- git = new Git(groupBDb);
- JGitTestUtil.writeTrashFile(groupBDb, "b.txt", "world");
- git.add().addFilepattern("b.txt").call();
- git.commit().setMessage("Initial commit").call();
- addRepoToClose(groupBDb);
+ try (Git git = new Git(groupBDb)) {
+ JGitTestUtil.writeTrashFile(groupBDb, "b.txt", "world");
+ git.add().addFilepattern("b.txt").call();
+ git.commit().setMessage("Initial commit").call();
+ addRepoToClose(groupBDb);
+ }
resolveRelativeUris();
}