Browse Source

RepoTest: Open Git in try-with-resources

Allocate a new Git for each part of the test, rather than
reassigning to the same variable.

Change-Id: Ic83778bbff0b2f57d37b95aef70324859d42cd58
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
tags/v4.3.0.201603230630-rc1
David Pursehouse 8 years ago
parent
commit
ef471b0861
1 changed files with 20 additions and 16 deletions
  1. 20
    16
      org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/RepoTest.java

+ 20
- 16
org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/RepoTest.java View File

@@ -74,28 +74,32 @@ public class RepoTest extends CLIRepositoryTestCase {
super.setUp();

defaultDb = createWorkRepository();
Git git = new Git(defaultDb);
JGitTestUtil.writeTrashFile(defaultDb, "hello.txt", "world");
git.add().addFilepattern("hello.txt").call();
git.commit().setMessage("Initial commit").call();
try (Git git = new Git(defaultDb)) {
JGitTestUtil.writeTrashFile(defaultDb, "hello.txt", "world");
git.add().addFilepattern("hello.txt").call();
git.commit().setMessage("Initial commit").call();
}

notDefaultDb = createWorkRepository();
git = new Git(notDefaultDb);
JGitTestUtil.writeTrashFile(notDefaultDb, "world.txt", "hello");
git.add().addFilepattern("world.txt").call();
git.commit().setMessage("Initial commit").call();
try (Git git = new Git(notDefaultDb)) {
JGitTestUtil.writeTrashFile(notDefaultDb, "world.txt", "hello");
git.add().addFilepattern("world.txt").call();
git.commit().setMessage("Initial commit").call();
}

groupADb = createWorkRepository();
git = new Git(groupADb);
JGitTestUtil.writeTrashFile(groupADb, "a.txt", "world");
git.add().addFilepattern("a.txt").call();
git.commit().setMessage("Initial commit").call();
try (Git git = new Git(groupADb)) {
JGitTestUtil.writeTrashFile(groupADb, "a.txt", "world");
git.add().addFilepattern("a.txt").call();
git.commit().setMessage("Initial commit").call();
}

groupBDb = createWorkRepository();
git = new Git(groupBDb);
JGitTestUtil.writeTrashFile(groupBDb, "b.txt", "world");
git.add().addFilepattern("b.txt").call();
git.commit().setMessage("Initial commit").call();
try (Git git = new Git(groupBDb)) {
JGitTestUtil.writeTrashFile(groupBDb, "b.txt", "world");
git.add().addFilepattern("b.txt").call();
git.commit().setMessage("Initial commit").call();
}

resolveRelativeUris();
}

Loading…
Cancel
Save