Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse2016-02-05 09:14:26 +0000
committerDavid Pursehouse2016-02-05 09:14:26 +0000
commit143ba06cd6259b8c64733a08f3d66cbe51e76b7f (patch)
tree8954fa176569fb5b09835f6d5f5bc5115e9c2b1a
parentb85e93046c51dccf0800bed2d33e61d3242da4f1 (diff)
downloadjgit-143ba06cd6259b8c64733a08f3d66cbe51e76b7f.tar.gz
jgit-143ba06cd6259b8c64733a08f3d66cbe51e76b7f.tar.xz
jgit-143ba06cd6259b8c64733a08f3d66cbe51e76b7f.zip
RepositoryResolveTest: Open Git in try-with-resource
Change-Id: Ibb612f3d8fd0f9913291430474311d9da62f4e6f Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryResolveTest.java52
1 files changed, 27 insertions, 25 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryResolveTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryResolveTest.java
index c9ea286407..1d2a4e9ab7 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryResolveTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryResolveTest.java
@@ -267,35 +267,37 @@ public class RepositoryResolveTest extends SampleDataRepositoryTestCase {
@Test
public void resolveExprSimple() throws Exception {
- Git git = new Git(db);
- writeTrashFile("file.txt", "content");
- git.add().addFilepattern("file.txt").call();
- git.commit().setMessage("create file").call();
- assertEquals("master", db.simplify("master"));
- assertEquals("refs/heads/master", db.simplify("refs/heads/master"));
- assertEquals("HEAD", db.simplify("HEAD"));
+ try (Git git = new Git(db)) {
+ writeTrashFile("file.txt", "content");
+ git.add().addFilepattern("file.txt").call();
+ git.commit().setMessage("create file").call();
+ assertEquals("master", db.simplify("master"));
+ assertEquals("refs/heads/master", db.simplify("refs/heads/master"));
+ assertEquals("HEAD", db.simplify("HEAD"));
+ }
}
@Test
public void resolveUpstream() throws Exception {
- Git git = new Git(db);
- writeTrashFile("file.txt", "content");
- git.add().addFilepattern("file.txt").call();
- RevCommit c1 = git.commit().setMessage("create file").call();
- writeTrashFile("file2.txt", "content");
- RefUpdate updateRemoteRef = db.updateRef("refs/remotes/origin/main");
- updateRemoteRef.setNewObjectId(c1);
- updateRemoteRef.update();
- db.getConfig().setString("branch", "master", "remote", "origin");
- db.getConfig()
- .setString("branch", "master", "merge", "refs/heads/main");
- db.getConfig().setString("remote", "origin", "url",
- "git://example.com/here");
- db.getConfig().setString("remote", "origin", "fetch",
- "+refs/heads/*:refs/remotes/origin/*");
- git.add().addFilepattern("file2.txt").call();
- git.commit().setMessage("create file").call();
- assertEquals("refs/remotes/origin/main", db.simplify("@{upstream}"));
+ try (Git git = new Git(db)) {
+ writeTrashFile("file.txt", "content");
+ git.add().addFilepattern("file.txt").call();
+ RevCommit c1 = git.commit().setMessage("create file").call();
+ writeTrashFile("file2.txt", "content");
+ RefUpdate updateRemoteRef = db.updateRef("refs/remotes/origin/main");
+ updateRemoteRef.setNewObjectId(c1);
+ updateRemoteRef.update();
+ db.getConfig().setString("branch", "master", "remote", "origin");
+ db.getConfig()
+ .setString("branch", "master", "merge", "refs/heads/main");
+ db.getConfig().setString("remote", "origin", "url",
+ "git://example.com/here");
+ db.getConfig().setString("remote", "origin", "fetch",
+ "+refs/heads/*:refs/remotes/origin/*");
+ git.add().addFilepattern("file2.txt").call();
+ git.commit().setMessage("create file").call();
+ assertEquals("refs/remotes/origin/main", db.simplify("@{upstream}"));
+ }
}
@Test

Back to the top