ApplyCommandTest: Open Git in try-with-resource

Also, add missing braces around if-block.

Change-Id: I9390b2c7d5c4507923b6f06271a070dc868534e5
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
This commit is contained in:
David Pursehouse 2016-02-02 18:22:32 +09:00
parent 5c84145fd0
commit d4ddb6fc2b
1 changed files with 15 additions and 14 deletions

View File

@ -69,23 +69,24 @@ private ApplyResult init(final String name) throws Exception {
private ApplyResult init(final String name, final boolean preExists,
final boolean postExists) throws Exception {
Git git = new Git(db);
try (Git git = new Git(db)) {
if (preExists) {
a = new RawText(readFile(name + "_PreImage"));
write(new File(db.getDirectory().getParent(), name),
a.getString(0, a.size(), false));
if (preExists) {
a = new RawText(readFile(name + "_PreImage"));
write(new File(db.getDirectory().getParent(), name),
a.getString(0, a.size(), false));
git.add().addFilepattern(name).call();
git.commit().setMessage("PreImage").call();
}
git.add().addFilepattern(name).call();
git.commit().setMessage("PreImage").call();
if (postExists) {
b = new RawText(readFile(name + "_PostImage"));
}
return git
.apply()
.setPatch(getTestResource(name + ".patch")).call();
}
if (postExists)
b = new RawText(readFile(name + "_PostImage"));
return git
.apply()
.setPatch(getTestResource(name + ".patch")).call();
}
@Test