Browse Source

PullCommandTest: Open RevWalk in try-with-resource

Change-Id: I676cd7ef4bb29f980a313acd77506dd070e6c98f
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
stable-4.2
David Pursehouse 9 years ago
parent
commit
7ccda5f63e
  1. 15
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java

15
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java

@ -140,12 +140,13 @@ public class PullCommandTest extends RepositoryTestCase {
ObjectId[] mergedCommits = mergeResult.getMergedCommits();
assertEquals(targetCommit.getId(), mergedCommits[0]);
assertEquals(sourceCommit.getId(), mergedCommits[1]);
RevCommit mergeCommit = new RevWalk(dbTarget).parseCommit(mergeResult
.getNewHead());
try (RevWalk rw = new RevWalk(dbTarget)) {
RevCommit mergeCommit = rw.parseCommit(mergeResult.getNewHead());
String message = "Merge branch 'master' of "
+ db.getWorkTree().getAbsolutePath();
assertEquals(message, mergeCommit.getShortMessage());
}
}
@Test
public void testPullConflict() throws Exception {
@ -259,12 +260,13 @@ public class PullCommandTest extends RepositoryTestCase {
ObjectId[] mergedCommits = mergeResult.getMergedCommits();
assertEquals(targetCommit.getId(), mergedCommits[0]);
assertEquals(sourceCommit.getId(), mergedCommits[1]);
RevCommit mergeCommit = new RevWalk(dbTarget).parseCommit(mergeResult
.getNewHead());
try (RevWalk rw = new RevWalk(dbTarget)) {
RevCommit mergeCommit = rw.parseCommit(mergeResult.getNewHead());
String message = "Merge branch 'other' of "
+ db.getWorkTree().getAbsolutePath();
assertEquals(message, mergeCommit.getShortMessage());
}
}
@Test
public void testPullMergeProgrammaticConfigurationImpliedTargetBranch()
@ -293,12 +295,13 @@ public class PullCommandTest extends RepositoryTestCase {
ObjectId[] mergedCommits = mergeResult.getMergedCommits();
assertEquals(targetCommit.getId(), mergedCommits[0]);
assertEquals(sourceCommit.getId(), mergedCommits[1]);
RevCommit mergeCommit = new RevWalk(dbTarget).parseCommit(mergeResult
.getNewHead());
try (RevWalk rw = new RevWalk(dbTarget)) {
RevCommit mergeCommit = rw.parseCommit(mergeResult.getNewHead());
String message = "Merge branch 'other' of "
+ db.getWorkTree().getAbsolutePath() + " into other";
assertEquals(message, mergeCommit.getShortMessage());
}
}
private enum TestPullMode {
MERGE, REBASE, REBASE_PREASERVE

Loading…
Cancel
Save