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:
parent
5c84145fd0
commit
d4ddb6fc2b
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue