diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2016-06-01 16:09:40 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2016-06-01 16:10:11 +0200 |
commit | dfb33e699cf41cf81f538d3f570141d001c1bdf5 (patch) | |
tree | b5b62b1ec4fc847b18a647b39ea83559106467be /org.eclipse.jgit.test/tst | |
parent | 9720f9e2492be0da596fb7228590477243e4f529 (diff) | |
parent | 525baa1213097aa8635d846ce024635b1f33931a (diff) | |
download | jgit-dfb33e699cf41cf81f538d3f570141d001c1bdf5.tar.gz jgit-dfb33e699cf41cf81f538d3f570141d001c1bdf5.zip |
Merge branch 'master' into stable-4.4
* master:
Fix javadoc errors and unused imports introduced by ddd0fe25
RepoCommand: record manifest shallow recommendation in .gitmodules
RepoCommand: record manifest groups as submodule labels
Remove the deprecated TestRepository.getClock() method
Replace use of deprecated method Repository.getRef()
[findBugs] Prevent potential NPE in
FileLfsRepository.getOutputStream()
Better report on client side if push failed due to too large object
[findBugs] Prevent potential NPE in CloneCommand.init()
RepoCommand: remove --record-remote-branches
RepoCommandTest: Improve assertion message for remote branch recording
Change-Id: I4fbce4f84925a933fcc9a48058ed6793f5821b97
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/ResetCommandTest.java | 2 | ||||
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java | 98 |
2 files changed, 97 insertions, 3 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java index 725ebc0d23..a4a699ef22 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java @@ -596,7 +596,7 @@ public class ResetCommandTest extends RepositoryTestCase { * @throws IOException */ private void assertSameAsHead(Ref ref) throws IOException { - Ref headRef = db.getRef(Constants.HEAD); + Ref headRef = db.exactRef(Constants.HEAD); assertEquals(headRef.getName(), ref.getName()); assertEquals(headRef.getObjectId(), ref.getObjectId()); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java index 2cec34ba89..ccd15d038d 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java @@ -44,6 +44,7 @@ package org.eclipse.jgit.gitrepo; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import java.io.BufferedReader; @@ -743,14 +744,107 @@ public class RepoCommandTest extends RepositoryTestCase { FileBasedConfig c = new FileBasedConfig(gitmodules, FS.DETECTED); c.load(); - assertEquals("standard branches work", "master", + assertEquals("Recording remote branches should work for short branch descriptions", "master", c.getString("submodule", "with-branch", "branch")); - assertEquals("long branches work", "refs/heads/master", + assertEquals("Recording remote branches should work for full ref specs", "refs/heads/master", c.getString("submodule", "with-long-branch", "branch")); } } } + + @Test + public void testRecordSubmoduleLabels() throws Exception { + try ( + Repository remoteDb = createBareRepository(); + Repository tempDb = createWorkRepository()) { + StringBuilder xmlContent = new StringBuilder(); + xmlContent + .append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n") + .append("<manifest>") + .append("<remote name=\"remote1\" fetch=\".\" />") + .append("<default revision=\"master\" remote=\"remote1\" />") + .append("<project path=\"test\" ") + .append("revision=\"master\" ") + .append("name=\"").append(notDefaultUri).append("\" ") + .append("groups=\"a1,a2\" />") + .append("</manifest>"); + JGitTestUtil.writeTrashFile(tempDb, "manifest.xml", + xmlContent.toString()); + + RepoCommand command = new RepoCommand(remoteDb); + command.setPath(tempDb.getWorkTree().getAbsolutePath() + "/manifest.xml") + .setURI(rootUri) + .setRecordSubmoduleLabels(true) + .call(); + // Clone it + File directory = createTempDirectory("testBareRepo"); + try (Repository localDb = Git.cloneRepository() + .setDirectory(directory) + .setURI(remoteDb.getDirectory().toURI().toString()).call() + .getRepository();) { + // The .gitattributes file should exist + File gitattributes = new File(localDb.getWorkTree(), + ".gitattributes"); + assertTrue("The .gitattributes file should exist", + gitattributes.exists()); + try (BufferedReader reader = new BufferedReader( + new FileReader(gitattributes));) { + String content = reader.readLine(); + assertEquals(".gitattributes content should be as expected", + "/test a1 a2", content); + } + } + } + } + + @Test + public void testRecordShallowRecommendation() throws Exception { + try ( + Repository remoteDb = createBareRepository(); + Repository tempDb = createWorkRepository()) { + StringBuilder xmlContent = new StringBuilder(); + xmlContent + .append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n") + .append("<manifest>") + .append("<remote name=\"remote1\" fetch=\".\" />") + .append("<default revision=\"master\" remote=\"remote1\" />") + .append("<project path=\"shallow-please\" ") + .append("name=\"").append(defaultUri).append("\" ") + .append("clone-depth=\"1\" />") + .append("<project path=\"non-shallow\" ") + .append("name=\"").append(defaultUri).append("\" />") + .append("</manifest>"); + JGitTestUtil.writeTrashFile(tempDb, "manifest.xml", + xmlContent.toString()); + + RepoCommand command = new RepoCommand(remoteDb); + command.setPath(tempDb.getWorkTree().getAbsolutePath() + "/manifest.xml") + .setURI(rootUri) + .setRecommendShallow(true) + .call(); + // Clone it + File directory = createTempDirectory("testBareRepo"); + try (Repository localDb = Git.cloneRepository() + .setDirectory(directory) + .setURI(remoteDb.getDirectory().toURI().toString()).call() + .getRepository();) { + // The .gitmodules file should exist + File gitmodules = new File(localDb.getWorkTree(), + ".gitmodules"); + assertTrue("The .gitmodules file should exist", + gitmodules.exists()); + FileBasedConfig c = new FileBasedConfig(gitmodules, + FS.DETECTED); + c.load(); + assertEquals("Recording shallow configuration should work", "true", + c.getString("submodule", "shallow-please", "shallow")); + assertNull("Recording non shallow configuration should work", + c.getString("submodule", "non-shallow", "shallow")); + } + } + } + @Test public void testRemoteRevision() throws Exception { StringBuilder xmlContent = new StringBuilder(); |