diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2014-01-07 10:15:14 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2014-02-14 16:10:59 +0100 |
commit | 1eae309723be301a4f2fc12a3e07e7e7c9f30782 (patch) | |
tree | dfba2bf9b5a2bf05c2fd21de6e4c059a3728ff37 /org.eclipse.jgit.test/tst | |
parent | 7bb7299e8a815ac7884f429e3bc710e0c27c121c (diff) | |
download | jgit-1eae309723be301a4f2fc12a3e07e7e7c9f30782.tar.gz jgit-1eae309723be301a4f2fc12a3e07e7e7c9f30782.zip |
Allow programmatic remote configuration for PullCommand
Also imply remoteBranchName to match current branch name if it wasn't
configured in branch configuration.
Bug: 424812
Change-Id: Id852cedaefb2a537b6aa3c330b9861efad052f11
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java index c03ced563f..245219d884 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java @@ -232,6 +232,71 @@ public class PullCommandTest extends RepositoryTestCase { Git.wrap(empty).pull().call(); } + @Test + public void testPullMergeProgrammaticConfiguration() throws Exception { + // create another commit on another branch in source + source.checkout().setCreateBranch(true).setName("other").call(); + sourceFile = new File(db.getWorkTree(), "file2.txt"); + writeToFile(sourceFile, "content"); + source.add().addFilepattern("file2.txt").call(); + RevCommit sourceCommit = source.commit() + .setMessage("source commit on branch other").call(); + + File targetFile2 = new File(dbTarget.getWorkTree(), "OtherFile.txt"); + writeToFile(targetFile2, "Unconflicting change"); + target.add().addFilepattern("OtherFile.txt").call(); + RevCommit targetCommit = target.commit() + .setMessage("Unconflicting change in local").call(); + + PullResult res = target.pull().setRemote("origin") + .setRemoteBranchName("other") + .setRebase(false).call(); + + MergeResult mergeResult = res.getMergeResult(); + ObjectId[] mergedCommits = mergeResult.getMergedCommits(); + assertEquals(targetCommit.getId(), mergedCommits[0]); + assertEquals(sourceCommit.getId(), mergedCommits[1]); + RevCommit mergeCommit = new RevWalk(dbTarget).parseCommit(mergeResult + .getNewHead()); + String message = "Merge branch 'other' of " + + db.getWorkTree().getAbsolutePath(); + assertEquals(message, mergeCommit.getShortMessage()); + } + + @Test + public void testPullMergeProgrammaticConfigurationImpliedTargetBranch() + throws Exception { + // create another commit on another branch in source + source.checkout().setCreateBranch(true).setName("other").call(); + sourceFile = new File(db.getWorkTree(), "file2.txt"); + writeToFile(sourceFile, "content"); + source.add().addFilepattern("file2.txt").call(); + RevCommit sourceCommit = source.commit() + .setMessage("source commit on branch other").call(); + + target.checkout().setCreateBranch(true).setName("other").call(); + File targetFile2 = new File(dbTarget.getWorkTree(), "OtherFile.txt"); + writeToFile(targetFile2, "Unconflicting change"); + target.add().addFilepattern("OtherFile.txt").call(); + RevCommit targetCommit = target.commit() + .setMessage("Unconflicting change in local").call(); + + // the source branch "other" matching the target branch should be + // implied + PullResult res = target.pull().setRemote("origin").setRebase(false) + .call(); + + MergeResult mergeResult = res.getMergeResult(); + ObjectId[] mergedCommits = mergeResult.getMergedCommits(); + assertEquals(targetCommit.getId(), mergedCommits[0]); + assertEquals(sourceCommit.getId(), mergedCommits[1]); + RevCommit mergeCommit = new RevWalk(dbTarget).parseCommit(mergeResult + .getNewHead()); + String message = "Merge branch 'other' of " + + db.getWorkTree().getAbsolutePath() + " into other"; + assertEquals(message, mergeCommit.getShortMessage()); + } + @Override @Before public void setUp() throws Exception { |