Browse Source

BranchTest: Create Git instances in try-with-resource

Change-Id: I8becee479fab91a18e6daffd6f4fd57338c9d120
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
stable-4.2
David Pursehouse 9 years ago committed by Matthias Sohn
parent
commit
9d721de69b
  1. 20
      org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/BranchTest.java

20
org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/BranchTest.java

@ -57,7 +57,9 @@ public class BranchTest extends CLIRepositoryTestCase {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
super.setUp(); super.setUp();
new Git(db).commit().setMessage("initial commit").call(); try (Git git = new Git(db)) {
git.commit().setMessage("initial commit").call();
}
} }
@Test @Test
@ -77,13 +79,15 @@ public class BranchTest extends CLIRepositoryTestCase {
@Test @Test
public void testListContains() throws Exception { public void testListContains() throws Exception {
new Git(db).branchCreate().setName("initial").call(); try (Git git = new Git(db)) {
RevCommit second = new Git(db).commit().setMessage("second commit") git.branchCreate().setName("initial").call();
.call(); RevCommit second = git.commit().setMessage("second commit")
assertArrayOfLinesEquals(new String[] { " initial", "* master", "" }, .call();
execute("git branch --contains 6fd41be")); assertArrayOfLinesEquals(new String[] { " initial", "* master", "" },
assertArrayOfLinesEquals(new String[] { "* master", "" }, execute("git branch --contains 6fd41be"));
execute("git branch --contains " + second.name())); assertArrayOfLinesEquals(new String[] { "* master", "" },
execute("git branch --contains " + second.name()));
}
} }
@Test @Test

Loading…
Cancel
Save